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