modify frame page
[vnfsdk/refrepo.git] / openo-portal / portal-common / src / main / webapp / common / js / mainpage / about.js
1 /*
2  * Copyright 2016, CMCC Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *         http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 var iniAboutInfo = function() {
17
18     //转换colomn
19
20     var divId = "ict_about_table_div";
21     var tableId = "abouttable";
22     var column = [
23         {"mData": "name", name: $.i18n.prop('com_zte_ums_ict_about_ppu_field_name'), "sWidth": '20%'},
24         {"mData": "version", name: $.i18n.prop('com_zte_ums_ict_about_ppu_field_version'), "sWidth": '25%'},
25         {"mData": "describe", name: $.i18n.prop('com_zte_ums_ict_about_ppu_field_desc'), "sWidth": '25%'},
26         {"mData": "time", name: $.i18n.prop('com_zte_ums_ict_about_ppu_field_time'), "sWidth": '30%'}
27     ];
28     //先把原来的表格清空
29     $('#' + divId).children().remove();
30     var tableEleStr = '<table class="table table-striped table-bordered table-hover" id= ' + tableId + '>'
31         + '<thead>'
32         + '<tr role="row" class="heading" >'
33         + '</tr>'
34         + '</thead>'
35         + '<tbody>'
36         + '</tbody>'
37         + '</table>';
38     $('#' + divId).append(tableEleStr);
39     var trEle = $('#' + tableId + ' > thead >tr');
40
41     for (var one in column) {
42         var th = '<th>' + column[one].name + '</th>';
43         trEle.append(th);
44     }
45     var table = $("#" + tableId).dataTable({
46         "bFilter": false,// 搜索栏
47         "bPaginate":false,
48         "bInfo":false,
49         "bSort":false,
50         'bAutoWidth':true
51     });
52     $.ajax({
53         type: "GET",
54         cache: false,
55         url: FrameConst.REST_GET_VERSIONINFO,
56         dataType: "json",
57         success: function (data) {
58             console.log(data);
59             //主版本号
60             $(".ict_main_version").append('<span>' + data.mainversion + '</span>');
61             //表格数据填充
62             for( var i = 0 ; i < data.ppuinfo.length ; i++ ) {
63                 var eachPPU = data.ppuinfo[i];
64                 $('#'+ tableId).dataTable().fnAddData([eachPPU.name ,eachPPU.version ,eachPPU.describe , eachPPU.time ]);
65             }
66         },
67         error: function (xhr, ajaxOptions, thrownError) {
68            
69         }
70     });
71 };
72
73 function internationalization(){
74     var lang = getLanguage();
75     //加载国际化
76     jQuery.i18n.properties({
77         language:lang,
78         name:'web-framework-mainPage-i18n',
79         path:'i18n/', // 资源文件路径
80         mode:'map', // 用 Map 的方式使用资源文件中的值
81         callback: function() {// 加载成功后设置显示内容
82             var i18nItems = $('[name_i18n=com_zte_ums_ict_framework_ui_i18n]' , '.aboutDlg');
83             for(var i=0;i<i18nItems.length;i++){
84                 var $item = $(i18nItems.eq(i));
85                 var itemId = $item.attr('id');
86                 if(typeof($item.attr("title"))!="undefined"){
87                     $item.attr("title", $.i18n.prop(itemId));
88                 }else{
89                     $item.text($.i18n.prop(itemId));
90                 }
91             }
92         }
93     });
94
95 }
96
97 function getAboutDlg(url){
98     if (url.length<2){
99         return;
100     }
101     openoFrameWork.startPageLoading();//加载中....
102     var aboutDiv =jQuery('.modal-dialog .aboutDlg');
103     aboutDiv.empty();
104     $.ajax({
105         type: "GET",
106         cache: false,
107         url: url,
108         dataType: "html",
109         success: function (res) {
110             jQuery('.modal-dialog .aboutDlg').append(res);
111             iniAboutInfo();
112             internationalization();
113             openoFrameWork.stopPageLoading();
114         },
115         error: function (xhr, ajaxOptions, thrownError) {
116             
117         }
118     });
119 };
120
121 function iniAboutDlg(){
122     var url=jQuery('.modal-dialog .aboutDlg').attr("dlgsrc");
123     if(url&&url.length>0){
124         getAboutDlg(url);
125     }
126 };
127
128 var ict_about_dlg_close = function(){
129     link_click('about');
130     console.log("about click close");
131     $('#aboutDlg').modal('hide');
132 };
133 var link_click = function( pageName ){
134     console.log("about click change");
135     if(pageName === 'info'){
136         $('.aboutmain').attr("style" , "display:none");
137         $('.aboutinfo').attr("style" , "display:block");
138     }else{
139         $('.aboutmain').attr("style" , "display:block");
140         $('.aboutinfo').attr("style" , "display:none");
141     }
142 };