1// JavaScript Document 2 3 4/* 5 * -- grayscale.js -- 6 * Copyright (C) James Padolsey (http://james.padolsey.com) 7 * 8 */ 9 10var grayscale = (function(){ 11 12 var config = { 13 colorProps: ['color','backgroundColor','borderBottomColor','borderTopColor','borderLeftColor','borderRightColor','backgroundImage'], 14 externalImageHandler : { 15 /* Grayscaling externally hosted images does not work 16 - Use these functions to handle those images as you so desire */ 17 /* Out of convenience these functions are also used for browsers 18 like Chrome that do not support CanvasContext.getImageData */ 19 init : function(el, src) { 20 if (el.nodeName.toLowerCase() === 'img') { 21 // Is IMG element... 22 } else { 23 // Is background-image element: 24 // Default - remove background images 25 data(el).backgroundImageSRC = src; 26 el.style.backgroundImage = ''; 27 } 28 }, 29 reset : function(el) { 30 if (el.nodeName.toLowerCase() === 'img') { 31 // Is IMG element... 32 } else { 33 // Is background-image element: 34 el.style.backgroundImage = 'url(' + (data(el).backgroundImageSRC || '') + ')'; 35 } 36 } 37 } 38 }, 39 log = function(){ 40 try { window.console.log.apply(console, arguments); } 41 catch(e) {}; 42 }, 43 isExternal = function(url) { 44 // Checks whether URL is external: 'CanvasContext.getImageData' 45 // only works if the image is on the current domain. 46 return (new RegExp('https?://(?!' + window.location.hostname + ')')).test(url); 47 }, 48 data = (function(){ 49 50 var cache = [0], 51 expando = 'data' + (+new Date()); 52 53 return function(elem) { 54 var cacheIndex = elem[expando], 55 nextCacheIndex = cache.length; 56 if(!cacheIndex) { 57 cacheIndex = elem[expando] = nextCacheIndex; 58 cache[cacheIndex] = {}; 59 } 60 return cache[cacheIndex]; 61 }; 62 63 })(), 64 desatIMG = function(img, prepare, realEl) { 65 66 // realEl is only set when img is temp (for BG images) 67 68 var canvas = document.createElement('canvas'), 69 context = canvas.getContext('2d'), 70 height = img.naturalHeight || img.offsetHeight || img.height, 71 width = img.naturalWidth || img.offsetWidth || img.width, 72 imgData; 73 74 canvas.height = height; 75 canvas.width = width; 76 context.drawImage(img, 0, 0); 77 try { 78 imgData = context.getImageData(0, 0, width, height); 79 } catch(e) {} 80 81 if (prepare) { 82 desatIMG.preparing = true; 83 // Slowly recurse through pixels for prep, 84 // :: only occurs on grayscale.prepare() 85 var y = 0; 86 (function(){ 87 88 if (!desatIMG.preparing) { return; } 89 90 if (y === height) { 91 // Finished! 92 context.putImageData(imgData, 0, 0, 0, 0, width, height); 93 realEl ? (data(realEl).BGdataURL = canvas.toDataURL()) 94 : (data(img).dataURL = canvas.toDataURL()) 95 } 96 97 for (var x = 0; x < width; x++) { 98 var i = (y * width + x) * 4; 99 // Apply Monoschrome level across all channels: 100 imgData.data[i] = imgData.data[i+1] = imgData.data[i+2] = 101 RGBtoGRAYSCALE(imgData.data[i], imgData.data[i+1], imgData.data[i+2]); 102 } 103 104 y++; 105 setTimeout(arguments.callee, 0); 106 107 })(); 108 return; 109 } else { 110 // If desatIMG was called without 'prepare' flag 111 // then cancel recursion and proceed with force! (below) 112 desatIMG.preparing = false; 113 } 114 115 for (var y = 0; y < height; y++) { 116 for (var x = 0; x < width; x++) { 117 var i = (y * width + x) * 4; 118 // Apply Monoschrome level across all channels: 119 imgData.data[i] = imgData.data[i+1] = imgData.data[i+2] = 120 RGBtoGRAYSCALE(imgData.data[i], imgData.data[i+1], imgData.data[i+2]); 121 } 122 } 123 124 context.putImageData(imgData, 0, 0, 0, 0, width, height); 125 return canvas; 126 127 }, 128 getStyle = function(el, prop) { 129 var style = document.defaultView && document.defaultView.getComputedStyle ? 130 document.defaultView.getComputedStyle(el, null)[prop] 131 : el.currentStyle[prop]; 132 // If format is #FFFFFF: (convert to RGB) 133 if (style && /^#[A-F0-9]/i.test(style)) { 134 var hex = style.match(/[A-F0-9]{2}/ig); 135 style = 'rgb(' + parseInt(hex[0], 16) + ',' 136 + parseInt(hex[1], 16) + ',' 137 + parseInt(hex[2], 16) + ')'; 138 } 139 return style; 140 }, 141 RGBtoGRAYSCALE = function(r,g,b) { 142 // Returns single monochrome figure: 143 return parseInt( (0.2125 * r) + (0.7154 * g) + (0.0721 * b), 10 ); 144 }, 145 getAllNodes = function(context) { 146 var all = Array.prototype.slice.call(context.getElementsByTagName('*')); 147 all.unshift(context); 148 return all; 149 }; 150 151 var init = function(context) { 152 153 // Handle if a DOM collection is passed instead of a single el: 154 if (context && context[0] && context.length && context[0].nodeName) { 155 // Is a DOM collection: 156 var allContexts = Array.prototype.slice.call(context), 157 cIndex = -1, cLen = allContexts.length; 158 while (++cIndex<cLen) { init.call(this, allContexts[cIndex]); } 159 return; 160 } 161 162 context = context || document.documentElement; 163 164 if (!document.createElement('canvas').getContext) { 165 context.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)'; 166 context.style.zoom = 1; 167 return; 168 } 169 170 var all = getAllNodes(context), 171 i = -1, len = all.length; 172 173 while (++i<len) { 174 var cur = all[i]; 175 176 if (cur.nodeName.toLowerCase() === 'img') { 177 var src = cur.getAttribute('src'); 178 if(!src) { continue; } 179 if (isExternal(src)) { 180 config.externalImageHandler.init(cur, src); 181 } else { 182 data(cur).realSRC = src; 183 try {
184 // Within try statement just encase there's no support.... 185 cur.src = data(cur).dataURL || desatIMG(cur).toDataURL(); 186 } catch(e) { config.externalImageHandler.init(cur, src); } 187 } 188 189 } else { 190 for (var pIndex = 0, pLen = config.colorProps.length; pIndex < pLen; pIndex++) { 191 var prop = config.colorProps[pIndex], 192 style = getStyle(cur, prop); 193 if (!style) {continue;} 194 if (cur.style[prop]) { 195 data(cur)[prop] = style; 196 } 197 // RGB color: 198 if (style.substring(0,4) === 'rgb(') { 199 var monoRGB = RGBtoGRAYSCALE.apply(null, style.match(/\d+/g)); 200 cur.style[prop] = style = 'rgb(' + monoRGB + ',' + monoRGB + ',' + monoRGB + ')'; 201 continue; 202 } 203 // Background Image:
204 if (style.indexOf('url(') > -1) { 205 var urlPatt = /\(['"]?(.+?)['"]?\)/, 206 url = style.match(urlPatt)[1]; 207 if (isExternal(url)) { 208 config.externalImageHandler.init(cur, url); 209 data(cur).externalBG = true; 210 continue; 211 } 212 // data(cur).BGdataURL refers to caches URL (from preparation) 213 try { 214 var imgSRC = data(cur).BGdataURL || (function(){ 215 var temp = document.createElement('img'); 216 temp.src = url; 217 return desatIMG(temp).toDataURL(); 218 })(); 219 220 cur.style[prop] = style.replace(urlPatt, function(_, url){ 221 return '(' + imgSRC + ')'; 222 }); 223 } catch(e) { config.externalImageHandler.init(cur, url); } 224 } 225 } 226 } 227 } 228 229 }; 230 231 init.reset = function(context) { 232 // Handle if a DOM collection is passed instead of a single el: 233 if (context && context[0] && context.length && context[0].nodeName) { 234 // Is a DOM collection: 235 var allContexts = Array.prototype.slice.call(context), 236 cIndex = -1, cLen = allContexts.length; 237 while (++cIndex<cLen) { init.reset.call(this, allContexts[cIndex]); } 238 return; 239 } 240 context = context || document.documentElement; 241 if (!document.createElement('canvas').getContext) { 242 context.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=0)'; 243 return; 244 } 245 var all = getAllNodes(context), 246 i = -1, len = all.length; 247 while (++i<len) { 248 var cur = all[i]; 249 if (cur.nodeName.toLowerCase() === 'img') { 250 var src = cur.getAttribute('src'); 251 if (isExternal(src)) { 252 config.externalImageHandler.reset(cur, src); 253 } 254 cur.src = data(cur).realSRC || src; 255 } else { 256 for (var pIndex = 0, pLen = config.colorProps.length; pIndex < pLen; pIndex++) { 257 if (data(cur).externalBG) { 258 config.externalImageHandler.reset(cur); 259 } 260 var prop = config.colorProps[pIndex]; 261 cur.style[prop] = data(cur)[prop] || ''; 262 } 263 } 264 } 265 }; 266 267 init.prepare = function(context) { 268 269 // Handle if a DOM collection is passed instead of a single el: 270 if (context && context[0] && context.length && context[0].nodeName) { 271 // Is a DOM collection: 272 var allContexts = Array.prototype.slice.call(context), 273 cIndex = -1, cLen = allContexts.length; 274 while (++cIndex<cLen) { init.prepare.call(null, allC
274ontexts[cIndex]); } 275 return; 276 } 277 278 // Slowly recurses through all elements 279 // so as not to lock up on the user. 280 281 context = context || document.documentElement; 282 283 if (!document.createElement('canvas').getContext) { return; } 284 285 var all = getAllNodes(context), 286 i = -1, len = all.length; 287 288 while (++i<len) { 289 var cur = all[i]; 290 if (data(cur).skip) { return; } 291 if (cur.nodeName.toLowerCase() === 'img') { 292 if (cur.getAttribute('src') && !isExternal(cur.src)) { 293 desatIMG(cur, true); 294 } 295 296 } else { 297 var style = getStyle(cur, 'backgroundImage'); 298 if (style.indexOf('url(') > -1) { 299 var urlPatt = /\(['"]?(.+?)['"]?\)/, 300 url = style.match(urlPatt)[1]; 301 if (!isExternal(url)) { 302 var temp = document.createElement('img'); 303 temp.src = url; 304 desatIMG(temp, true, cur); 305 } 306 } 307 } 308 } 309 }; 310 311 return init; 312 313})(); 314 315 316function checksearchform(){ 317 searchbox_text = document.searchFrm.query.value; 318 document.signal = true; 319 if(searchbox_text==''){ 320 document.signal=false;window.location = '/index.htm'; 321 }else{ 322 document.searchFrm.submit(); 323 } 324} 325function checksearchsubmit(){ 326searchbox_text = document.searchFrm.query.value; 327search_var = (searchbox_text=='')?false:true; 328 329 330 if(searchbox_text==''){ 331if((document.location.pathname.indexOf("/chi/") != -1)||(document.location.pathname.indexOf("\\chi\\") != -1)) 332 333 { 334 alert('è«è¼¸å ¥ééµå') 335 } 336 337else if ((document.location.pathname.indexOf("/eng/") != -1)||(document.location.pathname.indexOf("\\eng\\") != -1)) 338 339 { 340 341 alert('Please Input Keyword') 342 } 343 344else if ((document.location.pathname.indexOf("/sc/") != -1)||(document.location.pathname.indexOf("\\sc\\") != -1)) 345 346{ 347 348 alert('请è¾å ¥å ³é®å') 349} 350 351} 352return search_var; 353} 354 355 356function lastmodify() 357 358{ 359var op=''; 360var today = new Date(2007, 06, 05); 361 362var dd=today.getDate(); 363 364var mm=today.getMonth()+1; 365 366var month=today.getMonth(); 367 368var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December") 369 370var yy=today.getFullYear(); 371 372 373if ( yy <= 1999 ) { 374 375yy=yy+100; 376 377} 378 379if((document.location.pathname.indexOf("/chi/") != -1)||(document.location.pathname.indexOf("\\chi\\") != -1) ||(document.location.pathname.indexOf("/txt_tc/") != -1)||(document.location.pathname.indexOf("\\txt_tc\\") != -1)) 380 381 { 382 383 op= yy +" å¹´ "+ mm +" æ " + dd +" æ¥ "; 384 385 } 386 387else if ((document.location.pathname.indexOf("/eng/") != -1)||(document.location.pathname.indexOf("\\eng\\") != -1) || (document.location.pathname.indexOf("/txt_en/") != -1)||(document.location.pathname.indexOf("\\txt_en\\") != -1)) 388 389 { 390 391 //document.write( dd +" " + switchMonth(mm) +" " + yy); 392 op= " " + dd +" " + monthname[month] +" " + yy +" "; 393 394 } 395 396else if ((document.location.pathname.indexOf("/sc/") != -1)||(document.location.pathname.indexOf("\\sc\\") != -1) || (document.location.pathname.indexOf("/txt_sc/") != -1)||(document.location.pathname.indexOf("\\txt_sc\\") != -1)) 397 398{ 399 400 op= yy +" å¹´ "+ mm +" æ " + dd +" æ¥ "; 401 402} 403 404 return op; 405} 406 407 408function SwitchLang(lang) { 409 410var domainURL = document.location.href; 411var currentURL = encodeURI(document.location.pathname); 412var currentSearch = encodeURI(document.location.search); 413var currentHash = encodeURI(document.location.hash); 414var uatBoo = false; 415if (domainURL.match('https://uat2.netsoft.net/')) 416 uatBoo = true; 417var langArr = [ 418 ['eng','index.htm'], 419 ['chi','index.htm'], 420 ['sc','index.htm'] 421 ]; 422var nextURL = ''; 423if(currentURL.indexOf("/"+langArr[currLang][0]+"/")>=0){ 424 nextURL=currentURL.ReplaceAll("/"+langArr[currLang][0]+"/","/"+lang+"/"); 425} 426if (nextURL.indexOf('/') == 0) 427 nextURL = nextURL.substring(1); 428if(nextURL.match(/\/index\/index(?:_[a-z]|[0-9]+)\.htm/)) 429 nextURL=nextURL.replace(/index(?:_[a-z]|[0-9]+)\.htm/,'index.htm'); 430if (uatBoo) { 431 op = root_path + '../../' + nextURL + currentSearch + currentHash; 432} else { 433 op = root_path + '' + nextURL + currentSearch + currentHash; 434} 435return op; 436/* 437var gopath; 438 439 if (top.location.href.indexOf("#") != -1) { 440 locationx = top.location.href.substring(0, top.location.href.indexOf("#")); 441 } else { 442 locationx = top.location.href; 443 } 444 if (lang == 'eng') { 445 if (locationx.indexOf("/eng/") == -1) { 446 if (locationx.indexOf("/sc/") != -1) { 447 gopath = top.location.replace(locationx.replace("/sc/","/eng/")); 448 } else if (locationx.indexOf("/chi/") != -1) { 449 gopath = top.location.replace(locationx.replace("/chi/","/eng/")); 450 } else if (locationx.indexOf("/txt_en/") != -1) { 451 gopath = top.location.replace(locationx.replace("/txt_en/","/eng/")); 452 } else if (locationx.indexOf("/txt_sc/") != -1) { 453 gopath = top.location.replace(locationx.replace("/txt_sc/","/eng/")); 454 } else if (locationx.indexOf("/txt_tc/") != -1) { 455 gopath = top.location.replace(locationx.replace("/txt_tc/","/eng/")); 456 } 457 } 458 } else if (lang == 'sc') { 459 if (locationx.indexOf("/sc/") == -1) { 460 if (locationx.indexOf("/eng/") != -1) { 461 gopath = top.location.replace(locationx.replace("/eng/","/sc/")); 462 } else if (locationx.indexOf("/chi/") != -1) { 463 gopath = top.location.replace(locationx.replace("/chi/","/sc/")); 464 } else if (locationx.indexOf("/txt_en/") != -1) { 465 gopath = top.location.replace(locationx.replace("/txt_en/","/sc/")); 466 } else if (locationx.indexOf("/txt_sc/") != -1) { 467 gopath = top.location.replace(locationx.replace("/txt_sc/","/sc/")); 468 } else if (locationx.indexOf("/txt_tc/") != -1) { 469 gopath = top.location.replace(locationx.replace("/txt_tc/","/sc/")); 470 } 471 } 472 } else if (lang == 'chi') { 473 if (locationx.indexOf("/chi/") == -1) { 474 if (locationx.indexOf("/eng/") != -1) { 475 gopath = top.location.replace(locationx.replace("/eng/","/chi/")); 476 } else if (locationx.indexOf("/sc/") != -1) { 477 gopath = top.location.replace(locationx.replace("/sc/","/chi/")); 478 } else if (locationx.indexOf("/txt_en/") != -1) { 479 gopath = top.location.replace(locationx.replace("/txt_en/","/chi/")); 480 }else if (locationx.indexOf("/txt_sc/") != -1) { 481 gopath = top.location.replace(locationx.replace("/txt_sc/","/chi/")); 482 } else if (locationx.indexOf("/txt_tc/") != -1) { 483 gopath = top.location.replace(locationx.replace("/txt_tc/","/chi/")); 484 } 485 } 486 } else if (lang == 'txt_en') { 487 if (locationx.indexOf("/txt_en/") == -1) { 488 if (locationx.indexOf("/eng/") != -1) { 489 gopath = top.location.replace(locationx.replace("/eng/","/mobile/eng/")); 490 } else if (locationx.indexOf("/txt_sc/") != -1) { 491 gopath = top.location.replace(locationx.replace("/txt_sc/","/mobile/eng/")); 492 } else if (locationx.indexOf("/txt_tc/") != -1) { 493 gopath = top.location.replace(locationx.replace("/txt_tc/","/mobile/eng/")); 494 } 495 } 496 } else if (lang == 'txt_tc') { 497 if (locationx.indexOf("/txt_tc/") == -1) { 498 if (locationx.indexOf("/chi/") != -1) { 499 gopath = top.location.replace(locationx.replace("/chi/","/mobile/chi/")); 500 } else if (locationx.indexOf("/txt_sc/") != -1) { 501 gopath = top.location.replace(locationx.replace("/txt_sc/","/mobile/chi/")); 502 } else if (locationx.indexOf("/txt_en/") != -1) { 503 gopath = top.location.replace(locationx.replace("/txt_en/","/mobile/chi/")); 504 } 505 } 506 } else if (lang == 'txt_sc') { 507 if (locationx.indexOf("/txt_sc/") == -1) { 508 if (locationx.indexOf("/sc/") != -1) { 509 gopath = top.location.replace(locationx.replace("/sc/","/mobile/sc/")); 510 } else if (locationx.indexOf("/txt_tc/") != -1) { 511 gopath = top.location.replace(locationx.replace("/txt_tc/","/mobile/sc/")); 512 } else if (locationx.indexOf("/txt_en/") != -1) { 513 gopath = top.location.replace(locationx.replace("/txt_en/","/mobile/sc/")); 514 } 515 } 516 } 517*/ 518} 519 520// phoenix, multi level menu 521var MENU_TIMEOUT = 400; 522var menuTimer = null; 523var isMenuOneHovered = false; 524var isMenuTwoHovered = false; 525var isMenuThreeHovered = false; 526 527$(function() { 528 multiLevelMenu(); 529}); 530 531function hideAllMenu() { 532 if(isMenuOneHovered || isMenuTwoHovered || isMenuThreeHovered) { 533 534 } else { 535 $(".sec_level ul").hide(); 536 } 537} 538 539function multiLevelMenu() { 540 // level 1 541 $(".sec_level").hover( 542 function () { 543 isMenuOneHovered=true; 544 stopTimer(); 545 546 // hide all submenu 547 $(".sec_level ul").hide(); 548 549 // show lv2, hide lv3 550 $(this).find("ul").show(); 551 $(this).find("ul").find("ul").hide(); 552 }, 553 function () { 554 isMenuOneHovered=false; 555 startTimer(); 556 } 557 ); 558 559 // level 2 560 $("li.menu_lv2").hover( 561 function(){ 562 isMenuTwoHovered=true; 563 stopTimer(); 564 565 // show lv3 566 $(this).find("ul").show(); 567 }, 568 function(){ 569 isMenuTwoHovered=false; 570 startTimer(); 571 572 // hide lv3 573 $(this).find("ul").hide(); 574 } 575 ); 576 577 // level 3 578 $(".sec_level ul ul").hover( 579 function(){ 580 isMenuThreeHovered=true; 581 stopTimer(); 582 }, 583 function(){ 584 isMenuThreeHovered=false; 585 startTimer(); 586 } 587 588 ); 589} 590 591function startTimer() { 592 menuTimer = window.setTimeout(hideAllMenu, MENU_TIMEOUT); 593} 594 595function stopTimer() { 596 if(menuTimer) { 597 window.clearTimeout(menuTimer); 598 menuTimer = null; 599 } 600} 601 602 603/* ================================================================================================= 604 Socialbookmarking Share Functions 605================================================================================================= */ 606 607 608var currentPath = escape(document.URL); 609 610function shareFacebook() 611{ 612 var currentPath = escape(document.URL); 613 var extLink = 'http://www.facebook.com/share.php?u='; 614 var pageTitle = document.title; 615 window.open(extLink + currentPath + '&t=' + pageTitle); 616} 617 618function shareTwitter() 619{ 620 var currentPath = escape(document.URL); 621 var extLink = 'http://twitter.com/home?status='; 622 var pageTitle = encodeURI(document.title); 623 window.open(extLink + pageTitle + '%3A+' + currentPath); 624} 625 626function shareWeibo() 627{ 628 var currentPath = escape(document.URL); 629 var extLink = "http://v.t.sina.com.cn/share/share.php?title="; 630 var pageTitle = encodeURI(document.title); 631 window.open(extLink + pageTitle + '&url=' + currentPath + '&source=bookmark'); 632} 633/*function emailFriend() 634{ 635 NewWindow('/football/english/email-a-friend_popup.aspx?url='+currentPath+'&title='+escape(d.title), 'emailPop', 540, 610, 'yes', 'yes'); 636} 637 638function shareYahoo() 639{ 640 var currentPath = escape(document.URL);
641 var extLink = "http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u="; 642 var pageTitle = document.title; 643 window.open(extLink + currentPath + '&t=' + pageTitle); 644} 645 646/*function shareGoogle() 647{ 648 var currentPath = escape(document.URL); 649 var extLink = "https://www.google.com/accounts/ServiceLogin?hl=en&continue=https://www.google.com/bookmarks/mark%3Fop%3Dedit%26bkmk%3D"; 650 var pageTitle = document.title; 651 window.open(extLink + currentPath + '&title=' + pageTitle + '&nui=1&service=bookmarks'); 652}*/ 653 654 655/*function shareMyspace() 656{ 657 var extLink = 'http://www.myspace.com/Modules/PostTo/Pages/?u='; 658 var pageTitle = encodeURI(document.title); 659 window.open(extLink + currentPath + '&t=' + pageTitle + '&c=%3Ca+href%3D%22' + currentPath + '%22%3E' + pageTitle + '%3C%2Fa%3E'); 660} 661 662function shareXanga() 663{ 664 var currentPath = escape(document.URL); 665 var extLink = "http://www.xanga.com/private/editorx.aspx?t="; 666 var pageTitle = document.title; 667 window.open(extLink + pageTitle + '&u=' + currentPath); 668} 669 670function shareDelicious() 671{ 672 var currentPath = escape(document.URL); 673 var extLink = "http://delicious.com/save?v=5&noui&jump=close&url="; 674 var pageTitle = document.title; 675 window.open(extLink + currentPath + '&title=' + pageTitle); 676} 677 678 679function emailForm(){ 680 681var currentPath = escape(document.URL); 682var pageTitle = document.title; 683var mailto_link = 'mailto:?subject='+pageTitle+'&body='+currentPath; 684 685window.open(mailto_link); 686}*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.