1// <![CDATA[ 2// ---------------------------------------------------------------------- 3// Rotate content display -- Ken True -- saratoga-weather.org 4// This script is for use with the ajaxwx.js to create a rotating gizmo 5// display of AJAX conditions marked with <span class="contentN" style="display: none"></span> 6// where N=0..8 7// 8// Version 1.00 - initial release 9// Version 1.01 - changed to look for class="ajaxcontentN" to prevent interference with buoy-data.php 10// 11// 12// --------- begom settomgs --------------------------------------------------------------- 13var ajaxrotatedelay=4000; // Rotate display every 4 secs (= 4000 ms) 14var showUV = true ; // set to false if you don't have a Davis VP UV sensor 15// --------- emd settomgs ----------------------------------------------------------------- 16// 17// you shouldn't need to change things below this line 18// 19var ie4=document.all; 20var browser = navigator.appName; 21var ie8 = false; 22if (ie4 && /MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x; 23 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number 24 if (ieversion>=8) { 25 ie4=false; 26 ie8=true; 27 } 28} 29var ajaxcurindex = 0; 30var ajaxtotalcontent = 0; 31var ajaxrunrotation = 1; 32var browser = navigator.appName; 33 34function get_content_tags ( tag ) { 35// search all the span tags and return the list with class=tag 36// 37 if (ie4 && browser != "Opera" && ! ie8) { 38 var elem = document.getElementsByTagName('span'); 39 var lookfor = 'className'; 40 } else { 41 var elem = document.getElementsByTagName('span'); 42 var lookfor = 'class'; 43 } 44 var arr = new Array(); 45 var i = 0; 46 var iarr = 0; 47 48 for(i = 0; i < elem.length; i++) { 49 var att = elem[i].getAttribute(lookfor); 50 if(att == tag) { 51 arr[iarr] = elem[i]; 52 iarr++; 53 } 54 } 55 56 return arr; 57} 58 59 60function ajax_get_total() { 61 ajaxtotalcontent = 8; // content0 .. content7 62 if (showUV) { ajaxtotalcontent++ ; } // UV display is in last content area 63} 64 65function ajax_contract_all() { 66 for (var y=0;y<ajaxtotalcontent;y++) { 67 var elements = get_content_tags("ajaxcontent"+y); 68 var numelements = elements.length; 69// alert("ajax_contract_all: content"+y+" numelements="+numelements); 70 for (var index=0;index!=numelements;index++) { 71 var element = elements[index]; 72 element.style.display="none"; 73 } 74 } 75} 76 77function ajax_expand_one(which) { 78 ajax_contract_all(); 79 var elements = get_content_tags("ajaxcontent"+which); 80 var numelements = elements.length; 81 for (var index=0;index!=numelements;index++) { 82 var element = elements[index]; 83 element.style.display="inline"; 84 } 85} 86function ajax_step_content() { 87 ajax_get_total(); 88 ajax_contract_all(); 89 ajaxcurindex=(ajaxcurindex<ajaxtotalcontent-1)? ajaxcurindex+1: 0; 90 ajax_expand_one(ajaxcurindex); 91} 92function ajax_set_run(val) { 93 ajaxrunrotation = val; 94 ajax_rotate_content(); 95} 96function ajax_rotate_content() { 97 if (ajaxrunrotation) { 98 ajax_get_total(); 99 ajax_contract_all(); 100 ajax_expand_one(ajaxcurindex); 101 ajaxcurindex=(ajaxcurindex<ajaxtotalcontent-1)? ajaxcurindex+1: 0; 102 setTimeout("ajax_rotate_content()",ajaxrotatedelay); 103 } 104} 105 106ajax_rotate_content(); 107 108// ]]>
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.