Guest User

Untitled

a guest
Sep 30th, 2025
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.44 KB | None | 0 0
  1. var sw_mode = '<% nvram_get_x("", "sw_mode"); %>';
  2. var wan_route_x = '<% nvram_get_x("", "wan_route_x"); %>';
  3. var wan_proto = '<% nvram_get_x("", "wan_proto"); %>';
  4. var lan_proto = '<% nvram_get_x("", "lan_proto_x"); %>';
  5. var log_float = '<% nvram_get_x("", "log_float_ui"); %>';
  6. var log_stamp = 0;
  7. var sysinfo = <% json_system_status(); %>;
  8. var uptimeStr = "<% uptime(); %>";
  9. var timezone = uptimeStr.substring(26,31);
  10. var newformat_systime = uptimeStr.substring(8,11) + " " + uptimeStr.substring(5,7) + " " + uptimeStr.substring(17,25) + " " + uptimeStr.substring(12,16); //Ex format: Jun 23 10:33:31 2008
  11. var systime_millsec = Date.parse(newformat_systime); // millsec from system
  12. var JS_timeObj = new Date(); // 1970.1.1
  13. var cookie_pref = 'n56u_cookie_';
  14.  
  15. var uagent = navigator.userAgent.toLowerCase();
  16. var is_ie11p = (/trident\/7\./).test(uagent);
  17. var is_mobile = (/iphone|ipod|ipad|iemobile|android|blackberry|fennec/).test(uagent);
  18.  
  19. var new_wan_internet = '<% nvram_get_x("", "link_internet"); %>';
  20. var id_check_status = 0;
  21. var id_system_info = 0;
  22.  
  23. var cookie = {
  24. set: function(key, value, days) {
  25. document.cookie = cookie_pref + key + '=' + value + '; expires=' +
  26. (new Date(new Date().getTime() + ((days ? days : 14) * 86400000))).toUTCString() + '; path=/';
  27. },
  28. get: function(key) {
  29. var r = ('; ' + document.cookie + ';').match('; ' + cookie_pref + key + '=(.*?);');
  30. return r ? r[1] : null;
  31. },
  32. unset: function(key) {
  33. document.cookie = cookie_pref + key + '=; expires=' + (new Date(1)).toUTCString() + '; path=/';
  34. }
  35. };
  36.  
  37. <% firmware_caps_hook(); %>
  38.  
  39. function get_ap_mode(){
  40. return (wan_route_x == 'IP_Bridged' || sw_mode == '3') ? true : false;
  41. }
  42.  
  43. function unload_body(){
  44. disableCheckChangedStatus();
  45. no_flash_button();
  46. return true;
  47. }
  48.  
  49. function enableCheckChangedStatus(flag){
  50. var tm_int_sec = 1;
  51.  
  52. disableCheckChangedStatus();
  53.  
  54. if (new_wan_internet == '0')
  55. tm_int_sec = 2;
  56. else if (new_wan_internet == '1')
  57. tm_int_sec = 5;
  58.  
  59. id_check_status = setTimeout("get_changed_status();", tm_int_sec * 1000);
  60. }
  61.  
  62. function disableCheckChangedStatus(){
  63. clearTimeout(id_check_status);
  64. }
  65.  
  66. function update_internet_status(){
  67. if (new_wan_internet == '1')
  68. showMapWANStatus(1);
  69. else if(new_wan_internet == '2')
  70. showMapWANStatus(2);
  71. else
  72. showMapWANStatus(0);
  73. }
  74.  
  75. function notify_status_internet(wan_internet){
  76. this.new_wan_internet = wan_internet;
  77. if((location.pathname == "/" || location.pathname == "/index.asp") && (typeof(update_internet_status) === 'function'))
  78. update_internet_status();
  79. }
  80.  
  81. function notify_status_vpn_client(vpnc_state){
  82. if((location.pathname == "/vpncli.asp") && (typeof(update_vpnc_status) === 'function'))
  83. update_vpnc_status(vpnc_state);
  84. }
  85.  
  86. function get_changed_status(){
  87. var $j = jQuery.noConflict();
  88. $j.ajax({
  89. type: 'get',
  90. url: '/status_internet.asp',
  91. dataType: 'script',
  92. cache: true,
  93. error: function(xhr) {
  94. ;
  95. },
  96. success: function(response) {
  97. notify_status_internet(now_wan_internet);
  98. notify_status_vpn_client(now_vpnc_state);
  99. enableCheckChangedStatus();
  100. }
  101. });
  102. }
  103.  
  104. function get_system_info(){
  105. var $j = jQuery.noConflict();
  106. clearTimeout(id_system_info);
  107. $j.ajax({
  108. type: 'get',
  109. url: '/system_status_data.asp',
  110. dataType: 'script',
  111. cache: true,
  112. error: function(xhr) {
  113. id_system_info = setTimeout('get_system_info()', 2000);
  114. },
  115. success: function(response) {
  116. id_system_info = setTimeout('get_system_info()', 2000);
  117. setSystemInfo(response);
  118. }
  119. });
  120. }
  121.  
  122. function bytesToSize(bytes, precision){
  123. var absval = Math.abs(bytes);
  124. var kilobyte = 1024;
  125. var megabyte = kilobyte * 1024;
  126. var gigabyte = megabyte * 1024;
  127. var terabyte = gigabyte * 1024;
  128.  
  129. if (absval < kilobyte)
  130. return bytes + ' B';
  131. else if (absval < megabyte)
  132. return (bytes / kilobyte).toFixed(precision) + ' KB';
  133. else if (absval < gigabyte)
  134. return (bytes / megabyte).toFixed(precision) + ' MB';
  135. else if (absval < terabyte)
  136. return (bytes / gigabyte).toFixed(precision) + ' GB';
  137. else
  138. return (bytes / terabyte).toFixed(precision) + ' TB';
  139. }
  140.  
  141. function getLALabelStatus(num){
  142. var la = parseFloat(num);
  143. return la > 0.9 ? 'danger' : (la > 0.5 ? 'warning' : 'info');
  144. }
  145.  
  146. function setSystemInfo(response){
  147. if(typeof(si_new) !== 'object')
  148. return;
  149.  
  150. var cpu_now = {};
  151. var cpu_total = (si_new.cpu.total - sysinfo.cpu.total);
  152. if (!cpu_total)
  153. cpu_total = 1;
  154.  
  155. cpu_now.busy = parseInt((si_new.cpu.busy - sysinfo.cpu.busy) * 100 / cpu_total);
  156. cpu_now.user = parseInt((si_new.cpu.user - sysinfo.cpu.user) * 100 / cpu_total);
  157. cpu_now.nice = parseInt((si_new.cpu.nice - sysinfo.cpu.nice) * 100 / cpu_total);
  158. cpu_now.system = parseInt((si_new.cpu.system - sysinfo.cpu.system) * 100 / cpu_total);
  159. cpu_now.idle = parseInt((si_new.cpu.idle - sysinfo.cpu.idle) * 100 / cpu_total);
  160. cpu_now.iowait = parseInt((si_new.cpu.iowait - sysinfo.cpu.iowait) * 100 / cpu_total);
  161. cpu_now.irq = parseInt((si_new.cpu.irq - sysinfo.cpu.irq) * 100 / cpu_total);
  162. cpu_now.sirq = parseInt((si_new.cpu.sirq - sysinfo.cpu.sirq) * 100 / cpu_total);
  163.  
  164. sysinfo = si_new;
  165.  
  166. showSystemInfo(cpu_now,1);
  167. }
  168.  
  169. function showSystemInfo(cpu_now,force){
  170. var $j = jQuery.noConflict();
  171. var arrLA = sysinfo.lavg.split(' ');
  172. var h = sysinfo.uptime.hours < 10 ? ('0'+sysinfo.uptime.hours) : sysinfo.uptime.hours;
  173. var m = sysinfo.uptime.minutes < 10 ? ('0'+sysinfo.uptime.minutes) : sysinfo.uptime.minutes;
  174.  
  175. $j("#la_info").html('<span class="label label-'+getLALabelStatus(arrLA[0])+'">'+arrLA[0]+'</span>&nbsp;<span class="label label-'+getLALabelStatus(arrLA[1])+'">'+arrLA[1]+'</span>&nbsp;<span class="label label-'+getLALabelStatus(arrLA[2])+'">'+arrLA[2]+'</span>');
  176. $j("#cpu_info").html(cpu_now.busy + '%');
  177. $j("#mem_info").html(bytesToSize(sysinfo.ram.free*1024, 2) + " / " + bytesToSize(sysinfo.ram.total*1024, 2));
  178. $j("#uptime_info").html(sysinfo.uptime.days + "<#Day#>".substring(0,1) + " " + h+"<#Hour#>".substring(0,1) + " " + m+"<#Minute#>".substring(0,1));
  179.  
  180. $j("#cpu_usage tr:nth-child(1) td:first").html('busy: '+cpu_now.busy+'%');
  181. $j("#cpu_usage tr:nth-child(2) td:first").html('user: '+cpu_now.user+'%');
  182. $j("#cpu_usage tr:nth-child(2) td:last").html('system: '+cpu_now.system+'%');
  183. $j("#cpu_usage tr:nth-child(3) td:first").html('sirq: '+cpu_now.sirq+'%');
  184. $j("#cpu_usage tr:nth-child(3) td:last").html('irq: '+cpu_now.irq+'%');
  185. $j("#cpu_usage tr:nth-child(4) td:first").html('idle: '+cpu_now.idle+'%');
  186. $j("#cpu_usage tr:nth-child(4) td:last").html('nice: '+cpu_now.nice+'%');
  187.  
  188. $j("#mem_usage tr:nth-child(1) td:first").html('total: '+bytesToSize(sysinfo.ram.total*1024, 2));
  189. $j("#mem_usage tr:nth-child(2) td:first").html('free: '+bytesToSize(sysinfo.ram.free*1024, 2));
  190. $j("#mem_usage tr:nth-child(2) td:last").html('used: '+bytesToSize(sysinfo.ram.used*1024, 2));
  191. $j("#mem_usage tr:nth-child(3) td:first").html('cached: '+bytesToSize(sysinfo.ram.cached*1024, 2));
  192. $j("#mem_usage tr:nth-child(3) td:last").html('buffers: '+bytesToSize(sysinfo.ram.buffers*1024, 2));
  193. $j("#mem_usage tr:nth-child(4) td:first").html('swap: '+bytesToSize(sysinfo.swap.total*1024, 2));
  194. $j("#mem_usage tr:nth-child(4) td:last").html('swap used: '+bytesToSize(sysinfo.swap.used*1024, 2));
  195.  
  196. if(parseInt(sysinfo.wifi2.state) > 0)
  197. $j('#wifi2_b').addClass('btn-info');
  198. else
  199. $j('#wifi2_b').removeClass('btn-info');
  200.  
  201. if(parseInt(sysinfo.wifi5.state) > 0)
  202. $j('#wifi5_b').addClass('btn-info');
  203. else
  204. $j('#wifi5_b').removeClass('btn-info');
  205.  
  206. if(parseInt(sysinfo.wifi2.guest) > 0)
  207. $j('#wifi2_b_g').addClass('btn-info');
  208. else
  209. $j('#wifi2_b_g').removeClass('btn-info');
  210.  
  211. if(parseInt(sysinfo.wifi5.guest) > 0)
  212. $j('#wifi5_b_g').addClass('btn-info');
  213. else
  214. $j('#wifi5_b_g').removeClass('btn-info');
  215.  
  216. setLogStamp(sysinfo.logmt);
  217.  
  218. if(force && typeof(parent.getSystemJsonData) === 'function')
  219. getSystemJsonData(cpu_now, sysinfo.ram);
  220. }
  221.  
  222. var menu_code="", menu1_code="", menu2_code="", tab_code="", footer_code;
  223. var enabled2Gclass = '<% nvram_match_x("","rt_radio_x", "1", "btn-info"); %>';
  224. var enabled5Gclass = '<% nvram_match_x("","wl_radio_x", "1", "btn-info"); %>';
  225. var enabledGuest2Gclass = '<% nvram_match_x("","rt_guest_enable", "1", "btn-info"); %>';
  226. var enabledGuest5Gclass = '<% nvram_match_x("","wl_guest_enable", "1", "btn-info"); %>';
  227. var enabledBtnCommit = '<% nvram_match_x("","nvram_manual", "0", "display:none;"); %>';
  228.  
  229. // L3 = The third Level of Menu
  230. function show_banner(L3){
  231. var bc = '';
  232. var style_2g = 'width:55px;';
  233. var style_5g = 'width:55px;';
  234. if (!support_5g_radio()) {
  235. style_2g = 'width:114px;';
  236. style_5g = 'width:21px;display:none;';
  237. }
  238.  
  239. // log panel
  240. if (!is_mobile && log_float != '0'){
  241. bc += '<div class="syslog_panel">\n';
  242. bc += '<button id="syslog_panel_button" class="handle" href="/"><span class="log_text">Log</span></button>\n';
  243. bc += '<table class="" style="margin-top: 0px; margin-bottom: 5px" width="100%" border="0">\n';
  244. bc += ' <tr>\n';
  245. bc += ' <td width="60%" style="text-align: left"><b><#General_x_SystemTime_itemname#>:</b><span class="alert alert-info" style="margin-left: 10px; padding-top: 4px; padding-bottom: 4px;" id="system_time_log_area"></span></td>\n';
  246. bc += ' <td style="text-align: lift"><input type="hidden" id="scrATop" value=""></td>\n';
  247. bc += ' <td style="text-align: right"><button type="button" id="clearlog_btn" class="btn btn-info" style="min-width: 170px;" onclick="clearlog();"><#CTL_clear#></button></td>\n';
  248. bc += ' </tr>\n';
  249. bc += '</table>\n';
  250. bc += '<span><textarea rows="28" wrap="off" class="span12" readonly="readonly" id="log_area"></textarea></span>\n';
  251. bc += '</div>\n';
  252. }
  253.  
  254. // for chang language
  255. bc +='<form method="post" name="titleForm" id="titleForm" action="/start_apply.htm" target="hidden_frame">\n';
  256. bc +='<input type="hidden" name="current_page" value="">\n';
  257. bc +='<input type="hidden" name="sid_list" value="LANGUAGE;">\n';
  258. bc +='<input type="hidden" name="action_mode" value=" Apply ">\n';
  259. bc +='<input type="hidden" name="preferred_lang" value="">\n';
  260. bc +='<input type="hidden" name="flag" value="">\n';
  261. bc +='</form>\n';
  262.  
  263. // --->
  264. bc += '<div class="container-fluid" style="padding-left: 0px; margin-left: -6px;">\n';
  265. bc += '<div class="row-fluid">\n';
  266.  
  267. // block system info
  268. bc += '<div class="span6">\n';
  269. bc += '<div class="well" style="margin-bottom: 0px; height: 109px; padding: 7px 6px 6px 6px;">\n';
  270. bc += '<div class="row-fluid">\n';
  271.  
  272. bc += '<div id="main_info">\n';
  273. bc += '<table class="table table-condensed" width="100%" style="margin-bottom: 0px;">\n';
  274. bc += ' <tr>\n';
  275. bc += ' <td width="43%" style="border: 0 none;"><#SI_LoadAvg#></td>\n';
  276. bc += ' <td style="border: 0 none; min-width: 115px;"><div id="la_info"> -- -- -- </div></td>\n';
  277. bc += ' </tr>\n';
  278. bc += ' <tr>\n';
  279. bc += ' <td style="height: 20px;"><a class="adv_info" href="javascript:void(0)" onclick="click_info_cpu();"><#SI_LoadCPU#></a></td>\n';
  280. bc += ' <td><span id="cpu_info"> -- % </span></td>\n';
  281. bc += ' </tr>\n';
  282. bc += ' <tr>\n';
  283. bc += ' <td><a class="adv_info" href="javascript:void(0)" onclick="click_info_mem();"><#SI_FreeMem#></a></td>\n';
  284. bc += ' <td><span id="mem_info"> -- MB / -- MB </span></td>\n';
  285. bc += ' </tr>\n';
  286. bc += ' <tr>\n';
  287. bc += ' <td><#SI_Uptime#></td>\n';
  288. bc += ' <td><span id="uptime_info">&nbsp;</span></td>\n';
  289. bc += ' </tr>\n';
  290. bc += '</table>\n';
  291. bc += '</div>\n';
  292.  
  293. bc += '<div id="cpu_usage" style="display: none;">\n';
  294. bc += '<table class="table table-condensed" width="100%" style="margin-bottom: 0px;">\n';
  295. bc += ' <tr>\n';
  296. bc += ' <td width="43%" style="text-align:left; border: 0 none;"></td>\n';
  297. bc += ' <td style="border: 0 none; text-align:right;"><a class="label" href="javascript:void(0)" onclick="hide_adv_info();">hide</a></td>\n';
  298. bc += ' </tr>\n';
  299. bc += ' <tr>\n';
  300. bc += ' <td style="height: 20px;"></td>\n';
  301. bc += ' <td></td>\n';
  302. bc += ' </tr>\n';
  303. bc += ' <tr>\n';
  304. bc += ' <td></td>\n';
  305. bc += ' <td></td>\n';
  306. bc += ' </tr>\n';
  307. bc += ' <tr>\n';
  308. bc += ' <td></td>\n';
  309. bc += ' <td></td>\n';
  310. bc += ' </tr>\n';
  311. bc += '</table>\n';
  312. bc += '</div>\n';
  313.  
  314. bc += '<div id="mem_usage" style="display: none;">\n';
  315. bc += '<table class="table table-condensed" width="100%" style="margin-bottom: 0px;">\n';
  316. bc += ' <tr>\n';
  317. bc += ' <td width="43%" style="text-align:left; border: 0 none;"></td>\n';
  318. bc += ' <td style="border: 0 none; text-align:right;"><a class="label" href="javascript:void(0)" onclick="hide_adv_info();">hide</a></td>\n';
  319. bc += ' </tr>\n';
  320. bc += ' <tr>\n';
  321. bc += ' <td style="height: 20px;"></td>\n';
  322. bc += ' <td></td>\n';
  323. bc += ' </tr>\n';
  324. bc += ' <tr>\n';
  325. bc += ' <td></td>\n';
  326. bc += ' <td></td>\n';
  327. bc += ' </tr>\n';
  328. bc += ' <tr>\n';
  329. bc += ' <td></td>\n';
  330. bc += ' <td></td>\n';
  331. bc += ' </tr>\n';
  332. bc += '</table>\n';
  333. bc += '</div>\n';
  334.  
  335. bc += '</div>\n';
  336. bc += '</div>\n';
  337. bc += '</div>\n';
  338.  
  339. // block firmware version
  340. bc += '<div class="span6">\n';
  341. bc += '<div class="well" style="margin-bottom: 0px; height: 109px; padding: 5px 6px 8px 6px;">\n';
  342. bc += '<div class="row-fluid">\n';
  343. bc += '<table class="table table-condensed" style="margin-bottom: 0px">\n';
  344. bc += ' <tr>\n';
  345. bc += ' <td width="50%" style="border: 0 none;"><#menu5_1#>:</td>\n';
  346. bc += ' <td style="border: 0 none; min-width: 115px;"><div class="form-inline"><input type="button" id="wifi2_b" class="btn btn-mini '+enabled2Gclass+'" style="'+style_2g+'" value="2.4GHz" onclick="go_setting(2);">&nbsp;<input type="button" id="wifi5_b" style="'+style_5g+'" class="btn btn-mini '+enabled5Gclass+'" value="5GHz" onclick="go_setting(5);"></div></td>\n';
  347. bc += ' </tr>\n';
  348. bc += ' <tr>\n';
  349. bc += ' <td><#menu5_1_2#>:</td>\n';
  350. bc += ' <td><div class="form-inline"><input type="button" id="wifi2_b_g" class="btn btn-mini '+enabledGuest2Gclass+'" style="'+style_2g+'" value="2.4GHz" onclick="go_wguest(2);">&nbsp;<input type="button" id="wifi5_b_g" style="'+style_5g+'" class="btn btn-mini '+enabledGuest5Gclass+'" value="5GHz" onclick="go_wguest(5);"></div></td>\n';
  351. bc += ' </tr>\n';
  352. bc += ' <tr>\n';
  353. bc += ' <td><#General_x_FirmwareVersion_itemname#></td>\n';
  354. bc += ' <td><a href="/Advanced_FirmwareUpgrade_Content.asp"><span id="firmver" class="time"></span></a></td>\n';
  355. bc += ' </tr>\n';
  356. bc += ' <tr>\n';
  357. bc += ' <td><button type="button" id="commit_btn" class="btn btn-mini" style="width: 114px; height: 21px; outline:0; '+enabledBtnCommit+'" onclick="commit();"><i class="icon icon-fire"></i>&nbsp;<#CTL_Commit#></button></td>\n';
  358. bc += ' <td><button type="button" id="logout_btn" class="btn btn-mini" style="width: 114px; height: 21px; outline:0;" onclick="logout();"><#t1Logout#></button> <button type="button" id="reboto_btn" class="btn btn-mini" style="height: 21px; outline:0;" title="<#BTN_REBOOT#>" onclick="reboot();"><i class="icon icon-off"></i></button></td>\n';
  359. bc += ' </tr>\n';
  360. bc += '</table>\n';
  361. bc += '</div>\n';
  362. bc += '</div>\n';
  363. bc += '</div>\n';
  364.  
  365. bc += '</div>\n';
  366. bc += '</div>\n';
  367.  
  368. bc +='</td></tr></table>\n';
  369.  
  370. $("TopBanner").innerHTML = bc;
  371.  
  372. show_loading_obj();
  373. show_top_status();
  374. }
  375.  
  376. var tabtitle = new Array(10);
  377. tabtitle[0] = new Array("", "<#menu5_1_1#>", "<#menu5_1_2#>", "<#menu5_1_3#>", "<#menu5_1_4#>", "<#menu5_1_5#>", "<#menu5_1_6#>");
  378. tabtitle[1] = new Array("", "<#menu5_1_1#>", "<#menu5_1_2#>", "<#menu5_1_3#>", "<#menu5_1_4#>", "<#menu5_1_5#>", "<#menu5_1_6#>");
  379. tabtitle[2] = new Array("", "<#menu5_2_1#>", "<#menu5_2_2#>", "<#menu5_2_3#>", "<#menu5_2_4#>", "<#menu5_2_5#>", "Wake-on-LAN");
  380. tabtitle[3] = new Array("", "<#menu5_3_1#>", "<#menu5_3_3#>", "<#menu5_3_4#>", "<#menu5_3_5#>", "<#menu5_3_6#>");
  381. tabtitle[4] = new Array("", "<#menu5_5_1#>", "<#menu5_5_5#>", "<#menu5_5_2#>", "<#menu5_5_3#>", "<#menu5_5_4#>");
  382. tabtitle[5] = new Array("", "<#menu5_4_3#>", "<#menu5_4_1#>", "<#menu5_4_2#>", "<#menu5_4_4#>", "<#menu5_4_5#>");
  383. tabtitle[6] = new Array("", "<#menu5_6_2#>", "<#menu5_6_5#>", "<#menu5_6_1#>", "<#menu5_6_3#>", "<#menu5_6_4#>", "<#menu5_6_6#>");
  384. tabtitle[7] = new Array("", "<#menu5_10_1#>", "<#menu5_10_2#>", "<#menu5_10_3#>");
  385. tabtitle[8] = new Array("", "<#menu5_11#>", "<#menu5_12#>", "WAN", "", "", "", "", "", "", "");
  386. tabtitle[9] = new Array("", "<#menu5_7_2#>", "<#menu5_7_3#>", "<#menu5_7_5#>", "<#menu5_7_6#>", "<#menu5_7_8#>");
  387.  
  388. //Level 3 Tab title
  389. var tablink = new Array(10);
  390. tablink[0] = new Array("", "Advanced_Wireless2g_Content.asp", "Advanced_WGuest2g_Content.asp", "Advanced_WMode2g_Content.asp", "Advanced_ACL2g_Content.asp", "Advanced_WSecurity2g_Content.asp", "Advanced_WAdvanced2g_Content.asp");
  391. tablink[1] = new Array("", "Advanced_Wireless_Content.asp", "Advanced_WGuest_Content.asp", "Advanced_WMode_Content.asp", "Advanced_ACL_Content.asp", "Advanced_WSecurity_Content.asp", "Advanced_WAdvanced_Content.asp");
  392. tablink[2] = new Array("", "Advanced_LAN_Content.asp", "Advanced_DHCP_Content.asp", "Advanced_GWStaticRoute_Content.asp", "Advanced_IPTV_Content.asp", "Advanced_Switch_Content.asp", "Advanced_WOL_Content.asp");
  393. tablink[3] = new Array("", "Advanced_WAN_Content.asp", "Advanced_IPv6_Content.asp", "Advanced_VirtualServer_Content.asp", "Advanced_Exposed_Content.asp", "Advanced_DDNS_Content.asp");
  394. tablink[4] = new Array("", "Advanced_BasicFirewall_Content.asp", "Advanced_Netfilter_Content.asp", "Advanced_URLFilter_Content.asp", "Advanced_MACFilter_Content.asp", "Advanced_Firewall_Content.asp");
  395. tablink[5] = new Array("", "Advanced_AiDisk_others.asp", "Advanced_AiDisk_samba.asp", "Advanced_AiDisk_ftp.asp", "Advanced_Modem_others.asp", "Advanced_Printer_others.asp");
  396. tablink[6] = new Array("", "Advanced_System_Content.asp", "Advanced_Services_Content.asp", "Advanced_OperationMode_Content.asp", "Advanced_FirmwareUpgrade_Content.asp", "Advanced_SettingBackup_Content.asp", "Advanced_Console_Content.asp");
  397. tablink[7] = new Array("", "Advanced_Tweaks_Content.asp", "Advanced_Scripts_Content.asp", "Advanced_InetDetect_Content.asp");
  398. tablink[8] = new Array("", "Main_WStatus2g_Content.asp", "Main_WStatus_Content.asp", "", "", "", "", "", "", "", "");
  399. tablink[9] = new Array("", "Main_LogStatus_Content.asp", "Main_DHCPStatus_Content.asp", "Main_IPTStatus_Content.asp", "Main_RouteStatus_Content.asp", "Main_CTStatus_Content.asp");
  400.  
  401. //Level 2 Menu
  402. menuL2_title = new Array("", "<#menu5_11#>", "<#menu5_12#>", "<#menu5_2#>", "<#menu5_3#>", "<#menu5_5#>", "<#menu5_4#>", "<#menu5_6#>", "<#menu5_10#>", "<#menu5_9#>", "<#menu5_7#>");
  403. menuL2_link = new Array("", tablink[0][1], tablink[1][1], tablink[2][1], tablink[3][1], tablink[4][1], tablink[5][1], tablink[6][1], tablink[7][1], tablink[8][1], tablink[9][1]);
  404.  
  405. //Level 1 Menu in Gateway, Router mode
  406. menuL1_title = new Array("", "<#menu1#>", "<#menu3#>", "<#menu2#>", "<#menu6#>", "<#menu4#>", "<#menu5_8#>", "<#menu5#>");
  407. menuL1_link = new Array("", "index.asp", "aidisk.asp", "vpnsrv.asp", "vpncli.asp", "Main_TrafficMonitor_realtime.asp", "Advanced_System_Info.asp", "as.asp");
  408. menuL1_icon = new Array("", "icon-home", "icon-hdd", "icon-retweet", "icon-globe", "icon-tasks", "icon-random", "icon-wrench");
  409.  
  410. function show_menu(L1, L2, L3){
  411. var i;
  412. var num_ephy = support_num_ephy();
  413. if (num_ephy < 2)
  414. num_ephy = 2;
  415. if (num_ephy > 8)
  416. num_ephy = 8;
  417. if(sw_mode == '3'){
  418. tabtitle[2].splice(3,1);//LAN
  419. tablink[2].splice(3,1);
  420. tabtitle[3].splice(1,5);//WAN
  421. tablink[3].splice(1,5);
  422. tabtitle[4].splice(1,5);//firewall
  423. tablink[4].splice(1,5);
  424. tabtitle[5].splice(4,1);//USB
  425. tablink[5].splice(4,1);
  426. tabtitle[9].splice(2,4);//log
  427. tablink[9].splice(2,4);
  428. tablink[2][1] = "Advanced_APLAN_Content.asp";
  429. menuL2_link[3] = tablink[2][1];
  430. menuL2_link[4] = ""; //remove WAN
  431. menuL2_title[4] = "";
  432. menuL2_link[5] = ""; //remove Firewall
  433. menuL2_title[5] = "";
  434. menuL1_link[2] = ""; //remove AiDisk;
  435. menuL1_title[2] = "";
  436. menuL1_link[3] = ""; //remove VPN svr
  437. menuL1_title[3] = "";
  438. menuL1_link[4] = ""; //remove VPN cli
  439. menuL1_title[4] = "";
  440.  
  441. if (lan_proto == '1'){
  442. tabtitle[2].splice(2,1);
  443. tablink[2].splice(2,1);
  444. }
  445. }else{
  446. if(sw_mode == '4'){
  447. tablink[3].splice(3,2);
  448. tabtitle[3].splice(3,2);
  449. }
  450. if(!support_ipv6()){
  451. tablink[3].splice(2,1);
  452. tabtitle[3].splice(2,1);
  453. }
  454. }
  455.  
  456. for (i=0;i<num_ephy;i++){
  457. tablink[8][i+3] = "Main_EStatus_Content.asp#"+i.toString();
  458. if (i>0)
  459. tabtitle[8][i+3] = "LAN"+i.toString();
  460. }
  461.  
  462. if(num_ephy<8){
  463. tabtitle[8].splice(3+num_ephy,8-num_ephy);
  464. tablink[8].splice(3+num_ephy,8-num_ephy);
  465. }
  466.  
  467. if(!support_5g_radio()){
  468. menuL2_link[2] = ""; //remove 5GHz
  469. menuL2_title[2] = "";
  470. tabtitle[1].splice(1,6);
  471. tablink[1].splice(1,6);
  472. tabtitle[8].splice(2,1);
  473. tablink[8].splice(2,1);
  474. }
  475.  
  476. if(!support_storage()){
  477. tabtitle[5].splice(1,5);
  478. tablink[5].splice(1,5);
  479. menuL1_link[2] = ""; //remove AiDisk
  480. menuL1_title[2] = "";
  481. menuL2_link[6] = ""; //remove USB
  482. menuL2_title[6] = "";
  483. }else{
  484. if(!support_usb()){
  485. tabtitle[5].splice(4,2);
  486. tablink[5].splice(4,2);
  487. }
  488. if(!found_app_smbd() && !found_app_ftpd()){
  489. tabtitle[5].splice(2,2);
  490. tablink[5].splice(2,2);
  491. menuL1_link[2] = "";
  492. menuL1_title[2] = "";
  493. }
  494. else if(!found_app_smbd()){
  495. tabtitle[5].splice(2,1);
  496. tablink[5].splice(2,1);
  497. }
  498. else if(!found_app_ftpd()){
  499. tabtitle[5].splice(3,1);
  500. tablink[5].splice(3,1);
  501. menuL1_link[2] = "";
  502. menuL1_title[2] = "";
  503. }
  504. }
  505.  
  506. for(i = 1; i <= menuL1_title.length-1; i++){
  507. if(menuL1_title[i] == "")
  508. continue;
  509. else if(L1 == i && L2 <= 0)
  510. menu1_code += '<li class="active" id="option'+i+'"><a href="javascript:;"><i class="'+menuL1_icon[i]+'"></i>&nbsp;&nbsp;'+menuL1_title[i]+'</a></li>\n';
  511. else
  512. menu1_code += '<li id="option'+i+'"><a href="'+menuL1_link[i]+'" title="'+menuL1_link[i]+'"><i class="'+menuL1_icon[i]+'"></i>&nbsp;&nbsp;'+menuL1_title[i]+'</a></li>\n';
  513. }
  514.  
  515. $("mainMenu").innerHTML = menu1_code;
  516.  
  517. for(var i = 1; i <= menuL2_title.length-1; ++i){
  518. if(menuL2_title[i] == "")
  519. continue;
  520. else if(L2 == i)
  521. menu2_code += '<a href="javascript: void(0)" style="color: #005580; font-weight: bold"><i class="icon-minus"></i>&nbsp;&nbsp;'+menuL2_title[i]+'</a>\n';
  522. else
  523. menu2_code += '<a href="'+menuL2_link[i]+'"><i class="icon-minus"></i>&nbsp;&nbsp;'+menuL2_title[i]+'</a>\n';
  524. }
  525. $("subMenu").innerHTML = menu2_code;
  526.  
  527. if(L3){
  528. tab_code = '<ul class="nav nav-tabs" style="margin-bottom: 0px;">\n';
  529. for(var i = 1; i < tabtitle[L2-1].length; ++i){
  530. if(tabtitle[L2-1][i] == "")
  531. continue;
  532. if(L3 == i){
  533. tab_ref = "javascript: void(0)";
  534. if (L2==9 && i>0 && tablink[L2-1][i].indexOf("#")>0)
  535. tab_ref = tablink[L2-1][i];
  536. tab_code += '<li class="active"><a href="' +tab_ref+ '">'+tabtitle[L2-1][i]+'</a></li>\n';
  537. }else
  538. tab_code += '<li><a href="' +tablink[L2-1][i]+ '">'+tabtitle[L2-1][i]+'</a></li>\n';
  539. }
  540. tab_code += '</ul>\n';
  541. $("tabMenu").innerHTML = tab_code;
  542. }
  543. else
  544. $("tabMenu").innerHTML = "";
  545. }
  546.  
  547. function show_footer(){
  548. footer_code = '<div align="center" class="bottom-image"></div>\n';
  549. footer_code +='<div align="center" class="copyright"><#footer_copyright_desc#></div>\n';
  550. footer_code +='<div align="center">\n';
  551. footer_code +=' <span>Highcharts by Torstein Hønsi & <a href="http://www.highcharts.com">Highsoft</a></span></br>\n';
  552. footer_code +=' <span>Big icons designed by <a href="http://www.freepik.com">Freepik</a></br></span>\n';
  553. footer_code +=' <span>Non-Commercial Use Only</span></br>\n';
  554. footer_code +='</div>\n';
  555.  
  556. $("footer").innerHTML = footer_code;
  557.  
  558. flash_button();
  559. }
  560.  
  561. function show_top_status(){
  562. var $j = jQuery.noConflict();
  563.  
  564. $j("#cpu_info").click(function(){
  565. $j("#main_info").hide();
  566. $j("#cpu_usage").show();
  567. });
  568. $j("#mem_info").click(function(){
  569. $j("#main_info").hide();
  570. $j("#mem_usage").show();
  571. });
  572.  
  573. id_system_info = setTimeout('get_system_info()', 2000);
  574. showSystemInfo({busy: 0, user: 0, nice: 0, system: 0, idle: 0, iowait: 0, irq: 0, sirq: 0}, 0);
  575.  
  576. showtext($("firmver"), '<% nvram_get_x("", "firmver_sub"); %>');
  577.  
  578. /*if(sw_mode == "3")
  579. $("sw_mode_span").innerHTML = "AP";
  580. else
  581. $("sw_mode_span").innerHTML = "Router";*/
  582. }
  583.  
  584. function go_setting(band){
  585. if(band == "2")
  586. location.href = "Advanced_Wireless2g_Content.asp";
  587. else
  588. location.href = "Advanced_Wireless_Content.asp";
  589. }
  590.  
  591. function go_wguest(band){
  592. if(band == "2")
  593. location.href = "Advanced_WGuest2g_Content.asp";
  594. else
  595. location.href = "Advanced_WGuest_Content.asp";
  596. }
  597.  
  598. function show_time(){
  599. JS_timeObj.setTime(systime_millsec); // Add millsec to it.
  600. JS_timeObj3 = JS_timeObj.toString();
  601. JS_timeObj3 = checkTime(JS_timeObj.getHours()) + ":" +
  602. checkTime(JS_timeObj.getMinutes()) + ":" +
  603. checkTime(JS_timeObj.getSeconds());
  604. $('systemtime').innerHTML ="<a href='/Advanced_System_Content.asp'>" + JS_timeObj3 + "</a>";
  605. systime_millsec += 1000;
  606. stime_ID = setTimeout("show_time();", 1000);
  607. }
  608.  
  609. function checkTime(i){
  610. if (i<10)
  611. {i="0" + i}
  612. return i;
  613. }
  614.  
  615. function show_loading_obj(){
  616. var code = '';
  617.  
  618. code += '<center><div id="loadingBlock" class="loadingBlock">';
  619. code += '<div class="container-fluid">';
  620. code += '<div class="well" style="background-color: #212121; width: 60%;">';
  621. code += '<div class="progress progress-striped active" style="width: 50%; text-align: left;"><div class="bar" id="proceeding_bar" style="width: 0%;"><span id="proceeding_txt"></span></div></div>';
  622. code += '<span id="proceeding_main_txt"><#Main_alert_proceeding_desc4#></span></span>';
  623. code += '</div>';
  624. code += '</div>';
  625. code += '</div></center>';
  626.  
  627. $("Loading").innerHTML = code;
  628. id_check_status = setTimeout('hideLoading();', 3000);
  629. }
  630.  
  631. function submit_language(){
  632. if($("select_lang").value != $("preferred_lang").value){
  633. showLoading();
  634.  
  635. with(document.titleForm){
  636. action = "/start_apply.htm";
  637.  
  638. if(location.pathname == "/")
  639. current_page.value = "/index.asp";
  640. else
  641. current_page.value = location.pathname;
  642.  
  643. preferred_lang.value = $("select_lang").value;
  644. flag.value = "set_language";
  645.  
  646. submit();
  647. }
  648. }
  649. }
  650.  
  651. function logout(){
  652. if(!confirm('<#JS_logout#>'))
  653. return;
  654. setTimeout('location = "Logout.asp";', 1);
  655. }
  656.  
  657. function reboot(){
  658. if(!confirm('<#Main_content_Login_Item7#>'))
  659. return;
  660. showLoading(board_boot_time());
  661. var $j = jQuery.noConflict();
  662. $j.post('/apply.cgi',
  663. {
  664. 'action_mode': ' Reboot ',
  665. });
  666. }
  667.  
  668. function click_info_cpu(){
  669. location.href="/Advanced_System_Info.asp#CPU";
  670. }
  671.  
  672. function click_info_mem(){
  673. location.href="/Advanced_System_Info.asp#MEM";
  674. }
  675.  
  676. function hide_adv_info(){
  677. var $j = jQuery.noConflict();
  678. $j("#cpu_usage").hide();
  679. $j("#mem_usage").hide();
  680. $j("#main_info").show();
  681. }
  682.  
  683. function reset_btn_commit(btn_id){
  684. var $j = jQuery.noConflict();
  685. var $btn=$j('#'+btn_id);
  686. $btn.removeClass('alert-error').removeClass('alert-success');
  687. }
  688.  
  689. function commit(){
  690. if(!confirm('<#Commit_confirm#>'))
  691. return;
  692. var $j = jQuery.noConflict();
  693. var $btn = $j('#commit_btn');
  694. $j.ajax({
  695. type: "post",
  696. url: "/apply.cgi",
  697. data: {
  698. action_mode: " CommitFlash ",
  699. nvram_action: "commit_nvram"
  700. },
  701. dataType: "json",
  702. error: function(xhr) {
  703. $btn.addClass('alert-error');
  704. setTimeout("reset_btn_commit('#commit_btn')", 1500);
  705. },
  706. success: function(response) {
  707. var sys_result = (response != null && typeof response === 'object' && "sys_result" in response)
  708. ? response.sys_result : -1;
  709. if(sys_result == 0)
  710. $btn.addClass('alert-success');
  711. else
  712. $btn.addClass('alert-error');
  713. setTimeout("reset_btn_commit('commit_btn')", 1500);
  714. }
  715. });
  716. }
  717.  
  718. function clearlog(){
  719. var $j = jQuery.noConflict();
  720. $j.post('/apply.cgi',
  721. {
  722. 'action_mode': ' ClearLog ',
  723. 'current_page': 'Main_LogStatus_Content.asp'
  724. });
  725. setLogData();
  726. }
  727.  
  728. function kb_to_gb(kilobytes){
  729. if(typeof(kilobytes) == "string" && kilobytes.length == 0)
  730. return 0;
  731. return (kilobytes*1024)/(1024*1024*1024);
  732. }
  733.  
  734. function simpleNum(num){
  735. if(typeof(num) == "string" && num.length == 0)
  736. return 0;
  737. return parseInt(kb_to_gb(num)*1000)/1000;
  738. }
  739.  
  740. function simpleNum2(num){
  741. if(typeof(num) == "string" && num.length == 0)
  742. return 0;
  743. return parseInt(num*1000)/1000;
  744. }
  745.  
  746. function simpleNum3(num){
  747. if(typeof(num) == "string" && num.length == 0)
  748. return 0;
  749. return parseInt(num)/1024;
  750. }
  751.  
  752. function $(){
  753. var elements = new Array();
  754.  
  755. for(var i = 0; i < arguments.length; ++i){
  756. var element = arguments[i];
  757. if(typeof element == 'string')
  758. element = document.getElementById(element);
  759.  
  760. if(arguments.length == 1)
  761. return element;
  762.  
  763. elements.push(element);
  764. }
  765.  
  766. return elements;
  767. }
  768.  
  769. function E(e) {
  770. return (typeof(e) === 'string') ? document.getElementById(e) : e;
  771. }
  772.  
  773. function getElementsByName_iefix(tag, name){
  774. var tagObjs = document.getElementsByTagName(tag);
  775. var objsName;
  776. var targetObjs = new Array();
  777. var targetObjs_length;
  778.  
  779. if(!(typeof(name) == "string" && name.length > 0))
  780. return [];
  781.  
  782. for(var i = 0, targetObjs_length = 0; i < tagObjs.length; ++i){
  783. objsName = tagObjs[i].getAttribute("name");
  784.  
  785. if(objsName && objsName.indexOf(name) == 0){
  786. targetObjs[targetObjs_length] = tagObjs[i];
  787. ++targetObjs_length;
  788. }
  789. }
  790.  
  791. return targetObjs;
  792. }
  793.  
  794. function getElementsByClassName_iefix(tag, name){
  795. var tagObjs = document.getElementsByTagName(tag);
  796. var objsName;
  797. var targetObjs = new Array();
  798. var targetObjs_length;
  799.  
  800. if(!(typeof(name) == "string" && name.length > 0))
  801. return [];
  802.  
  803. for(var i = 0, targetObjs_length = 0; i < tagObjs.length; ++i){
  804. if(navigator.appName == 'Netscape')
  805. objsName = tagObjs[i].getAttribute("class");
  806. else
  807. objsName = tagObjs[i].getAttribute("className");
  808.  
  809. if(objsName == name){
  810. targetObjs[targetObjs_length] = tagObjs[i];
  811. ++targetObjs_length;
  812. }
  813. }
  814.  
  815. return targetObjs;
  816. }
  817.  
  818. function showtext(obj, str){
  819. if(obj)
  820. obj.innerHTML = str;//*/
  821. }
  822.  
  823. function showhtmlspace(ori_str){
  824. var str = "", head, tail_num;
  825.  
  826. head = ori_str;
  827. while((tail_num = head.indexOf(" ")) >= 0){
  828. str += head.substring(0, tail_num);
  829. str += "&nbsp;";
  830.  
  831. head = head.substr(tail_num+1, head.length-(tail_num+1));
  832. }
  833. str += head;
  834.  
  835. return str;
  836. }
  837.  
  838. function showhtmland(ori_str){
  839. var str = "", head, tail_num;
  840.  
  841. head = ori_str;
  842. while((tail_num = head.indexOf("&")) >= 0){
  843. str += head.substring(0, tail_num);
  844. str += "&amp;";
  845.  
  846. head = head.substr(tail_num+1, head.length-(tail_num+1));
  847. }
  848. str += head;
  849.  
  850. return str;
  851. }
  852.  
  853. // A dummy function which just returns its argument. This was needed for localization purpose
  854. function translate(str){
  855. return str;
  856. }
  857.  
  858. function trim(str){
  859. return str.replace(/^\s+|\s+$/g, '');
  860. }
  861.  
  862. function validate_string(string_obj, flag){
  863. if(string_obj.value.charAt(0) == '"'){
  864. if(flag != "noalert")
  865. alert('<#JS_validstr1#> ["]');
  866.  
  867. string_obj.value = "";
  868. string_obj.focus();
  869.  
  870. return false;
  871. }
  872. else{
  873. invalid_char = "";
  874.  
  875. for(var i = 0; i < string_obj.value.length; ++i){
  876. if(string_obj.value.charAt(i) < ' ' || string_obj.value.charAt(i) > '~'){
  877. invalid_char = invalid_char+string_obj.value.charAt(i);
  878. }
  879. }
  880.  
  881. if(invalid_char != ""){
  882. if(flag != "noalert")
  883. alert("<#JS_validstr2#> '"+invalid_char+"' !");
  884. string_obj.value = "";
  885. string_obj.focus();
  886.  
  887. return false;
  888. }
  889. }
  890.  
  891. return true;
  892. }
  893.  
  894. function validate_hex(obj){
  895. var obj_value = obj.value
  896. var re = new RegExp("[^a-fA-F0-9]+","gi");
  897. if(re.test(obj_value))
  898. return false;
  899. else
  900. return true;
  901. }
  902.  
  903. function validate_psk(psk_obj){
  904. var psk_length = psk_obj.value.length;
  905. if(psk_length < 8){
  906. alert("<#JS_passzero#>");
  907. psk_obj.value = "00000000";
  908. psk_obj.focus();
  909. psk_obj.select();
  910.  
  911. return false;
  912. }
  913. if(psk_length > 64){
  914. alert("<#JS_PSK64Hex#>");
  915. psk_obj.value = psk_obj.value.substring(0, 64);
  916. psk_obj.focus();
  917. psk_obj.select();
  918.  
  919. return false;
  920. }
  921. if(psk_length >= 8 && psk_length <= 63 && !validate_string(psk_obj)){
  922. alert("<#JS_PSK64Hex#>");
  923. psk_obj.value = "00000000";
  924. psk_obj.focus();
  925. psk_obj.select();
  926.  
  927. return false;
  928. }
  929. if(psk_length == 64 && !validate_hex(psk_obj)){
  930. alert("<#JS_PSK64Hex#>");
  931. psk_obj.value = "00000000";
  932. psk_obj.focus();
  933. psk_obj.select();
  934.  
  935. return false;
  936. }
  937. return true;
  938. }
  939.  
  940. function checkDuplicateName(newname, targetArray){
  941. var existing_string = targetArray.join(',');
  942. existing_string = ","+existing_string+",";
  943. var newstr = ","+trim(newname)+",";
  944.  
  945. var re = new RegExp(newstr, "gi");
  946. var matchArray = existing_string.match(re);
  947.  
  948. if(matchArray != null)
  949. return true;
  950. else
  951. return false;
  952. }
  953.  
  954. function alert_error_msg(error_msg){
  955. alert(error_msg);
  956. refreshpage();
  957. }
  958.  
  959. function refreshpage(seconds){
  960. if(typeof(seconds) == "number")
  961. setTimeout("refreshpage()", seconds*1000);
  962. else
  963. location.href = location.href;
  964. }
  965.  
  966. function hideLinkTag(){
  967. if(document.all){
  968. var tagObjs = document.all.tags("a");
  969.  
  970. for(var i = 0; i < tagObjs.length; ++i)
  971. tagObjs(i).outerHTML = tagObjs(i).outerHTML.replace(">"," hidefocus=true>");
  972. }
  973. }
  974.  
  975. function buttonOver(o){ //Lockchou 1206 modified
  976. o.style.color = "#FFFFFF";
  977. o.style.background = "url(/images/bgaibutton.gif) #ACCCE1";
  978. o.style.cursor = "hand";
  979. }
  980.  
  981. function buttonOut(o){ //Lockchou 1206 modified
  982. o.style.color = "#000000";
  983. o.style.background = "url(/images/bgaibutton0.gif) #ACCCE1";
  984. }
  985.  
  986. function flash_button(){
  987. if(navigator.appName.indexOf("Microsoft") < 0)
  988. return;
  989.  
  990. var btnObj = getElementsByClassName_iefix("input", "button");
  991.  
  992. for(var i = 0; i < btnObj.length; ++i){
  993. btnObj[i].onmouseover = function(){
  994. buttonOver(this);
  995. };
  996.  
  997. btnObj[i].onmouseout = function(){
  998. buttonOut(this);
  999. };
  1000. }
  1001. }
  1002.  
  1003. function no_flash_button(){
  1004. if(navigator.appName.indexOf("Microsoft") < 0)
  1005. return;
  1006.  
  1007. var btnObj = getElementsByClassName_iefix("input", "button");
  1008.  
  1009. for(var i = 0; i < btnObj.length; ++i){
  1010. btnObj[i].onmouseover = "";
  1011.  
  1012. btnObj[i].onmouseout = "";
  1013. }
  1014. }
  1015.  
  1016. function gotoprev(formObj){
  1017. var prev_page = formObj.prev_page.value;
  1018.  
  1019. if(prev_page == "/")
  1020. prev_page = "/index.asp";
  1021.  
  1022. formObj.action = prev_page;
  1023. formObj.target = "_parent";
  1024. formObj.submit();
  1025. }
  1026.  
  1027. function add_option(selectObj, str, value, selected){
  1028. var tail = selectObj.options.length;
  1029.  
  1030. if(typeof(str) != "undefined")
  1031. selectObj.options[tail] = new Option(str);
  1032. else
  1033. selectObj.options[tail] = new Option();
  1034.  
  1035. if(typeof(value) != "undefined")
  1036. selectObj.options[tail].value = value;
  1037. else
  1038. selectObj.options[tail].value = "";
  1039.  
  1040. if(selected == 1)
  1041. selectObj.options[tail].selected = selected;
  1042. }
  1043.  
  1044. function free_options(selectObj){
  1045. if(selectObj == null)
  1046. return;
  1047.  
  1048. for(var i = selectObj.options.length-1; i >= 0; --i){
  1049. selectObj.options[i].value = null;
  1050. selectObj.options[i] = null;
  1051. }
  1052. }
  1053.  
  1054. function blocking(obj_id, show){
  1055. var state = show?'block':'none';
  1056.  
  1057. if(document.getElementById)
  1058. $(obj_id).style.display = state;
  1059. else if(document.layers)
  1060. document.layers[obj_id].display = state;
  1061. else if(document.all)
  1062. document.all[obj_id].style.display = state;
  1063. }
  1064.  
  1065. function inputCtrl(obj, flag){
  1066. obj.disabled = (flag == 0);
  1067. }
  1068.  
  1069. // add eagle23
  1070. jQuery(document).ready(function(){
  1071. var $j = jQuery.noConflict();
  1072.  
  1073. $j("#logo").click(function(){
  1074. location.href = '/';
  1075. });
  1076.  
  1077. // tabindex navigation
  1078. $j(function(){
  1079. var tabindex = 1;
  1080. $j('input,select').each(function() {
  1081. if (this.type != "hidden" && this.type != 'radio') {
  1082. var $input = $j(this);
  1083. $input.attr("tabindex", tabindex);
  1084. tabindex++;
  1085. }
  1086. });
  1087. });
  1088.  
  1089. var idFindSyslogPanel = setInterval(function(){
  1090. if(is_mobile || log_float == '0'){
  1091. clearInterval(idFindSyslogPanel);
  1092. }else if($j('.syslog_panel').size() > 0){
  1093. clearInterval(idFindSyslogPanel);
  1094.  
  1095. var offsetLeft = $j('.wrapper').offset().left;
  1096. $j('.syslog_panel').css({opacity: 1});
  1097. $j('.syslog_panel').tabSlideOut({
  1098. tabHandle: '.handle',
  1099. imageHeight: '20px',
  1100. imageWidth: '62px',
  1101. tabLocation: 'top',
  1102. speed: 300,
  1103. action: 'click',
  1104. topPos: '400px',
  1105. leftPos: (offsetLeft+5)+'px',
  1106. fixedPosition: true
  1107. });
  1108.  
  1109. setLogData();
  1110. showClockLogArea();
  1111. }
  1112. }, 100);
  1113. });
  1114.  
  1115. // fix for ie
  1116. String.prototype.nl2br = function(){
  1117. return this.replace(/\n/g, "\n\r");
  1118. }
  1119.  
  1120. function setLogStamp(mt){
  1121. if(is_mobile || log_float == '0')
  1122. return;
  1123.  
  1124. var $j = jQuery.noConflict();
  1125.  
  1126. if(isLocalStorageAvailable())
  1127. log_stamp = localStorage.getItem('syslog_stamp');
  1128. if(log_stamp == null)
  1129. log_stamp = 0;
  1130.  
  1131. if (log_stamp != mt){
  1132. setToLocalStorage('syslog_stamp', mt);
  1133. if (log_stamp != 0){
  1134. setLogData();
  1135. if(!$j('.syslog_panel').hasClass('open')){
  1136. var tabText = 'Log <span class="label label-important">!</span>';
  1137. $j(".log_text").html(tabText);
  1138. }
  1139. }
  1140. log_stamp = mt;
  1141. }
  1142. }
  1143.  
  1144. function setLogData(){
  1145. var $j = jQuery.noConflict();
  1146. $j.get('/log_content.asp', function(data){
  1147. // fix for ie
  1148. if($j.browser.msie && !is_ie11p)
  1149. data = data.nl2br();
  1150. if($j("#log_area").val() == ''){
  1151. $j("#log_area").text(data);
  1152. $j("#log_area").prop('scrollTop', $j("#log_area").prop('scrollHeight'));
  1153. $j("#scrATop").val($j("#log_area").prop('scrollTop'));
  1154. }else{
  1155. var scrMaxTop = $j("#log_area").prop('scrollHeight')
  1156. var scrTop = $j("#log_area").prop('scrollTop');
  1157. $j("#log_area").text(data);
  1158. var scrITop = scrMaxTop - scrTop;
  1159. if($j("#scrATop").val() == scrTop || scrITop < 629){
  1160. $j("#log_area").prop('scrollTop', scrMaxTop);
  1161. $j("#scrATop").val($j("#log_area").prop('scrollTop'));
  1162. }else{
  1163. $j("#log_area").prop('scrollTop', scrTop);
  1164. }
  1165. }
  1166. });
  1167. }
  1168.  
  1169. function showClockLogArea(){
  1170. if(jQuery('#system_time').size() == 0){
  1171. JS_timeObj.setTime(systime_millsec);
  1172. systime_millsec += 1000;
  1173.  
  1174. JS_timeObj2 = JS_timeObj.toString();
  1175. JS_timeObj2 = JS_timeObj2.substring(0,3) + ", " +
  1176. JS_timeObj2.substring(4,10) + " " +
  1177. checkTime(JS_timeObj.getHours()) + ":" +
  1178. checkTime(JS_timeObj.getMinutes()) + ":" +
  1179. checkTime(JS_timeObj.getSeconds()) + " " +
  1180. JS_timeObj.getFullYear() + " GMT" + timezone;
  1181. }
  1182. jQuery("#system_time_log_area").html(JS_timeObj2);
  1183. setTimeout("showClockLogArea()", 1000);
  1184. }
  1185.  
  1186. function onCompleteSlideOutLogArea(){
  1187. var idTimeout = setTimeout(function(){
  1188. clearTimeout(idTimeout);
  1189. jQuery(".log_text").html('Log');
  1190. }, 1500);
  1191. }
  1192.  
  1193. function passwordShowHide(id){
  1194. var obj = $j('#'+id);
  1195. var changeTo = (obj.attr('type') == 'password') ? 'text' : 'password';
  1196. if ($j.browser.msie && parseInt($j.browser.version, 10) < 9){
  1197. var marker = $j('<span />').insertBefore('#'+id);
  1198. obj.detach().attr('type', changeTo).insertAfter(marker);
  1199. marker.remove();
  1200. }else{
  1201. document.getElementById(id).type = changeTo;
  1202. }
  1203. }
  1204.  
  1205. /**
  1206. * Local Storage HTML5 Standart
  1207. * http://www.w3.org/TR/webstorage/
  1208. */
  1209. /**
  1210. * ckeck if localStorage available
  1211. * @return void
  1212. */
  1213. function isLocalStorageAvailable(){
  1214. try {
  1215. return 'localStorage' in window && window['localStorage'] !== null;
  1216. } catch (e) {
  1217. return false;
  1218. }
  1219. }
  1220.  
  1221. /**
  1222. * set value to localStorage
  1223. * @param name string
  1224. * @param value mixed
  1225. */
  1226. function setToLocalStorage(name, value){
  1227. if(isLocalStorageAvailable()){
  1228. try {
  1229. localStorage.setItem(name, value);
  1230. } catch (e) {
  1231. if (e == QUOTA_EXCEEDED_ERR) {
  1232. }
  1233. }
  1234. }
  1235. }
  1236.  
  1237. /**
  1238. * get from localStorage
  1239. * @param name
  1240. * @return mixed
  1241. */
  1242. function getFromLocalStorage(name){
  1243. if(isLocalStorageAvailable()){
  1244. return localStorage.getItem(name);
  1245. }
  1246. }
  1247.  
  1248. /**
  1249. * remove from localStorage
  1250. * @param name
  1251. * @return void
  1252. */
  1253. function removeFromLocalStorage(name){
  1254. if(isLocalStorageAvailable()){
  1255. localStorage.removeItem(name);
  1256. }
  1257. }
  1258.  
  1259. (function($){
  1260. var $j = $.noConflict();
  1261. $j.fn.tabSlideOut = function(callerSettings){
  1262. var settings = $j.extend({
  1263. tabHandle: '.handle',
  1264. speed: 300,
  1265. action: 'click',
  1266. tabLocation: 'left',
  1267. topPos: '200px',
  1268. leftPos: '20px',
  1269. fixedPosition: false,
  1270. positioning: 'absolute',
  1271. pathToTabImage: null,
  1272. imageHeight: null,
  1273. imageWidth: null
  1274. }, callerSettings||{});
  1275.  
  1276. settings.tabHandle = $j(settings.tabHandle);
  1277. var obj = this;
  1278. if (settings.fixedPosition === true) {
  1279. settings.positioning = 'fixed';
  1280. } else {
  1281. settings.positioning = 'absolute';
  1282. }
  1283.  
  1284. //ie6 doesn't do well with the fixed option
  1285. if (document.all && !window.opera && !window.XMLHttpRequest) {
  1286. settings.positioning = 'absolute';
  1287. }
  1288.  
  1289. //set initial tabHandle css
  1290. settings.tabHandle.css({
  1291. 'display': 'block',
  1292. 'width' : settings.imageWidth,
  1293. 'height': settings.imageHeight,
  1294. //'textIndent' : '-99999px',
  1295. //'background' : 'url('+settings.pathToTabImage+') no-repeat',
  1296. 'outline' : 'none',
  1297. 'position' : 'absolute',
  1298. 'border-radius': '0px 0px 4px 4px',
  1299. 'background-color': '#f5f5f5',
  1300. 'border-left': '1px solid #ddd',
  1301. 'border-right': '1px solid #ddd',
  1302. 'border-bottom': '1px solid #ddd'
  1303. });
  1304.  
  1305. obj.css({
  1306. 'line-height' : '1',
  1307. 'position' : settings.positioning
  1308. });
  1309.  
  1310. var properties = {
  1311. containerWidth: parseInt(obj.outerWidth(), 10) + 'px',
  1312. containerHeight: parseInt(obj.outerHeight(), 10) + 'px',
  1313. tabWidth: parseInt(settings.tabHandle.outerWidth(), 10) + 'px',
  1314. tabHeight: parseInt(settings.tabHandle.outerHeight(), 10) + 'px'
  1315. };
  1316.  
  1317. //set calculated css
  1318. if(settings.tabLocation === 'top' || settings.tabLocation === 'bottom') {
  1319. obj.css({'left' : settings.leftPos});
  1320. settings.tabHandle.css({'right' : -1});
  1321. }
  1322.  
  1323. if(settings.tabLocation === 'top') {
  1324. obj.css({'top' : '-' + properties.containerHeight});
  1325. settings.tabHandle.css({'bottom' : '-' + properties.tabHeight});
  1326. }
  1327.  
  1328. if(settings.tabLocation === 'bottom') {
  1329. obj.css({'bottom' : '-' + properties.containerHeight, 'position' : 'fixed'});
  1330. settings.tabHandle.css({'top' : '-' + properties.tabHeight});
  1331.  
  1332. }
  1333.  
  1334. if(settings.tabLocation === 'left' || settings.tabLocation === 'right') {
  1335. obj.css({
  1336. 'height' : properties.containerHeight,
  1337. 'top' : settings.topPos
  1338. });
  1339.  
  1340. settings.tabHandle.css({'top' : 0});
  1341. }
  1342.  
  1343. if(settings.tabLocation === 'left') {
  1344. obj.css({ 'left': '-' + properties.containerWidth});
  1345. settings.tabHandle.css({'right' : '-' + properties.tabWidth});
  1346. }
  1347.  
  1348. if(settings.tabLocation === 'right') {
  1349. obj.css({ 'right': '-' + properties.containerWidth});
  1350. settings.tabHandle.css({'left' : '-' + properties.tabWidth});
  1351.  
  1352. $j('html').css('overflow-x', 'hidden');
  1353. }
  1354.  
  1355. //functions for animation events
  1356.  
  1357. settings.tabHandle.click(function(event){
  1358. event.preventDefault();
  1359. });
  1360.  
  1361. var slideIn = function() {
  1362.  
  1363. if (settings.tabLocation === 'top') {
  1364. obj.animate({top:'-' + properties.containerHeight}, settings.speed).removeClass('open');
  1365. } else if (settings.tabLocation === 'left') {
  1366. obj.animate({left: '-' + properties.containerWidth}, settings.speed).removeClass('open');
  1367. } else if (settings.tabLocation === 'right') {
  1368. obj.animate({right: '-' + properties.containerWidth}, settings.speed).removeClass('open');
  1369. } else if (settings.tabLocation === 'bottom') {
  1370. obj.animate({bottom: '-' + properties.containerHeight}, settings.speed).removeClass('open');
  1371. }
  1372.  
  1373. };
  1374.  
  1375. var slideOut = function() {
  1376.  
  1377. if (settings.tabLocation == 'top') {
  1378. obj.animate({top:'-3px'}, settings.speed, onCompleteSlideOutLogArea()).addClass('open');
  1379. } else if (settings.tabLocation == 'left') {
  1380. obj.animate({left:'-3px'}, settings.speed, onCompleteSlideOutLogArea()).addClass('open');
  1381. } else if (settings.tabLocation == 'right') {
  1382. obj.animate({right:'-3px'}, settings.speed, onCompleteSlideOutLogArea()).addClass('open');
  1383. } else if (settings.tabLocation == 'bottom') {
  1384. obj.animate({bottom:'-3px'}, settings.speed, onCompleteSlideOutLogArea()).addClass('open');
  1385. }
  1386. };
  1387.  
  1388. var clickScreenToClose = function() {
  1389. obj.click(function(event){
  1390. event.stopPropagation();
  1391. });
  1392.  
  1393. $j(document).click(function(){
  1394. slideIn();
  1395. });
  1396. };
  1397.  
  1398. var clickAction = function(){
  1399. settings.tabHandle.click(function(event){
  1400. if (obj.hasClass('open')) {
  1401. slideIn();
  1402. } else {
  1403. slideOut();
  1404. }
  1405. });
  1406.  
  1407. clickScreenToClose();
  1408. };
  1409.  
  1410. var hoverAction = function(){
  1411. obj.hover(
  1412. function(){
  1413. slideOut();
  1414. },
  1415.  
  1416. function(){
  1417. slideIn();
  1418. });
  1419.  
  1420. settings.tabHandle.click(function(event){
  1421. if (obj.hasClass('open')) {
  1422. slideIn();
  1423. }
  1424. });
  1425. clickScreenToClose();
  1426.  
  1427. };
  1428.  
  1429. //choose which type of action to bind
  1430. if (settings.action === 'click') {
  1431. clickAction();
  1432. }
  1433.  
  1434. if (settings.action === 'hover') {
  1435. hoverAction();
  1436. }
  1437. };
  1438. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment