1/* 2 * Start of Javascript for the Counterize plugin 3 */ 4 5 6//a function to get an element by its id regardless of the used browser 7function counterize_getElementByIdUniversal( id ) 8{ 9 var elem; 10 if( document.getElementById ) 11 { 12 elem = document.getElementById( id ); 13 } 14 else 15 { 16 elem = document.all[ id ]; 17 } 18 return elem; 19} 20 21//toggle folding of corresponding ID 22function counterize_fold( sourceElemId, targetElemId ) 23{ 24 var source = counterize_getElementByIdUniversal( sourceElemId ); 25 var target = counterize_getElementByIdUniversal( targetElemId ); 26 27 if( target && source ) 28 { 29 if( target.className == "collapsed" ) 30 { 31 target.className = "expanded"; 32 source.innerHTML = "[ - ]"; 33 } 34 else 35 { 36 target.className = "collapsed"; 37 source.innerHTML = "[ + ]"; 38 } 39 } 40} 41 42// 43function counterize_conf( url ) 44{ 45 if( confirm( 'Are you sure that you want to delete this entry?' ) ) 46 { 47 self.location.href = url; 48 } 49} 50 51//Add filter data to the specified field 52function counterize_add_filter( data, filter_field_name ) 53{ 54 var filter_field = counterize_getElementByIdUniversal( filter_field_name ); 55 if( filter_field ) 56 { 57 if( filter_field.value != '' ) 58 { 59 var tmp = filter_field.value + '||'; 60 if( tmp.indexOf( data + '||' ) < 0 ) 61 { 62 filter_field.value += '||' + data; 63 } 64 else 65 { 66 alert( 'This filter is already set!' ); 67 } 68 } 69 else 70 { 71 filter_field.value += data; 72 } 73 } 74} 75 76//Clear the fields specified in the array 'fields' 77function counterize_clear_filter_form( fields ) 78{ 79 var field; 80 for( var i = 0; i < fields.length; i++ ) 81 { 82 field = counterize_getElementByIdUniversal( fields[i] ); 83 if( field ) 84 { 85 field.value = ""; 86 } 87 } 88} 89 90// 91// by Nannette Thacker 92// http://www.shiningstar.net 93// 94 95function counterize_check_all( field ) 96{ 97 for( i = 0; i < field.length; i++ ) 98 { 99 field[i].checked = true ; 100 } 101} 102 103function counterize_uncheck_all( field ) 104{ 105 for( i = 0; i < field.length; i++ ) 106 { 107 field[i].checked = false ; 108 } 109} 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141/* 142Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work 143of Simon Willison (see comments by Simon below). 144 145Description: 146 147Uses css selectors to apply javascript behaviours to enable 148unobtrusive javascript in html documents. 149 150Usage: 151 152var myrules = { 153 'b.someclass' : function(element){ 154 element.onclick = function(){ 155 alert(this.innerHTML); 156 } 157 }, 158 '#someid u' : function(element){ 159 element.onmouseover = function(){ 160 this.innerHTML = "BLAH!"; 161 } 162 } 163}; 164 165Behaviour.register(myrules); 166 167// Call Behaviour.apply() to re-apply the rules (if you 168// update the dom, etc). 169 170License: 171 172This file is entirely BSD licensed. 173 174More information: 175 176http://ripcord.co.nz/behaviour/ 177 178*/ 179 180var Behaviour = 181{ 182 list: new Array, 183 184 register: function( sheet ) 185 { 186 Behaviour.list.push( sheet ); 187 }, 188 189 start: function() 190 { 191 Behaviour.addLoadEvent( 192 function() 193 { 194 Behaviour.apply(); 195 } 196 ); 197 }, 198 199 apply: function() 200 { 201 for( h = 0; sheet = Behaviour.list[h]; h++ ) 202 { 203 for( selector in sheet ) 204 { 205 list = document.getElementsBySelector( selector ); 206 207 if( ! list ) 208 { 209 continue; 210 } 211 212 for( i = 0; element = list[i]; i++ ) 213 { 214 sheet[selector]( element ); 215 } 216 } 217 } 218 }, 219 220 addLoadEvent: function( func ) 221 { 222 var oldonload = window.onload; 223 224 if( typeof window.onload != 'function' ) 225 { 226 window.onload = func; 227 } 228 else 229 { 230 window.onload = function() 231 { 232 oldonload(); 233 func(); 234 } 235 } 236 } 237} 238 239Behaviour.start(); 240 241/* 242The following code is Copyright (C) Simon Willison 2004. 243 244document.getElementsBySelector(selector) 245- returns an array of element objects from the current document 246matching the CSS selector. Selectors can contain element names, 247class names and ids and can be nested. For example: 248 249elements = document.getElementsBySelect('div#main p a.external') 250 251Will return an array of all 'a' elements with 'external' in their 252class attribute that are contained inside 'p' elements that are 253contained inside the 'div' element which has id="main" 254 255New in version 0.4: Support for CSS2 and CSS3 attribute selectors: 256See http://www.w3.org/TR/css3-selectors/#attribute-selectors 257 258Version 0.4 - Simon Willison, March 25th 2003 259-- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows 260-- Opera 7 fails 261*
262* Some improvements by GabSoftware 263*/ 264 265function getAllChildren( e ) 266{ 267 // Returns all children of element. Workaround required for IE5/Windows. Ugh. 268 return e.all ? e.all : e.getElementsByTagName( '*' ); 269} 270 271document.getElementsBySelector = function( selector ) 272{ 273 // Attempt to fail gracefully in lesser browsers 274 if( ! document.getElementsByTagName ) 275 { 276 return new Array(); 277 } 278 // Split selector in to tokens 279 var tokens = selector.split( ' ' ); 280 var currentContext = new Array( document ); 281 for( var i = 0, tln = tokens.length; i < tln; i++ ) 282 { 283 token = tokens[i].replace( /^\s+/, '' ).replace( /\s+$/, '' ); 284 if( token.indexOf( '#' ) > -1 ) 285 { 286 // Token is an ID selector 287 var bits = token.split( '#' ); 288 var tagName = bits[0]; 289 var id = bits[1]; 290 var element = document.getElementById( id ); 291 if( ! element || ( tagName && element.nodeName.toLowerCase() != tagName ) ) 292 { 293 // tag with that ID not found, return false 294 return new Array(); 295 } 296 // Set currentContext to contain just this element 297 currentContext = new Array( element ); 298 continue; // Skip to next token 299 } 300 if( token.indexOf( '.' ) > -1 ) 301 { 302 // Token contains a class selector 303 var bits = token.split( '.' ); 304 var tagName = bits[0]; 305 var className = bits[1]; 306 if( ! tagName ) 307 { 308 tagName = '*'; 309 } 310 // Get elements matching tag, filter them for class selector 311 var found = new Array; 312 var foundCount = 0; 313 for( var h = 0, ccln = currentContext.length; h < ccln; h++ ) 314 { 315 var elements; 316 if( tagName == '*' ) 317 { 318 elements = getAllChildren( currentContext[h] ); 319 } 320 else 321 { 322 elements = currentContext[h].getElementsByTagName( tagName ); 323 } 324 for( var j = 0, eln = elements.length; j < eln; j++ ) 325 { 326 found[foundCount++] = elements[j]; 327 } 328 } 329 currentContext = new Array; 330 var currentContextIndex = 0; 331 for( var k = 0, fln = found.length; k < fln; k++ ) 332 { 333 if( found[k].className && found[k].className.match( new RegExp( '(\\s|^)' + className + '(\\s|$)' ) ) ) 334 { 335 currentContext[currentContextIndex++] = found[k]; 336 } 337 } 338 continue; // Skip to next token 339 } 340 // Code to deal with attribute selectors 341 if( token.match( /^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ ) ) 342 { 343 var tagName = RegExp.$1; 344 var attrName = RegExp.$2; 345 var attrOperator = RegExp.$3; 346 var attrValue = RegExp.$4; 347 if( ! tagName ) 348 { 349 tagName = '*'; 350 } 351 // Grab all of the tagName elements within current context 352 var found = new Array; 353 var foundCount = 0; 354 for( var h = 0, ccln = currentContext.length; h < ccln; h++ ) 355 { 356 var elements; 357 if( tagName == '*' ) 358 { 359 elements = getAllChildren(currentContext[h] ); 360 } 361 else 362 { 363 elements = currentContext[h].getElementsByTagName( tagName ); 364 } 365 for( var j = 0, eln = elements.length; j < eln; j++ ) 366 { 367 found[foundCount++] = elements[j]; 368 } 369 } 370 currentContext = new Array; 371 var currentContextIndex = 0; 372 var checkFunction; // This function will be used to filter the elements 373 switch( attrOperator ) 374 { 375 case '=': // Equality 376 checkFunction = function( e ) { return ( e.getAttribute( attrName ) == attrValue ); }; 377 break; 378 case '~': // Match one of space seperated words 379 checkFunction = function( e ) { return ( e.getAttribute( attrName ).match( new RegExp( '(\\s|^)' + attrValue + '(\\s|$)' ) ) ); }; 380 break; 381 case '|': // Match start with value followed by optional hyphen 382 checkFunction = function( e ) { return ( e.getAttribute( attrName ).match( new RegExp( '^' + attrValue + '-?' ) ) ); }; 383 break; 384 case '^': // Match starts with value 385 checkFunction = function( e ) { return ( e.getAttribute( attrName ).indexOf( attrValue ) == 0 ); }; 386 break; 387 case '$': // Match ends with value - fails with "Warning" in Opera 7 388 checkFunction = function( e ) { return ( e.getAttribute( attrName ).lastIndexOf( attrValue ) == e.getAttribute( attrName ).length - attrValue.length ); }; 389 break; 390 case '*': // Match ends with value 391 checkFunction = function( e ) { return ( e.getAttribute( attrName ).indexOf( attrValue ) > -1 ); }; 392 break; 393 default : 394 // Just test for existence of attribute 395 checkFunction = function( e ) { return e.getAttribute( attrName ); }; 396 } 397 currentContext = new Array; 398 var currentContextIndex = 0; 399 for( var k = 0, fln = found.length; k < fln; k++ ) 400 { 401 if (checkFunction(found[k])) 402 { 403 currentContext[currentContextIndex++] = found[k]; 404 } 405 } 406 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue); 407 continue; // Skip to next token 408 } 409 410 if( ! currentContext[0] ) 411 { 412 return; 413 } 414 415 // If we get here, token is JUST an element (not a class or ID selector) 416 tagName = token; 417 var found = new Array; 418 var foundCount = 0; 419 for( var h = 0, ccln = currentContext.length; h < ccln; h++ ) 420 { 421 var elements = currentContext[h].getElementsByTagName( tagName ); 422 for( var j = 0, eln = elements.length; j < eln; j++ ) 423 { 424 found[foundCount++] = elements[j]; 425 } 426 } 427 currentContext = found; 428 } 429 return currentContext; 430} 431
432/* That revolting regular expression explained 433/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ 434\---/ \---/\-------------/ \-------/ 435| | | | 436| | | The value 437| | ~,|,^,$,* or = 438| Attribute 439Tag 440*/ 441 442var myrules = 443{ 444 'a': function( el ) 445 { 446 if( document.domain ) 447 { 448 if( el.onclick != null || el.href.substring( 0, 1 ) == '/' || el.href.substring( 0, 1 ) == '#' || el.href.substring( 0, 11 ) == 'javascript:' || el.href.indexOf( document.domain ) > -1 ) 449 { 450 return; 451 } 452 else 453 { 454 el.onclick = function() 455 { 456 var request = false; 457 try 458 { 459 request = new XMLHttpRequest(); 460 } 461 catch( trymicrosoft ) 462 { 463 try 464 { 465 request = new ActiveXObject( 'Msxml2.XMLHTTP' ); 466 } 467 catch( othermicrosoft ) 468 { 469 try 470 { 471 request = new ActiveXObject( 'Microsoft.XMLHTTP' ); 472 } 473 catch( failed ) 474 { 475 request = false; 476 } 477 } 478 } 479 480 if( ! request ) 481 { 482 alert( 'Error initializing XMLHttpRequest!' ); 483 return; 484 } 485 486 487 var url = '/Wordpress/wp-content/plugins/counterize/counterize.php?external=1&href=' + escape( this.href ) + '&from=' + escape( window.location.href ) + '&time=1790280637'; 488 request.abort(); 489 request.open( 'GET', url, false ); 490 request.onreadystatechange = 491 function() 492 { 493 if( request.readyState == 4 ) 494 { 495 if( request.status == 200 ) 496 { 497 var response = request.responseText; 498 //alert( 'response: ' + response ); 499 } 500 else 501 { 502 //alert( request.status ); 503 } 504 } 505 }; 506 request.send( null ); 507 } 508 } 509 } 510 } 511}; 512Behaviour.register( myrules ); 513 514 515 516 517 518 519// 520// End of Counterize Javascript 521//
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.