T_Util.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509
  1. function setCookie( name, value, expiredays )
  2. {
  3. var todayDate = new Date();
  4. todayDate.setDate( todayDate.getDate() + expiredays );
  5. document.cookie = name + '=' + escape( value ) + '; domain=' + location.hostname + ';path=/; expires=' + todayDate.toGMTString() + ';';
  6. }
  7. function getCookie( name )
  8. {
  9. var nameOfCookie = name + '=';
  10. var x = 0;
  11. while ( x <= document.cookie.length )
  12. {
  13. var y = (x+nameOfCookie.length);
  14. if ( document.cookie.substring( x, y ) == nameOfCookie )
  15. {
  16. if ( (endOfCookie=document.cookie.indexOf( ';', y )) == -1 )
  17. endOfCookie = document.cookie.length;
  18. return unescape( document.cookie.substring( y, endOfCookie ) );
  19. }
  20. x = document.cookie.indexOf( ' ', x ) + 1;
  21. if ( x == 0 )
  22. break;
  23. }
  24. return '';
  25. }
  26. function fnCut(str,lengths)
  27. {
  28. var len = 0;
  29. var newStr = '';
  30. for (var i=0;i<str.length; i++){
  31. var n = str.charCodeAt(i);
  32. var nv = str.charAt(i);
  33. if(n < 128){
  34. len++;
  35. }
  36. else if(n < 2048){
  37. len +=2;
  38. }
  39. else if(n < 65536){
  40. len +=3;
  41. }
  42. else{
  43. len +=4;
  44. }
  45. if (len>lengths) break;
  46. else newStr = newStr + nv;
  47. }
  48. return newStr;
  49. }
  50. function getBytes(sString) {
  51. var c = 0;
  52. for(var i= 0; i <sString.length;i++){
  53. c +=parseInt(getByte(sString.charAt(i)));
  54. }
  55. return c;
  56. }
  57. function getByte(sChar) {
  58. var c = 0;
  59. var s = parseInt(sChar.charCodeAt(0));
  60. if(s < 128){
  61. c++;
  62. }
  63. else if(s < 2048){
  64. c +=2;
  65. }
  66. else if(s < 65536){
  67. c +=3;
  68. }
  69. else{
  70. c +=4;
  71. }
  72. return c;
  73. }
  74. function checkInputBox(type, e)
  75. {
  76. var unicode = e.charCode ? e.charCode : e.keyCode;
  77. //document.getElementById("console").innerHTML += unicode + ", ";
  78. if(unicode == 9)
  79. return true;
  80. if(unicode != 8 && unicode != 39 && unicode != 46)
  81. {
  82. if(type == "num")
  83. {
  84. if(unicode >= 48 && unicode <= 57)
  85. {
  86. return true;
  87. }
  88. if(unicode >= 96 && unicode <= 105)
  89. {
  90. return true;
  91. }
  92. else
  93. {
  94. return false;
  95. }
  96. }
  97. else if(type == "ip")
  98. {
  99. if(unicode < 48 ||
  100. (unicode > 57 && unicode < 96) ||
  101. (unicode > 105 && unicode < 110) ||
  102. (unicode > 110 && unicode < 190) ||
  103. unicode > 190)
  104. {
  105. return false;
  106. }
  107. else
  108. {
  109. return true;
  110. }
  111. }
  112. else if(type == "alnum")
  113. {
  114. if(unicode < 48 ||
  115. (unicode > 57 && unicode < 65) ||
  116. (unicode > 90 && unicode < 96) ||
  117. (unicode > 107 && unicode < 109) ||
  118. (unicode > 111 && unicode < 186) ||
  119. (unicode > 192 && unicode < 219) ||
  120. unicode > 222)
  121. {
  122. return false;
  123. }
  124. else
  125. {
  126. return true;
  127. }
  128. }
  129. else if(type == "webchar")
  130. {
  131. //if(unicode != 16){
  132. // alert("aa"+unicode+"bb");
  133. //}
  134. if(unicode == 222 || unicode == 220)
  135. {
  136. return true;
  137. }
  138. else
  139. {
  140. return true;
  141. }
  142. }
  143. else
  144. {
  145. return false;
  146. }
  147. }
  148. else
  149. {
  150. return true;
  151. }
  152. }
  153. function isValidMulticastIP(value)
  154. {
  155. var iplength = (value.split(/\./)).length;
  156. if(iplength == 4)
  157. {
  158. if(value.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1)
  159. { // ip 4
  160. var myArray = value.split(/\./);
  161. if(Number(myArray[1]) > 255 ||
  162. Number(myArray[2]) > 255 ||
  163. Number(myArray[3]) > 255)
  164. {
  165. return false;
  166. }
  167. if(Number(myArray[0]) < 224 || Number(myArray[0]) > 239)
  168. {
  169. return false;
  170. }
  171. return true;
  172. }
  173. else
  174. {
  175. return false;
  176. }
  177. }
  178. else
  179. {
  180. return false;
  181. }
  182. }
  183. function IPMaskCheck(ip, gw, sm)
  184. {
  185. if((ip.split(/\./)).length == 4 && (gw.split(/\./)).length == 4 && (sm.split(/\./)).length == 4){
  186. var IPArray = ip.split(/\./);
  187. var GWArray = gw.split(/\./);
  188. var SMArray = sm.split(/\./);
  189. for(var i= 0; i < 4; i++){
  190. if((Number(IPArray[i]) & Number(SMArray[i])) != (Number(GWArray[i]) & Number(SMArray[i]))){
  191. return false;
  192. }
  193. }
  194. return true;
  195. }
  196. return false;
  197. }
  198. function CheckLocalIPv4Setting(ip, gw, sm)
  199. {
  200. if( ((ip.split(/\./)).length != 4) ||
  201. ((gw.split(/\./)).length != 4) ||
  202. ((sm.split(/\./)).length != 4) ) {
  203. return false;
  204. }
  205. if( (ip.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) == -1) ||
  206. (gw.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) == -1) ||
  207. (sm.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) == -1) ) {
  208. return false;
  209. }
  210. var ipArray = ip.split(/\./);
  211. var gwArray = gw.split(/\./);
  212. var smArray = sm.split(/\./);
  213. // check ip
  214. if(Number(ipArray[0] >= 224)) {
  215. return false;
  216. }
  217. var ip2 = ((Number(ipArray[0]) << 24) + (Number(ipArray[1]) << 16) + (Number(ipArray[2]) << 8) + (Number(ipArray[3]))) >>> 0;
  218. var gw2 = ((Number(gwArray[0]) << 24) + (Number(gwArray[1]) << 16) + (Number(gwArray[2]) << 8) + (Number(gwArray[3]))) >>> 0;
  219. var sm2 = ((Number(smArray[0]) << 24) + (Number(smArray[1]) << 16) + (Number(smArray[2]) << 8) + (Number(smArray[3]))) >>> 0;
  220. // check subnetmask
  221. if(sm2 == 0) {
  222. return false;
  223. } else {
  224. for(var i = 31; i >= 0; i--) {
  225. if(((sm2 >>> i) & 0x1) == 0) {
  226. for(var j = i; j >= 0; j--) {
  227. if(((sm2 >>> j) & 0x1) != 0) {
  228. return false;
  229. }
  230. }
  231. }
  232. }
  233. }
  234. // check gateway
  235. var networkip, broadcastip;
  236. networkip = (ip2 & sm2) >>> 0;
  237. broadcastip = (networkip | (~sm2)) >>> 0;
  238. if((gw2 == ip2) || (gw2 == networkip) || (gw2 == broadcastip)) {
  239. return false;
  240. }
  241. return true;
  242. }
  243. function isValidIP(value)
  244. {
  245. var iplength = (value.split(/\./)).length;
  246. if(iplength == 4)
  247. {
  248. if(value.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1)
  249. { // ip 4
  250. var myArray = value.split(/\./);
  251. if(Number(myArray[0]) > 255 ||
  252. Number(myArray[1]) > 255 ||
  253. Number(myArray[2]) > 255 ||
  254. Number(myArray[3]) > 255)
  255. {
  256. return false;
  257. }
  258. if(Number(myArray[0]) == 0 &&
  259. Number(myArray[1]) == 0 &&
  260. Number(myArray[2]) == 0 &&
  261. Number(myArray[3]) == 0)
  262. {
  263. return true;
  264. }
  265. return true;
  266. }
  267. else
  268. {
  269. return false;
  270. }
  271. }
  272. else if(iplength == 6)
  273. {
  274. if(value.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}.\d{1,3}$/) != -1)
  275. { // ip 6
  276. var myArray2 = value.split(/\./);
  277. //alert(myArray2);
  278. if(Number(myArray2[0]) > 255 ||
  279. Number(myArray2[1]) > 255 ||
  280. Number(myArray2[2]) > 255 ||
  281. Number(myArray2[3]) > 255 ||
  282. Number(myArray2[4]) > 255 ||
  283. Number(myArray2[5]) > 255)
  284. {
  285. return false;
  286. }
  287. if(Number(myArray2[0]) == 0 &&
  288. Number(myArray2[1]) == 0 &&
  289. Number(myArray2[2]) == 0 &&
  290. Number(myArray2[3]) == 0 &&
  291. Number(myArray2[4]) == 0 &&
  292. Number(myArray2[5]) == 0)
  293. {
  294. return false;
  295. }
  296. return true;
  297. }
  298. else
  299. {
  300. return false;
  301. }
  302. }
  303. else
  304. {
  305. return false;
  306. }
  307. }
  308. alpha_numeric = new String("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
  309. function check_alphanumber(str)
  310. {
  311. if(str.length == 0){
  312. return false;
  313. }
  314. for(j = 0 ; j < str.length; j++)
  315. {
  316. rtn = is_alpha_numeric(str.charAt(j));
  317. if(rtn == false)
  318. {
  319. return rtn;
  320. }
  321. }
  322. return true;
  323. }
  324. function is_alpha_numeric(cha1)
  325. {
  326. for(i=0;i<alpha_numeric.length;i++)
  327. {
  328. if(alpha_numeric.charAt(i) == cha1)
  329. return true;
  330. }
  331. return false;
  332. }
  333. function IsAlpha(c)
  334. {
  335. if (c >= '0' && c <= '9')
  336. return 1;
  337. if (c >= 'a' && c <= 'z')
  338. return 1;
  339. if (c >= 'A' && c <= 'Z')
  340. return 1;
  341. else return 0;
  342. }
  343. network_address = new String("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-")
  344. function check_network_address(str)
  345. {
  346. if(str.length == 0){
  347. return false;
  348. }
  349. if(str.length == 1){
  350. return false;
  351. }
  352. if(is_alpha_numeric(str.charAt(0)) == false){
  353. return false;
  354. }
  355. for(j = 1 ; j < str.length; j++)
  356. {
  357. rtn = is_network_address(str.charAt(j));
  358. if(rtn == false)
  359. {
  360. return rtn;
  361. }
  362. }
  363. return true;
  364. }
  365. function is_network_address(cha1)
  366. {
  367. for(i=0;i<network_address.length;i++)
  368. {
  369. if(network_address.charAt(i) == cha1)
  370. return true;
  371. }
  372. return false;
  373. }
  374. password_string = new String("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+|-\\`~[]{},./:;\"\'")
  375. function check_password(str)
  376. {
  377. if(str.length == 0){
  378. return false;
  379. }
  380. if(str.length == 1){
  381. return false;
  382. }
  383. for(j = 0 ; j < str.length; j++)
  384. {
  385. rtn = is_password_string(str.charAt(j));
  386. if(rtn == false)
  387. {
  388. alert("Password string cannot contain \'" + str.charAt(j) + "\'");
  389. return rtn;
  390. }
  391. }
  392. return true;
  393. }
  394. function is_password_string(cha1)
  395. {
  396. for(i=0;i<password_string.length;i++)
  397. {
  398. if(password_string.charAt(i) == cha1)
  399. return true;
  400. }
  401. return false;
  402. }
  403. password_special_char = new String("!@#$%^&*()_+|-\\`~[]{},./:;\"\'")
  404. function check_password_special_char(str)
  405. {
  406. if(str.length == 0){
  407. return false;
  408. }
  409. if(str.length == 1){
  410. return false;
  411. }
  412. for(j = 0 ; j < str.length; j++)
  413. {
  414. rtn = is_password_special_char_string(str.charAt(j));
  415. if(rtn == true)
  416. {
  417. return rtn;
  418. }
  419. }
  420. return false;
  421. }
  422. function is_password_special_char_string(cha1)
  423. {
  424. for(i=0;i<password_special_char.length;i++)
  425. {
  426. if(password_special_char.charAt(i) == cha1)
  427. return true;
  428. }
  429. return false;
  430. }
  431. function check_password_len(str, min_len)
  432. {
  433. if(str.length < min_len) {
  434. return false;
  435. }
  436. return true;
  437. }
  438. function check_password_char_type_num(str, min_num)
  439. {
  440. var num = -1, upper = -1, lower = -1, special = -1;
  441. var type_count = 0;
  442. if((num = str.search(/[0-9]/g)) != -1) {
  443. type_count++;
  444. }
  445. if((upper = str.search(/[A-Z]/g)) != -1) {
  446. type_count++;
  447. }
  448. if((lower = str.search(/[a-z]/g)) != -1) {
  449. type_count++;
  450. }
  451. for(j = 0; j < str.length; j++) {
  452. if(is_password_special_char_string(str.charAt(j))) {
  453. special = j;
  454. type_count++;
  455. break;
  456. }
  457. }
  458. //console.log(num + ", " + upper + ", " + lower + ", " + special + ", " + min_num);
  459. if(type_count < min_num) {
  460. return false;
  461. }
  462. return true;
  463. }
  464. function Tencryption(s) {
  465. var key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  466. var i = 0, len = s.length,
  467. c1, c2, c3,
  468. e1, e2, e3, e4,
  469. result = [];
  470. while (i < len) {
  471. c1 = s.charCodeAt(i++);
  472. c2 = s.charCodeAt(i++);
  473. c3 = s.charCodeAt(i++);
  474. e1 = c1 >> 2;
  475. e2 = ((c1 & 3) << 4) | (c2 >> 4);
  476. e3 = ((c2 & 15) << 2) | (c3 >> 6);
  477. e4 = c3 & 63;
  478. if (isNaN(c2)) {
  479. e3 = e4 = 64;
  480. } else if (isNaN(c3)) {
  481. e4 = 64;
  482. }
  483. result.push(e1, e2, e3, e4);
  484. }
  485. return jQuery.map(result, function (e) { return key.charAt(e); }).join('');
  486. }
  487. function TEncodeUrl(str){
  488. // return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
  489. var pass = str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
  490. var ln = pass.length;
  491. return str.substr(ln-1,1) + str.substr(ln/2,1) + pass;
  492. }
  493. function macro_16(length)
  494. {
  495. return ((length+0xF) & ~(0xF))/16;
  496. }
  497. function getperformance_macroblock(res, fps)
  498. {
  499. var m_width = 0;
  500. var m_height = 0;
  501. var weight = 0;
  502. switch(res) {
  503. case 0: //720x480
  504. m_width = macro_16(720);
  505. m_height = macro_16(480);
  506. break;
  507. case 1: //720x240
  508. m_width = macro_16(720);
  509. m_height = macro_16(240);
  510. break;
  511. case 2: //352x480
  512. m_width = macro_16(352);
  513. m_height = macro_16(480);
  514. break;
  515. case 3: //352x240
  516. m_width = macro_16(352);
  517. m_height = macro_16(240);
  518. break;
  519. case 4: //720x576
  520. m_width = macro_16(720);
  521. m_height = macro_16(576);
  522. break;
  523. case 5: //720x288
  524. m_width = macro_16(720);
  525. m_height = macro_16(288);
  526. break;
  527. case 6: //352x576
  528. m_width = macro_16(352);
  529. m_height = macro_16(576);
  530. break;
  531. case 7: //352x288
  532. m_width = macro_16(352);
  533. m_height = macro_16(288);
  534. break;
  535. case 8: //640x480
  536. m_width = macro_16(640);
  537. m_height = macro_16(480);
  538. break;
  539. case 9: //800x600
  540. m_width = macro_16(800);
  541. m_height = macro_16(600);
  542. break;
  543. case 10: //1024x768
  544. m_width = macro_16(1024);
  545. m_height = macro_16(768);
  546. break;
  547. case 11: //1280x960
  548. m_width = macro_16(1280);
  549. m_height = macro_16(960);
  550. break;
  551. case 12: //1280x1024
  552. m_width = macro_16(1280);
  553. m_height = macro_16(1024);
  554. break;
  555. case 13: //1440x900
  556. m_width = macro_16(1440);
  557. m_height = macro_16(900);
  558. break;
  559. case 14: //1600x900
  560. m_width = macro_16(1600);
  561. m_height = macro_16(900);
  562. break;
  563. case 15: //1680x1050
  564. m_width = macro_16(1680);
  565. m_height = macro_16(1050);
  566. break;
  567. case 16: //1280x720
  568. m_width = macro_16(1280);
  569. m_height = macro_16(720);
  570. break;
  571. case 17: //1920x1080
  572. m_width = macro_16(1920);
  573. m_height = macro_16(1080);
  574. break;
  575. case 18: //176x128
  576. m_width = macro_16(176);
  577. m_height = macro_16(128);
  578. break;
  579. case 19: //176x144
  580. m_width = macro_16(176);
  581. m_height = macro_16(144);
  582. break;
  583. case 22: //320x240
  584. m_width = macro_16(320);
  585. m_height = macro_16(240);
  586. break;
  587. case 23: //2048x1536
  588. m_width = macro_16(2048);
  589. m_height = macro_16(1536);
  590. break;
  591. case 24: //2560x1600
  592. m_width = macro_16(2560);
  593. m_height = macro_16(1600);
  594. break;
  595. case 25: //2592x1936
  596. m_width = macro_16(2592);
  597. m_height = macro_16(1936);
  598. break;
  599. case 26: //1920x1056
  600. m_width = macro_16(1920);
  601. m_height = macro_16(1056);
  602. break;
  603. case 27: //640x360
  604. m_width = macro_16(640);
  605. m_height = macro_16(360);
  606. break;
  607. case 28: //1440x540
  608. m_width = macro_16(1440);
  609. m_height = macro_16(540);
  610. break;
  611. case 29: //1792x1344
  612. m_width = macro_16(1792);
  613. m_height = macro_16(1344);
  614. break;
  615. case 30: //1440x1080
  616. m_width = macro_16(1440);
  617. m_height = macro_16(1080);
  618. break;
  619. case 47: //1600x1200
  620. m_width = macro_16(1600);
  621. m_height = macro_16(1200);
  622. break;
  623. case 48: //1920x1200
  624. m_width = macro_16(1920);
  625. m_height = macro_16(1200);
  626. break;
  627. case 49: //704x480
  628. m_width = macro_16(704);
  629. m_height = macro_16(480);
  630. break;
  631. case 50: //3840x2160
  632. m_width = macro_16(3840);
  633. m_height = macro_16(2160);
  634. break;
  635. case 51: //4096x2160
  636. m_width = macro_16(4096);
  637. m_height = macro_16(2160);
  638. break;
  639. case 52: //4000x3000
  640. m_width = macro_16(4000);
  641. m_height = macro_16(3000);
  642. break;
  643. case 53: //1280x768
  644. m_width = macro_16(1280);
  645. m_height = macro_16(768);
  646. break;
  647. case 54: //1152x864
  648. m_width = macro_16(1152);
  649. m_height = macro_16(864);
  650. break;
  651. case 55: //1360x768
  652. m_width = macro_16(1360);
  653. m_height = macro_16(768);
  654. break;
  655. case 56: //1400x1050
  656. m_width = macro_16(1400);
  657. m_height = macro_16(1050);
  658. break;
  659. case 57: //2048x2048
  660. m_width = macro_16(2048);
  661. m_height = macro_16(2048);
  662. break;
  663. case 58: //2592x1944
  664. m_width = macro_16(2592);
  665. m_height = macro_16(1944);
  666. break;
  667. case 59: //960x540
  668. m_width = macro_16(960);
  669. m_height = macro_16(540);
  670. break;
  671. case 60: //768x432
  672. m_width = macro_16(768);
  673. m_height = macro_16(432);
  674. break;
  675. case 67: //1080x1920
  676. m_width = macro_16(1080);
  677. m_height = macro_16(1920);
  678. break;
  679. case 68: //720x1280
  680. m_width = macro_16(720);
  681. m_height = macro_16(1280);
  682. break;
  683. case 69: //360x640
  684. m_width = macro_16(360);
  685. m_height = macro_16(640);
  686. break;
  687. case 70: //1944X2592
  688. m_width = macro_16(1944);
  689. m_height = macro_16(2592);
  690. break;
  691. case 71: //1600X2560
  692. m_width = macro_16(1600);
  693. m_height = macro_16(2560);
  694. break;
  695. case 72: //1536X2048
  696. m_width = macro_16(1536);
  697. m_height = macro_16(2048);
  698. break;
  699. case 73: //1366X768
  700. m_width = macro_16(1366);
  701. m_height = macro_16(768);
  702. break;
  703. case 74: //2560X1440
  704. m_width = macro_16(2560);
  705. m_height = macro_16(1440);
  706. break;
  707. case 75: //800X448
  708. m_width = macro_16(800);
  709. m_height = macro_16(448);
  710. break;
  711. case 77: //3200x1800
  712. m_width = macro_16(3200);
  713. m_height = macro_16(1800);
  714. break;
  715. case 78: //3072x1728
  716. m_width = macro_16(3072);
  717. m_height = macro_16(1728);
  718. break;
  719. case 81: //2160x3840
  720. m_width = macro_16(2160);
  721. m_height = macro_16(3840);
  722. break;
  723. case 82: //1296x2304
  724. m_width = macro_16(1296);
  725. m_height = macro_16(2304);
  726. break;
  727. case 83: //1808x3200
  728. m_width = macro_16(1808);
  729. m_height = macro_16(3200);
  730. break;
  731. case 84: //1728x3072
  732. m_width = macro_16(1728);
  733. m_height = macro_16(3072);
  734. break;
  735. default:
  736. m_width = macro_16(720);
  737. m_height = macro_16(480);
  738. break;
  739. }
  740. switch(fps){
  741. case 0 :
  742. weight = 30;
  743. break;
  744. case 1 :
  745. weight = 25;
  746. break;
  747. case 2 :
  748. weight = 20;
  749. break;
  750. case 3 :
  751. weight = 15;
  752. break;
  753. case 4 :
  754. weight = 10;
  755. break;
  756. case 5 :
  757. weight = 8;
  758. break;
  759. case 6 :
  760. weight = 6;
  761. break;
  762. case 7 :
  763. weight = 5;
  764. break;
  765. case 8 :
  766. weight = 4;
  767. break;
  768. case 9 :
  769. weight = 3;
  770. break;
  771. case 10 :
  772. weight = 2;
  773. break;
  774. case 11 :
  775. weight = 1;
  776. break;
  777. case 150 :
  778. weight = 50;
  779. break;
  780. case 160 :
  781. weight = 60;
  782. break;
  783. case 175:
  784. weight = 75;
  785. break;
  786. case 185:
  787. weight = 85;
  788. break;
  789. }
  790. return (m_width*m_height*weight);
  791. }
  792. function getperformance_res(res) {
  793. var weight1 = 0;
  794. switch(res){
  795. case 2 :
  796. case 3 :
  797. case 6 :
  798. case 7 :
  799. case 22 :
  800. weight1 = 2;
  801. break;
  802. case 0 :
  803. case 1 :
  804. case 4 :
  805. case 5 :
  806. case 8 :
  807. case 18 :
  808. case 19 :
  809. case 27 :
  810. case 49 :
  811. case 60 :
  812. case 69 :
  813. case 80 :
  814. weight1 = 4;
  815. break;
  816. case 9 :
  817. case 10 :
  818. case 16 :
  819. case 28 :
  820. case 54 :
  821. case 59 :
  822. case 68 :
  823. case 75 :
  824. weight1 = 10;
  825. break;
  826. case 53 :
  827. weight1 = 12;
  828. break;
  829. case 12 :
  830. weight1 = 14;
  831. break;
  832. case 30 :
  833. weight1 = 15;
  834. break;
  835. case 11 :
  836. case 13 :
  837. case 14 :
  838. case 15 :
  839. case 17 :
  840. case 26 :
  841. case 30 :
  842. case 47 :
  843. case 48 :
  844. case 55 :
  845. case 56 :
  846. case 67 :
  847. case 73 :
  848. case 79 :
  849. weight1 = 20;
  850. break;
  851. case 29 :
  852. weight1 = 25;
  853. break;
  854. case 23 :
  855. case 76 :
  856. case 82 : //1296x2304
  857. weight1 = 30;
  858. break;
  859. case 74 : //2560X1440
  860. weight1 = 35;
  861. break;
  862. case 24:
  863. case 57:
  864. weight1 = 40;
  865. break;
  866. case 25:
  867. case 58: // 2592x1944
  868. weight1 = 50;
  869. break;
  870. case 77: //3200x1800
  871. case 83: //1808x3200
  872. weight1 = 57;
  873. break;
  874. case 78: //3072x1728
  875. case 84: //1728x3072
  876. weight1 = 53;
  877. break;
  878. case 50: //3840x2160
  879. case 81: //2160x3840
  880. weight1 = 80;
  881. break;
  882. case 51:
  883. weight1 = 85;
  884. break;
  885. case 52:
  886. weight1 = 120;
  887. break;
  888. default:
  889. weight1 = 20;
  890. break;
  891. }
  892. return weight1;
  893. }
  894. function getperformance_fps(fps) {
  895. var weight2 = 0;
  896. switch(fps){
  897. case 0 :
  898. weight2 = 30;
  899. break;
  900. case 1 :
  901. weight2 = 25;
  902. break;
  903. case 2 :
  904. weight2 = 20;
  905. break;
  906. case 3 :
  907. weight2 = 15;
  908. break;
  909. case 4 :
  910. weight2 = 10;
  911. break;
  912. case 5 :
  913. weight2 = 8;
  914. break;
  915. case 6 :
  916. weight2 = 6;
  917. break;
  918. case 7 :
  919. weight2 = 5;
  920. break;
  921. case 8 :
  922. weight2 = 4;
  923. break;
  924. case 9 :
  925. weight2 = 3;
  926. break;
  927. case 10 :
  928. weight2 = 2;
  929. break;
  930. case 11 :
  931. weight2 = 1;
  932. break;
  933. case 150 :
  934. weight2 = 50;
  935. break;
  936. case 160 :
  937. weight2 = 60;
  938. break;
  939. case 175:
  940. weight2 = 75;
  941. break;
  942. case 185:
  943. weight2 = 85;
  944. break;
  945. }
  946. return weight2;
  947. }
  948. function getperformance(res, fps, _force_4k_calculation)
  949. {
  950. var weight1 = 0;
  951. var weight2 = 0;
  952. switch(res){
  953. case 0 :
  954. case 1 :
  955. case 2 :
  956. case 3 :
  957. case 4 :
  958. case 5 :
  959. case 6 :
  960. case 7 :
  961. case 8 :
  962. case 18 :
  963. case 19 :
  964. case 22 :
  965. case 27 :
  966. case 49 :
  967. case 60 :
  968. case 69 :
  969. case 80 :
  970. weight1 = 4;
  971. break;
  972. case 9 :
  973. case 10 :
  974. case 16 :
  975. case 28 :
  976. case 54 :
  977. case 59 :
  978. case 68 :
  979. case 75 :
  980. weight1 = 10;
  981. break;
  982. case 53 :
  983. weight1 = 12;
  984. break;
  985. case 30 :
  986. weight1 = 15;
  987. break;
  988. case 11 :
  989. case 12 :
  990. case 13 :
  991. case 14 :
  992. case 15 :
  993. case 17 :
  994. case 26 :
  995. case 30 :
  996. case 47 :
  997. case 48 :
  998. case 55 :
  999. case 56 :
  1000. case 67 :
  1001. case 73 :
  1002. case 79 :
  1003. weight1 = 20;
  1004. break;
  1005. case 29 :
  1006. weight1 = 25;
  1007. break;
  1008. case 23 :
  1009. case 76 :
  1010. case 82 : //1296x2304
  1011. weight1 = 30;
  1012. break;
  1013. case 74 : //2560X1440
  1014. if(_force_4k_calculation) {
  1015. weight1 = 80;
  1016. }
  1017. else {
  1018. weight1 = 35;
  1019. }
  1020. break;
  1021. case 24:
  1022. case 57:
  1023. weight1 = 40;
  1024. break;
  1025. case 25:
  1026. case 58: // 2592x1944
  1027. if(_force_4k_calculation) {
  1028. weight1 = 80;
  1029. }
  1030. else {
  1031. weight1 = 50;
  1032. }
  1033. break;
  1034. case 77: //3200x1800
  1035. case 83: //1808x3200
  1036. if(_force_4k_calculation) {
  1037. weight1 = 80;
  1038. }
  1039. else {
  1040. weight1 = 57;
  1041. }
  1042. break;
  1043. case 78: //3072x1728
  1044. case 84: //1728x3072
  1045. if(_force_4k_calculation) {
  1046. weight1 = 80;
  1047. }
  1048. else {
  1049. weight1 = 53;
  1050. }
  1051. break;
  1052. case 50: //3840x2160
  1053. case 81: //2160x3840
  1054. weight1 = 80;
  1055. break;
  1056. case 51:
  1057. weight1 = 85;
  1058. break;
  1059. case 52:
  1060. weight1 = 120;
  1061. break;
  1062. default:
  1063. weight1 = 20;
  1064. break;
  1065. }
  1066. switch(fps){
  1067. case 0 :
  1068. weight2 = 30;
  1069. break;
  1070. case 1 :
  1071. weight2 = 25;
  1072. break;
  1073. case 2 :
  1074. weight2 = 20;
  1075. break;
  1076. case 3 :
  1077. weight2 = 15;
  1078. break;
  1079. case 4 :
  1080. weight2 = 10;
  1081. break;
  1082. case 5 :
  1083. weight2 = 8;
  1084. break;
  1085. case 6 :
  1086. weight2 = 6;
  1087. break;
  1088. case 7 :
  1089. weight2 = 5;
  1090. break;
  1091. case 8 :
  1092. weight2 = 4;
  1093. break;
  1094. case 9 :
  1095. weight2 = 3;
  1096. break;
  1097. case 10 :
  1098. weight2 = 2;
  1099. break;
  1100. case 11 :
  1101. weight2 = 1;
  1102. break;
  1103. case 150 :
  1104. weight2 = 50;
  1105. break;
  1106. case 160 :
  1107. weight2 = 60;
  1108. break;
  1109. case 175:
  1110. weight2 = 75;
  1111. break;
  1112. case 185:
  1113. weight2 = 85;
  1114. break;
  1115. }
  1116. return (weight1*weight2);
  1117. }
  1118. function DBG(str)
  1119. {
  1120. if(window.console == undefined) {
  1121. console = { log : function() {} };
  1122. }
  1123. console.log(str);
  1124. }
  1125. function getwidth(res,real)
  1126. {
  1127. if(real) {
  1128. switch(res) {
  1129. case 0:
  1130. return 720 ; // 720x480
  1131. case 1:
  1132. return 720 ; // 720x240
  1133. case 2:
  1134. return 352; // 352x480
  1135. case 3:
  1136. return 352; // 352x240
  1137. case 4:
  1138. return 720; // 720x576
  1139. case 5:
  1140. return 720; // 720x288
  1141. case 6:
  1142. return 352; // 352x576
  1143. case 7:
  1144. return 352; // 352x288
  1145. case 8:
  1146. return 640; // 640x480
  1147. case 18:
  1148. return 176; // 176x128
  1149. case 19:
  1150. return 176; // 176x144
  1151. case 22:
  1152. return 320; // 320x240
  1153. };
  1154. }
  1155. switch(res){
  1156. case 0 :
  1157. case 1 :
  1158. case 2 :
  1159. case 3 :
  1160. case 18 :
  1161. return 720;
  1162. case 4 :
  1163. case 5 :
  1164. case 6 :
  1165. case 7 :
  1166. case 19 :
  1167. return 720;
  1168. case 8 :
  1169. return 640;
  1170. case 9 :
  1171. return 800;
  1172. case 10 :
  1173. return 1024;
  1174. case 11 :
  1175. return 1280;
  1176. case 12 :
  1177. return 1280;
  1178. case 13 :
  1179. return 1440;
  1180. case 14 :
  1181. return 1600;
  1182. case 15 :
  1183. return 1680;
  1184. case 16 :
  1185. return 1280;
  1186. case 17 :
  1187. return 1920;
  1188. case 23 :
  1189. return 2048;
  1190. case 26 :
  1191. return 1920;
  1192. case 24 :
  1193. return 2560;
  1194. case 25 :
  1195. return 2592;
  1196. case 27 :
  1197. return 640;
  1198. case 28 :
  1199. return 1440;
  1200. case 29 :
  1201. return 1792;
  1202. case 30 :
  1203. return 1440;
  1204. case 47:
  1205. return 1600;
  1206. case 48:
  1207. return 1920;
  1208. case 50:
  1209. return 3840;
  1210. case 51:
  1211. return 4096;
  1212. case 52:
  1213. return 4000;
  1214. case 53:
  1215. return 1280;
  1216. case 54:
  1217. return 1152;
  1218. case 55:
  1219. return 1360;
  1220. case 56:
  1221. return 1400;
  1222. case 57:
  1223. return 2048;
  1224. case 58:
  1225. return 2592;
  1226. case 59:
  1227. return 960;
  1228. case 60:
  1229. return 768;
  1230. case 66:
  1231. return 960;
  1232. case 67:
  1233. return 1080;
  1234. case 68:
  1235. return 720;
  1236. case 69:
  1237. return 360;
  1238. case 70:
  1239. return 1944;
  1240. case 71:
  1241. return 1600;
  1242. case 72:
  1243. return 1536;
  1244. case 73:
  1245. return 1366;
  1246. case 74:
  1247. return 2560;
  1248. case 76:
  1249. return 2304;
  1250. case 77:
  1251. return 3200;
  1252. case 78:
  1253. return 3072;
  1254. case 79:
  1255. return 1088;
  1256. case 80:
  1257. return 368;
  1258. case 81:
  1259. return 2160;
  1260. case 82:
  1261. return 1296;
  1262. case 83:
  1263. return 1808;
  1264. case 84:
  1265. return 1728;
  1266. default :
  1267. return 720;
  1268. }
  1269. }
  1270. function getheight(res,real)
  1271. {
  1272. if(real) {
  1273. switch(res) {
  1274. case 0:
  1275. return 480 ; // 720x480
  1276. case 1:
  1277. return 240 ; // 720x240
  1278. case 2:
  1279. return 480; // 352x480
  1280. case 3:
  1281. return 240; // 352x240
  1282. case 4:
  1283. return 576; // 720x576
  1284. case 5:
  1285. return 288; // 720x288
  1286. case 6:
  1287. return 576; // 352x576
  1288. case 7:
  1289. return 288; // 352x288
  1290. case 8:
  1291. return 480; // 640x480
  1292. case 18:
  1293. return 128; // 176x128
  1294. case 19:
  1295. return 144; // 176x144
  1296. case 22:
  1297. return 240; // 320x240
  1298. };
  1299. }
  1300. switch(res){
  1301. case 0 :
  1302. case 1 :
  1303. case 2 :
  1304. case 3 :
  1305. case 8 :
  1306. case 18 :
  1307. return 480;
  1308. case 4 :
  1309. case 5 :
  1310. case 6 :
  1311. case 7 :
  1312. case 19 :
  1313. return 576;
  1314. case 9 :
  1315. return 600;
  1316. case 10 :
  1317. return 768;
  1318. case 11 :
  1319. return 960;
  1320. case 12 :
  1321. return 1024;
  1322. case 13 :
  1323. return 900;
  1324. case 14 :
  1325. return 900;
  1326. case 15 :
  1327. return 1050;
  1328. case 16 :
  1329. return 720;
  1330. case 17 :
  1331. return 1080;
  1332. case 23 :
  1333. return 1536;
  1334. case 26 :
  1335. return 1056;
  1336. case 24 :
  1337. return 1600;
  1338. case 25 :
  1339. return 1936;
  1340. case 27 :
  1341. return 360;
  1342. case 28 :
  1343. return 540;
  1344. case 29 :
  1345. return 1344;
  1346. case 30:
  1347. return 1080;
  1348. case 47:
  1349. case 48:
  1350. return 1200;
  1351. case 50:
  1352. return 2160;
  1353. case 51:
  1354. return 2160;
  1355. case 52:
  1356. return 3000;
  1357. case 53:
  1358. return 768;
  1359. case 54:
  1360. return 864;
  1361. case 55:
  1362. return 768;
  1363. case 56:
  1364. return 1050;
  1365. case 57:
  1366. return 2048;
  1367. case 58:
  1368. return 1944;
  1369. case 59:
  1370. return 540;
  1371. case 60:
  1372. return 432;
  1373. case 66:
  1374. return 600;
  1375. case 67:
  1376. return 1920;
  1377. case 68:
  1378. return 1280;
  1379. case 69:
  1380. return 640;
  1381. case 70:
  1382. return 2592;
  1383. case 71:
  1384. return 2560;
  1385. case 72:
  1386. return 2048;
  1387. case 73:
  1388. return 768;
  1389. case 74:
  1390. return 1440;
  1391. case 76:
  1392. return 1296;
  1393. case 77:
  1394. return 1800;
  1395. case 78:
  1396. return 1728;
  1397. case 79:
  1398. return 1920;
  1399. case 80:
  1400. return 640;
  1401. case 81:
  1402. return 3840;
  1403. case 82:
  1404. return 2304;
  1405. case 83:
  1406. return 3200;
  1407. case 84:
  1408. return 3072;
  1409. default :
  1410. return 360;
  1411. }
  1412. }