1var cssparser=new (function($){ 2 var css_copy=null; 3 var rtype=document.styleSheets.length ? 'cssRules' : 'rules'; 4 5 var _grayfn=function(rgb){ 6 var rgbn={r:rgb.r,g:rgb.g,b:rgb.b}; 7 switch (cssparser.graymode){ 8 case 0: 9 return _gray0(rgbn); 10 break; 11 case 2: 12 return _gray2(rgbn); 13 break; 14 case 1: 15 default: 16 return _gray1(rgbn); 17 break; 18 } 19 }; 20 21 this.graymode=1; 22 //Lightness 23 var _gray0=function(rgb){ 24 var nc=Math.round((Math.max(rgb.r, rgb.g, rgb.b) + Math.min(rgb.r, rgb.g, rgb.b))/2); 25 rgb.r=nc; 26 rgb.g=nc; 27 rgb.b=nc; 28 return rgb; 29 } 30 //Average 31 var _gray1=function(rgb){ 32 var nc=Math.round((rgb.r+rgb.g+rgb.b)/3); 33 rgb.r=nc; 34 rgb.g=nc; 35 rgb.b=nc; 36 return rgb; 37 } 38 //Luminosity 39 var _gray2=function(rgb){ 40 var nc=Math.round(0.21*rgb.r + 0.71*rgb.g + 0.07*rgb.b); 41 rgb.r=nc; 42 rgb.g=nc; 43 rgb.b=nc; 44 return rgb; 45 } 46 47 48 49 var hex2dec =function(n) { 50 n='0x'+n; 51 return parseInt(Number(n) ? Number(n) : 0); 52 }; 53 var _parseColor=function(color){ 54 var rgbrx = /rgb *\( *([0-9]{1,3}) *, *([0-9]{1,3}) *, *([0-9]{1,3}) *\)/; 55 var hexrx = /\#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i; 56 var shexrx = /\#([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})/i; 57 var rgb={r:0,g:0,b:0}; 58 var rgbt; 59 color=colourNameToHex(color); 60 if (rgbrx.test(color)){ 61 rgbt=rgbrx.exec(color); 62 rgb.r=parseInt(rgbt[1]); 63 rgb.g=parseInt(rgbt[2]); 64 rgb.b=parseInt(rgbt[3]); 65 } else if (hexrx.test(color)){ 66 rgbt=hexrx.exec(color); 67 rgb.r=hex2dec(rgbt[1]); 68 rgb.g=hex2dec(rgbt[2]); 69 rgb.b=hex2dec(rgbt[3]); 70 } else if (shexrx.test(color)){ 71 rgbt=shexrx.exec(color); 72 rgb.r=hex2dec(rgbt[1]+''+rgbt[1]); 73 rgb.g=hex2dec(rgbt[2]+''+rgbt[2]); 74 rgb.b=hex2dec(rgbt[3]+''+rgbt[3]); 75 } else { 76 return false; 77 } 78 return rgb; 79 } 80 81 var colourNameToHex=function(colour){ 82 var colours = {"aliceblue":"#f0f8ff","antiquewhite":"#faebd7","aqua":"#00ffff","aquamarine":"#7fffd4","azure":"#f0ffff", 83 "beige":"#f5f5dc","bisque":"#ffe4c4","black":"#000000","blanchedalmond":"#ffebcd","blue":"#0000ff","blueviolet":"#8a2be2","brown":"#a52a2a","burlywood":"#deb887", 84 "cadetblue":"#5f9ea0","chartreuse":"#7fff00","chocolate":"#d2691e","coral":"#ff7f50","cornflowerblue":"#6495ed","cornsilk":"#fff8dc","crimson":"#dc143c","cyan":"#00ffff", 85 "darkblue":"#00008b","darkcyan":"#008b8b","darkgoldenrod":"#b8860b","darkgray":"#a9a9a9","darkgreen":"#006400","darkkhaki":"#bdb76b","darkmagenta":"#8b008b","darkolivegreen":"#556b2f", 86 "darkorange":"#ff8c00","darkorchid":"#9932cc","darkred":"#8b0000","darksalmon":"#e9967a","darkseagreen":"#8fbc8f","darkslateblue":"#483d8b","darkslategray":"#2f4f4f","darkturquoise":"#00ced1", 87 "darkviolet":"#9400d3","deeppink":"#ff1493","deepskyblue":"#00bfff","dimgray":"#696969","dodgerblue":"#1e90ff", 88 "firebrick":"#b22222","floralwhite":"#fffaf0","forestgreen":"#228b22","fuchsia":"#ff00ff", 89 "gainsboro":"#dcdcdc","ghostwhite":"#f8f8ff","gold":"#ffd700","goldenrod":"#daa520","gray":"#808080","green":"#008000","greenyellow":"#adff2f", 90 "honeydew":"#f0fff0","hotpink":"#ff69b4", 91 "indianred ":"#cd5c5c","indigo ":"#4b0082","ivory":"#fffff0","khaki":"#f0e68c", 92 "lavender":"#e6e6fa","lavenderblush":"#fff0f5","lawngreen":"#7cfc00","lemonchiffon":"#fffacd","lightblue":"#add8e6","lightcoral":"#f08080","lightcyan":"#e0ffff","lightgoldenrodyellow":"#fafad2", 93 "lightgrey":"#d3d3d3","lightgreen":"#90ee90","lightpink":"#ffb6c1","lightsalmon":"#ffa07a","lightseagreen":"#20b2aa","lightskyblue":"#87cefa","lightslategray":"#778899","lightsteelblue":"#b0c4de", 94 "lightyellow":"#ffffe0","lime":"#00ff00","limegreen":"#32cd32","linen":"#faf0e6", 95 "magenta":"#ff00ff","maroon":"#800000","mediumaquamarine":"#66cdaa","mediumblue":"#0000cd","mediumorchid":"#ba55d3","mediumpurple":"#9370d8","mediumseagreen":"#3cb371","mediumslateblue":"#7b68ee", 96 "mediumspringgreen":"#00fa9a","mediumturquoise":"#48d1cc","mediumvioletred":"#c71585","midnightblue":"#191970","mintcream":"#f5fffa","mistyrose":"#ffe4e1","moccasin":"#ffe4b5", 97 "navajowhite":"#ffdead","navy":"#000080", 98 "oldlace":"#fdf5e6","olive":"#808000","olivedrab":"#6b8e23","orange":"#ffa500","orangered":"#ff4500","orchid":"#da70d6", 99 "palegoldenrod":"#eee8aa","palegreen":"#98fb98","paleturquoise"
99:"#afeeee","palevioletred":"#d87093","papayawhip":"#ffefd5","peachpuff":"#ffdab9","peru":"#cd853f","pink":"#ffc0cb","plum":"#dda0dd","powderblue":"#b0e0e6","purple":"#800080", 100 "red":"#ff0000","rosybrown":"#bc8f8f","royalblue":"#4169e1", 101 "saddlebrown":"#8b4513","salmon":"#fa8072","sandybrown":"#f4a460","seagreen":"#2e8b57","seashell":"#fff5ee","sienna":"#a0522d","silver":"#c0c0c0","skyblue":"#87ceeb","slateblue":"#6a5acd","slategray":"#708090","snow":"#fffafa","springgreen":"#00ff7f","steelblue":"#4682b4", 102 "tan":"#d2b48c","teal":"#008080","thistle":"#d8bfd8","tomato":"#ff6347","turquoise":"#40e0d0", 103 "violet":"#ee82ee", 104 "wheat":"#f5deb3","white":"#ffffff","whitesmoke":"#f5f5f5", 105 "yellow":"#ffff00","yellowgreen":"#9acd32"}; 106 107 if (typeof colours[colour.toLowerCase()] != 'undefined'){ 108 return colours[colour.toLowerCase()]; 109 } 110 return colour; 111 } 112 113 this.grayscale=function(){ 114 var _regexp=/body.grayscale/; 115 _elemsLoop(function(rule,style){ 116 if (!_regexp.test(rule)){ 117 _grayColor(style,'backgroundColor'); 118 _grayColor(style,'color'); 119 _grayColor(style,'borderTopColor'); 120 _grayColor(style,'borderBottomColor'); 121 _grayColor(style,'borderLeftColor'); 122 _grayColor(style,'borderRightColor'); 123 if (typeof style.backgroundImage!='undefined' && style.backgroundImage!=null && style.backgroundImage.indexOf('gradient')>-1){ 124 style.backgroundImage='none'; 125 } 126 } 127 128 }); 129 $('[style]').each(function(){ 130 _jqGrayColor($(this),'background-color'); 131 _jqGrayColor($(this),'color'); 132 _jqGrayColor($(this),'border-top-color'); 133 _jqGrayColor($(this),'border-bottom-color'); 134 _jqGrayColor($(this),'border-left-color'); 135 _jqGrayColor($(this),'border-right-color'); 136 }); 137 }; 138 139 140 this.colorize=function(name,bg,fr){ 141 var _regexp=/body.highcontrast/; 142 _elemsLoop(function(rule,style){ 143 if (!_regexp.test(rule)){ 144 _setColor(style,'backgroundColor',bg); 145 _setColor(style,'color',fr); 146 _setColor(style,'borderTopColor',fr); 147 _setColor(style,'borderBottomColor',fr); 148 _setColor(style,'borderLeftColor',fr); 149 _setColor(style,'borderRightColor',fr); 150 if (typeof style.backgroundImage!='undefined' && style.backgroundImage!=null && style.backgroundImage.indexOf('gradient')>-1){ 151 style.backgroundImage='none'; 152 } 153 } 154 }); 155 $('[style]').each(function(){ 156 _jqSetColor($(this),'background-color',bg); 157 _jqSetColor($(this),'color',fr); 158 _jqSetColor($(this),'border-top-color',fr); 159 _jqSetColor($(this),'border-bottom-color',fr); 160 _jqSetColor($(this),'border-left-color',fr); 161 _jqSetColor($(this),'border-right-color',fr); 162 }); 163 var _bclass=$('body').attr('class'); 164 var _newclass=[]; 165 if ($.trim(_bclass)!=''){ 166 _bclass=_bclass.split(' '); 167 var _regptrn=/^highcontrast/; 168 for (var i=0;i<_bclass.length;i++){ 169 if (!_regptrn.test(_bclass[i])){ 170 _newclass.push(_bclass[i]); 171 } 172 } 173 } 174 $('body').attr('class',_newclass.join(' ')).addClass('highcontrast highcontrast-'+name); 175 176 $(document).trigger('colorupdate',bg,fr,name); 177 }; 178 179 var _setColor=function(style,name,val){ 180 181 if (typeof style[name]!='undefined' && style[name]!=null && style[name]!='' && style[name]!='transparent' && style[name]!='inherit' && style[name]!='none'){ 182 style[name]=val; 183 } 184 }; 185 var _grayColor=function(style,name){ 186 187 if (typeof style[name]!='undefined' && style[name]!=null && style[name]!='' && style[name]!='transparent' && style[name]!='inherit' && style[name]!='none'){ 188 var cl=_parseColor(style[name]); 189 if (cl){ 190 var nc=_grayfn(cl); 191 //console.log(style[name],cl,nc); 192 style[name]='rgb('+nc.r+','+nc.g+','+nc.b+')'; 193 } 194 } 195 }; 196 var _jqGrayColor=function(sel,name){ 197 var ov=sel.css(name); 198 if (typeof ov!='undefined' && ov!='' && ov!=null && ov!='transparent' && ov!='inherit' && ov!='none'){ 199 var cl=_parseColor(sel.css(name)); 200 if (cl){ 201 var nc=_grayfn(cl); 202 //console.log(sel.css(name),cl,nc); 203 sel.css(name,'rgb('+nc.r+','+nc.g+','+nc.b+')'); 204 } 205 } 206 }; 207 208 var _jqSetColor=function(sel,name,value){ 209 var ov=sel.css(name); 210 if (typeof ov!='undefined' && ov!='' && ov!=null && ov!='transparent' && ov!='inherit' && ov!='none'){ 211 sel.css(name,value); 212 } 213 }; 214 215 this.restore=function(){ 216 var csscopy = jQuery.extend({}, css_copy); 217 //console.log(csscopy); 218 document.styleSheets=csscopy; 219 // console.log('restore'); 220 }; 221 222 223 var _elemsLoop=function($cb){ 224 _parseCssRules(document.styleSheets,$cb); 225 }; 226 227 var _parseCssRules=function(ss,$cb){ 228 for (var i=0;i<ss.length;i++){ 229 for (var r=0;r<ss[i][rtype].length;r++){ 230 231 if (ss[i][rtype][r].styleSheet){ 232 _parseCssRules([ss[i][rtype][r].styleSheet],$cb); 233 } else { 234 if (ss[i][rtype][r].style){ 235 $cb(ss[i][rtype][r].selectorText,ss[i][rtype][r].style); 236 } 237 } 238 } 239 } 240 }; 241 242 243 244 245 var _init=function(){ 246 //console.log(document.styleSheets); 247 //css_copy = jQuery.extend( {}, document.styleSheets); 248 }; 249 _init(); 250})(jQuery); 251jQuery(function($){ 252 switch($.cookie('__pstyle')){ 253 case 'bw': 254 cssparser.colorize('bw','#000','#fff'); 255 setTimeout(function(){cssparser.colorize('bw','#000','#fff');},1000); 256 break; 257 case 'ny': 258 cssparser.colorize('ny','#00f','#ff0'); 259 setTimeout(function(){cssparser.colorize('ny','#00f','#ff0');},1000); 260 break; 261 } 262 var _Apply=function(){ 263 if ($('#top-nav .sitecolor-bw').length>0){ 264 $('#top-nav .sitecolor-bw').unbind('click').bind('click',function(e){ 265 e.preventDefault(); 266 cssparser.colorize('bw','#000','#fff'); 267 $.cookie('__pstyle','bw',{path:'/'}); 268 269 return false;
270 }); 271 $('#top-nav .sitecolor-ny').unbind('click').bind('click',function(e){ 272 e.preventDefault(); 273 cssparser.colorize('ny','#00f','#ff0'); 274 $.cookie('__pstyle','ny',{path:'/'}); 275 276 return false; 277 }); 278 $('#top-nav .sitecolor-standard').unbind('click').bind('click',function(e){ 279 e.preventDefault(); 280 $.cookie('__pstyle','',{path:'/'}); 281 document.location.reload(); 282 283 return false; 284 }); 285 } else { 286 setTimeout(function(){ 287 _Apply(); 288 },100); 289 } 290 } 291 _Apply(); 292});
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.