/******************************************************************** ******* scrollbox.js ********************************************************************/ /********************************************************* * Scrollbox control ************************ * by Kozyuck Alexander, 2008 ************************ * kolexander@gmail.com ************************ *********************************************************/ var Scrollbox = Class.create(); Scrollbox.prototype = { initialize: function(parameters) { this.cont = $(parameters.contId); this.list = $(parameters.listId); if(typeof parameters.insertTo == 'undefined') this.insertTo = $('scrollrows') else this.insertTo = $(parameters.insertTo) if(typeof parameters.gauge == 'undefined') this.gauge = $('regauge'); else this.gauge = $(parameters.gauge); if(typeof parameters.scrollLeft == 'undefined') this.scrollLeft = 0; else this.scrollLeft = parameters.scrollLeft; this.offsetDiv = 10; this.repeatTm = 5; this.timer = null; this.downButton = false; this.nomoreRows = false; this.countFetchRows = 20; this.fromVal = 0; if(typeof parameters.prevButton == 'undefined') this.prevButton = $('prev'); else this.prevButton = $(parameters.prevButton); if(typeof parameters.nextButton == 'undefined') this.nextButton = $('next'); else this.nextButton = $(parameters.nextButton); if(typeof parameters.fetching == 'undefined') this.fetching = false; else this.fetching = parameters.fetching; if(typeof parameters.fromUrl == 'undefined') this.fromUrl = '/main/fetch'; else this.fromUrl = parameters.fromUrl; if(typeof parameters.fetchParams == 'undefined') this.fetchParams = null; else this.fetchParams = parameters.fetchParams; if(typeof parameters.direction == 'undefined') this.direction = 'vertical'; else this.direction = parameters.direction; if(typeof parameters.prevButton != 'undefined') { this.prevButton.onmousedown = this.pressPrevButton.bindAsEventListener(this); this.prevButton.onmouseup = this.releaseButton.bindAsEventListener(this); this.prevButton.onmouseout = this.releaseButton.bindAsEventListener(this); } if(typeof parameters.nextButton != 'undefined') { this.nextButton.onmousedown = this.pressNextButton.bindAsEventListener(this); this.nextButton.onmouseup = this.releaseButton.bindAsEventListener(this); this.nextButton.onmouseout = this.releaseButton.bindAsEventListener(this); } }, setGaugeHidden: function(){ this.gauge.style.visibility = 'hidden'; }, setGaugeVisible: function(){ this.gauge.style.left = this.cont.offsetLeft+Math.round((this.cont.offsetWidth-this.gauge.offsetWidth)/2)+'px'; this.gauge.style.top = this.cont.offsetTop+Math.round((this.cont.offsetHeight-this.gauge.offsetHeight)/2)+'px'; this.gauge.style.visibility = 'visible'; }, dec: function(val) { var par = parseInt(val); val = (isNaN(par))?0:par - this.offsetDiv; return val+"px"; }, inc: function(val) { var par = parseInt(val); val = (isNaN(par))?0:par + this.offsetDiv; return val+"px"; }, pressPrevButton: function() { this.downButton = true; this.scrollPrev(); }, pressNextButton: function() { this.downButton = true; this.scrollNext(); }, releaseButton: function() { this.downButton = false; }, scrollPrev: function() { if(this.downButton) { //если долистали в начало if((this.direction=='horizontal'&&parseInt(this.list.style.left) >= this.scrollLeft) || (this.direction=='vertical'&&parseInt(this.list.style.top) >= this.scrollLeft)) { this.downButton = false; clearTimeout(this.timer); this.onAfterScroll(); return; } if(this.direction=='horizontal') this.list.style.left = this.inc(this.list.style.left); if(this.direction=='vertical') this.list.style.top = this.inc(this.list.style.top); this.timer = setTimeout( function(){ this.scrollPrev() ; }.bind(this), this.repeatTm) } else clearTimeout(this.timer); }, scrollNext: function() { if(this.downButton) { //если долистали до конца if((this.direction=='horizontal' && ((-1)*parseInt(this.list.offsetLeft) > (parseInt(this.list.offsetWidth) - parseInt(this.cont.offsetWidth) - this.scrollLeft))) || (this.direction=='vertical' && ((-1)*parseInt(this.list.offsetTop) > (parseInt(this.list.offsetHeight) - parseInt(this.cont.offsetHeight))) )) { this.downButton = false; clearTimeout(this.timer); this.fromVal += this.countFetchRows; if(!this.nomoreRows && this.fetching) this.fetchNextBlock(); this.scrollLeft = 0; this.onAfterScroll(); return; } if(this.direction=='horizontal') this.list.style.left = this.dec(this.list.style.left); else this.list.style.top = this.dec(this.list.style.top); this.timer = setTimeout( function(){ this.scrollNext(); }.bind(this), this.repeatTm); } else clearTimeout(this.timer); }, scrollBegin: function() { this.downButton = true; this.scrollPrev(); }, scrollEnd: function() { this.downButton = true; this.scrollNext(); }, fetchNextBlock: function() { this.setGaugeVisible(); var sfparm = ''; for(fparm in this.fetchParams) { sfparm += '&'+fparm+'='+this.fetchParams[fparm] } new Ajax.Updater(this.insertTo.id, this.fromUrl,{ method: "post", parameters:sfparm+"&offset=" + this.fromVal + "&rowcount=" + this.countFetchRows, //&light=1 insertion: Insertion.Bottom, onComplete: this.handleResponse.bind(this), onFailure: this.reportError.bind(this) } ); }, onAfterScroll: function (){ }, handleResponse: function(response) { if(response.responseText.length == 0) this.nomoreRows = true; this.setGaugeHidden(); }, reportError: function(err) { } } /******************************************************************** ******* colorsphere.js ********************************************************************/ /* DHTML Color Sphere : v1.0.2 : 2008/04/17 */ /* http://www.colorjack.com/software/dhtml+color+sphere.html */ /* Modified by Alex Kozuck 2008/05/26 */ var __coord = {X: 0, Y: 0}; function getObj(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); } function getObjStyle(o) { o=getObj(o); if(o) return(o.style); } function abPos(o) { var o=(typeof(o)=='object'?o:getObj(o)), z={X:0,Y:0}; while(o!=null) { z.X+=o.offsetLeft; z.Y+=o.offsetTop; o=o.offsetParent; }; return(z); } function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); } function isset(v) { return((typeof(v)=='undefined' || v.length==0)?false:true); } function toggle(i,t,xy) { var v=getObjStyle(i); v.display=t?t:(v.display=='none'?'block':'none'); if(xy) { v.left=xy[0]; v.top=xy[1]; } } function XY(e,v) { try { if(agent('msie')) { var o = {'X':e.clientX+document.body.scrollLeft,'Y':e.clientY+document.body.scrollTop}; } else var o = {'X':e.pageX,'Y':e.pageY}; __coord = o; }catch(e){ var o = __coord; } return(v?o[v]:o); } function zero(n) { return(!isNaN(n=parseFloat(n))?n:0); } function zindex(d) { d.style.zIndex=zINDEX++; } /* COLOR PICKER */ Picker={}; Picker.stop=1; Picker.core=function(o,e,xy,z,fu) { function point(a,b,e) { eZ=XY(e); commit([eZ.X+a,eZ.Y+b]); } function M(v,a,z) { return(Math.max(!isNaN(z)?z:0,!isNaN(a)?Math.min(a,v):v)); } function commit(v) { if(fu) fu(v); if(o=='mCur') { var W=parseInt(getObjStyle('mSpec').width), W2=W/2, W3=W2/2; var x=v[0]-W2-3, y=W-v[1]-W2+21, SV=Math.sqrt(Math.pow(x,2)+Math.pow(y,2)), hue=Math.atan2(x,y)/(Math.PI*2); hsv={'H':hue>0?(hue*360):((hue*360)+360), 'S':SV=W3?Math.max(0,1-((SV-W3)/(W2-W3)))*100:100}; getObj('mHEX').innerHTML=color.HSV_HEX(hsv); try { // if(!Picker.stop) selectColorHandler(); }catch(e){ } color.cords(W); } else if(o=='mSize') { var b=Math.max(Math.max(v[0],v[1])+oH,75); color.cords(b); // getObjStyle('mini').height=(b+28)+'px'; getObjStyle('mini').width=(b+20)+'px'; getObjStyle('mSpec').height=b+'px'; getObjStyle('mSpec').width=b+'px'; } else { if(xy) v=[M(v[0],xy[0],xy[2]), M(v[1],xy[1],xy[3])]; // XY LIMIT if(!xy || xy[0]) d.left=v[0]+'px'; if(!xy || xy[1]) d.top=v[1]+'px'; } }; if(Picker.stop) { Picker.stop=''; var d=getObjStyle(o), eZ=XY(e); if(!z) zindex(getObj(o)); if(o=='mCur') { var ab=abPos(getObj(o).parentNode); point(-(ab.X-5),-(ab.Y-28),e); } if(o=='mSize') { var oH = parseInt(getObjStyle('mSpec').height), oX=-XY(e).X, oY=-XY(e).Y; } else { var oX=zero(d.left)-eZ.X, oY=zero(d.top)-eZ.Y; } document.onmousemove=function(e) { if(!Picker.stop) point(oX,oY,e); }; document.onmouseup=function() { Picker.stop=1; document.onmousemove=''; document.onmouseup=''; }; } }; Picker.hsv={H:0, S:0, V:100}; zINDEX=2; /* COLOR LIBRARY */ color={}; color.cords=function(W) { var W2=W/2, rad=(hsv.H/360)*(Math.PI*2), hyp=(hsv.S+(100-hsv.V))/100*(W2/2); getObjStyle('mCur').left=Math.round(Math.abs(Math.round(Math.sin(rad)*hyp)+W2+3))+'px'; getObjStyle('mCur').top=Math.round(Math.abs(Math.round(Math.cos(rad)*hyp)-W2-21))+'px'; }; color.HEX=function(o) { o=Math.round(Math.min(Math.max(0,o),255)); return("0123456789ABCDEF".charAt((o-o%16)/16)+"0123456789ABCDEF".charAt(o%16)); }; color.RGB_HEX=function(o) { var fu=color.HEX; return(fu(o.R)+fu(o.G)+fu(o.B)); }; color.HSV_RGB=function(o) { var R, G, A, B, C, S=o.S/100, V=o.V/100, H=o.H/360; if(S>0) { if(H>=1) H=0; H=6*H; F=H-Math.floor(H); A=Math.round(255*V*(1-S)); B=Math.round(255*V*(1-(S*F))); C=Math.round(255*V*(1-(S*(1-F)))); V=Math.round(255*V); switch(Math.floor(H)) { case 0: R=V; G=C; B=A; break; case 1: R=B; G=V; B=A; break; case 2: R=A; G=V; B=C; break; case 3: R=A; G=B; B=V; break; case 4: R=C; G=A; B=V; break; case 5: R=V; G=A; B=B; break; } return({'R':R?R:0, 'G':G?G:0, 'B':B?B:0, 'A':1}); } else return({'R':(V=Math.round(V*255)), 'G':V, 'B':V, 'A':1}); }; color.HSV_HEX = function(o) { return(color.RGB_HEX(color.HSV_RGB(o))); }; /******************************************************************** ******* informerstune.js ********************************************************************/ initCommon(); var curl = '/'+curlang+'/informertune/'; var colorInformer = '0000FF'; var bgcolorInformer = 'FFFFFF'; var txtcolorInformer = 'FFFF00'; var tmC = null; var tmCts = null; var singleCityTypes = [1,2,3,7,8,9,11]; var multipleCityTypes = [5, 6, 16, 25, 33, 34, 35, 38]; var dinamicHeight var flashInformerTypes = [5, 6, 9, 33] ; var flagTuneMode = '&tune=1'; var searchCountryFilter = null; var countryFilter = checkCountryInList1(); var informer_struct = eval(informer_json) ; var flashInformParams = {size:{width:null, height:null}, color:null,txtcolor:null, citylist:null}; var curCountryInList1 = country ; function getInformerUrl() { if (informer_struct.type == 'graphic') { var citis = getUrlCityList(); if(citis.length==0) { citis = city_url_list;//&city[]='+city_name_url; var tocity = 'weather/'+city_name_url+'/'; var meta = _strings.weather_in+' '+incity; } else { var m = citis.match(/\&city\[\]\=(\w+)/); var tocity = 'weather/'+m[1]+'/'; var meta = _strings.weather_in+' '+getCitiesNamesM(); } var url = root+'informerget/?type='+type+citis+'&color='+colorInformer+'&txtcolor='+txtcolorInformer; var radio = $('forminformers').elements['langs']; langs = curlang; for(var i=0; i < radio.length; i++) { if(radio[i].checked) { var langs = radio[i].value; break; } } url = String(url).replace(/\/\w{2}\//g,'/'+langs+'/'); //******************************Work with Flash informers******************** if (isFlashInformer(type)) { } //*************************************************************************** //********************************************************************************************************************* //develop informer tags if (type == 25) { //countryFilter = curCountryInList1 ; var city_arr = new Array() ; var area_coords = new Array() ; var len ; var area = '' ; city_arr = citis.split('&city[]=') ; len = city_arr.length ; area_coords = _getInformerCordsImap(len-1, type) ; for (var i = 1; i < len; i++) { area += '\n'; //alt="informer_part#'+i+'" } map_str = '\n' + '\n' + area + '\n' + '\n' ; var inf_code = '' ; var inf_code_page = '' ; if ($('checkcountry').checked) { url = url + '&country=1'; inf_code = '\\n' + '\'+meta+'\n\ \n\n'; inf_code_page = '\\n' + '\'+meta+'\n\ \n\n' ; $('messagebox').update(_strings.informer_check_box_only_one_country); } else { url = url + '&country=0'; inf_code = '\\n' + '\'+meta+'\n\ \n\n'; inf_code_page = '\\n' + '\'+meta+'\n' + '\\n\n'; $('messagebox').update(''); } var inf_code_map = map_str + inf_code; $('informer_code').value = inf_code_map ; $('informer_many_part').update(inf_code_page) ; $('informer_'+type).update(map_str) ; } //********************************************************************************************************* else $('informer_code').value = '\n\ \n\ '+meta+'\n\ \n\ \n'; return url; } } /** * Формирует координаты имапа для информера */ function _getInformerCordsImap(informer_len, informer_type) { var coords = new Array() ; switch (informer_type) { case '25': var start_x = 7 ; var end_x = 133 ; for (var i = 1; i <= informer_len; i++) { var j = i - 1 ; coords[i] = start_x + ', ' + (j * 34 + 23) + ', ' + end_x + ', ' + ((j + 1) * 34 + 23) ; } break; } return coords ; } //************************************************************************************************ /** * Return type "TRUE" if informers type is "Flash" else return - "FALSE" * * informer_type - type of informer * */ function isFlashInformer(informer_type) { var ret = false; if(flashInformerTypes.indexOf(parseInt(informer_type))==-1) ret = true; return ret; } function updateFlashInformer(status_update) { if ('full' != status_update) getFlashInformer(status_update); else $('informer').update(getFlashInformer(status_update)); } /** * We set co-ordinates for current informera * * type_informer - type current informera * * return array coodinates for informera */ function _getFlashInformerCoords(type_informer) { var params ; switch(type_informer) { case "5": flashInformParams.size.width = 122 ; flashInformParams.size.height = 93 ; if (flashInformParams.color == null) flashInformParams.color = "FF8895" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "404BFF" //return params = {width: 122, height: 93} ; break ; case "6": flashInformParams.size.width = 134 ; flashInformParams.size.height = 104 ; if (flashInformParams.color == null) flashInformParams.color = "ABDC00" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "A91A00" //return params = {width: 134, height: 104} ; break ; //prev informer number 8 case "36": flashInformParams.size.width = 124 ; flashInformParams.size.height = 84 ; if (flashInformParams.color == null) flashInformParams.color = "E07979" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFF982" //return params = {width: 134, height: 104} ; break ; case "9": flashInformParams.size.width = 116 ; flashInformParams.size.height = 158 ; if (flashInformParams.color == null) flashInformParams.color = "FF7513" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "3D80FF" //return params = {width: 116, height: 158} ; break ; case "16": flashInformParams.size.width = 267 ; flashInformParams.size.height = 169 ; flashInformParams.heightCitySection = 16; flashInformParams.basicHeight = 105; if (flashInformParams.color == null) flashInformParams.color = "00A4A0" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFDE6E" //return params = {width: 116, height: 158} ; break ; case "30": flashInformParams.size.width = 240 ; flashInformParams.size.height = 82 ; if (flashInformParams.color == null) flashInformParams.color = "FFEFF8" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFA900" //return params = {width: 116, height: 158} ; break ; case "34": flashInformParams.size.width = 139 ; flashInformParams.size.height = 153 ; flashInformParams.heightCitySection = 17; flashInformParams.basicHeight = 68; if (flashInformParams.color == null) flashInformParams.color = "FF0726" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "31A0FF" //return params = {width: 116, height: 158} ; break ; case "35": flashInformParams.size.width = 188 ; flashInformParams.size.height = 217; flashInformParams.heightCitySection = 23; flashInformParams.basicHeight = 102; if (flashInformParams.color == null) flashInformParams.color = "AAFFE9" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "00A686" //return params = {width: 116, height: 158} ; break ; case "38": flashInformParams.size.width = 140 ; flashInformParams.size.height = 187 ; if (flashInformParams.color == null) flashInformParams.color = "C01B00" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "3D80FF" //return params = {width: 116, height: 158} ; break ; //prev informer number 11 case "37": flashInformParams.size.width = 122 ; flashInformParams.size.height = 82 ; if (flashInformParams.color == null) flashInformParams.color = "7E98FF" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "B44F00" //return params = {width: 116, height: 158} ; break ; //prev informer number 12 case "38": flashInformParams.size.width = 150 ; flashInformParams.size.height = 200 ; if (flashInformParams.color == null) flashInformParams.color = "C01B00" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFFFFF" //return params = {width: 116, height: 158} ; break ; case "13": flashInformParams.size.width = 125 ; flashInformParams.size.height = 88 ; if (flashInformParams.color == null) flashInformParams.color = "FF7513" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "3D80FF" //return params = {width: 150, height: 127} ; break ; case "15": flashInformParams.size.width = 125 ; flashInformParams.size.height = 93 ; if (flashInformParams.color == null) flashInformParams.color = "C7F2FF" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFF872" //return params = {width: 150, height: 127} ; break ; case "21": flashInformParams.size.width = 120 ; flashInformParams.size.height = 110 ; if (flashInformParams.color == null) flashInformParams.color = "FFFFFF" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFFFFF" //return params = {width: 150, height: 127} ; break ; case "17": flashInformParams.size.width = 150 ; flashInformParams.size.height = 122 ; if (flashInformParams.color == null) flashInformParams.color = "5BD500" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FF0916" //return params = {width: 150, height: 127} ; break ; case "18": flashInformParams.size.width = 150 ; flashInformParams.size.height = 122 ; if (flashInformParams.color == null) flashInformParams.color = "008BA4" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "3B0FFF" //return params = {width: 150, height: 127} ; break ; case "20": flashInformParams.size.width = 142 ; flashInformParams.size.height = 110 ; if (flashInformParams.color == null) flashInformParams.color = "E9AF00" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFE73C" //return params = {width: 150, height: 127} ; break ; case "27": flashInformParams.size.width = 240 ; flashInformParams.size.height = 83 ; if (flashInformParams.color == null) flashInformParams.color = "006A23" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "FFF872" //return params = {width: 150, height: 127} ; break ; case "33": flashInformParams.size.width = 150 ; flashInformParams.size.height = 127 ; if (flashInformParams.color == null) flashInformParams.color = "7DC9FF" ; if (flashInformParams.txtcolor == null) flashInformParams.txtcolor = "F6FF81" //return params = {width: 150, height: 127} ; break ; /* default: flashInformParams.size.width = 100 ; flashInformParams.size.height = 100 ; break ; */ } var cities = getUrlCityList(); if(cities.length == 0) flashInformParams.citylist = city_name_list_flash ; else flashInformParams.citylist = cities ; var cities_arr = flashInformParams.citylist.split(','); if(informer_struct.dinamic_height) if ((undefined != flashInformParams.heightCitySection) && (undefined != flashInformParams.basicHeight)) flashInformParams.size.height = (flashInformParams.heightCitySection * cities_arr.length) + (flashInformParams.basicHeight); } function getFlashInformer(status_update){ //var flashInformParams = {size:{width:122,height:93},color:"FF0000",txtcolor:"FFFF00"}; //get informer size coordinates _getFlashInformerCoords(type) ; var radio = $('forminformers').elements['langs']; langs = curlang; for(var i=0; i < radio.length; i++) { if(radio[i].checked) { var langs = radio[i].value; break; } } var params = flashInformParams; var informpath = '/pictures/informers/flash/inform'; var informer_code = "\n" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "\n"; $('informer_code').value = informer_code ; if ('full' == status_update) { var code = "" + "" + "" + "" + "" + "" + "" + "" + "" ; return code; } } function selectColorHandler() { if(!Picker.stop) { if($('rcolorinf').checked) { colorInformer = $('mHEX').innerHTML; if(isGraphInformer) { $('informer').src = getInformerUrl() + flagTuneMode; } else { flashInformParams.color = colorInformer; $('informer').update(getFlashInformer('full')); // $('inform5').setAttribute("value", "http://www.meteoprog2.ua/ru/informer/&color="+colorInformer+"&txtcolor=000000&country=Ukraine&city=Kuiv, Kharkiv, Donetsk, Odesa"); var a = 1; } } } if($('rcolorbg').checked) { bgcolorInformer = $('mHEX').innerHTML; $('plugID').style.backgroundColor='#'+bgcolorInformer; if(isGraphInformer) { $('informer').src = getInformerUrl() + flagTuneMode; } else { // flashInformParams.color // $('informer').update(getFlashInformer()); } } if($('rcolortxt').checked) { txtcolorInformer = $('mHEX').innerHTML; if(isGraphInformer) { $('informer').src = getInformerUrl() + flagTuneMode; } else { flashInformParams.txtcolor = txtcolorInformer; $('informer').update(getFlashInformer('full')); } } } function selectLanguageHandler() { $('informer').src = getInformerUrl() + flagTuneMode; if ('flash' == informer_struct.type) updateFlashInformer('full') ; } function startCountriesAutoCompleter(){ tmC = setTimeout('searchCountries()',1500); } function searchCountries() { clearTimeout(tmC); // new Ajax.Updater($('scrollrows1'), curl + 'getcountries',{ // //searchCountryFilter = ; scroller1.nomoreRows = false; scroller1.fetchParams.search = $('countries').value; scroller1.fromVal = 0; new Ajax.Request(curl + 'getcountries',{ method: "post", parameters:"&ajax=1&search="+$('countries').value, onComplete: handleSearchCountriesResponse.bind(this), onFailure: reportSearchCountriesError.bind(this)() } ); } function handleSearchCountriesResponse(response){ try{ scroller1.list.style.top = '0px'; $('scrollrows1').update(response.responseText); }catch(e){ } } function reportSearchCountriesError(){ return; } function startCitiesAutoCompleter() { tmCts = setTimeout('searchCities()',1500); } function getSelectedCountry() { var country = null; // if($('checkcountry').checked) { var rows = document.getElementsByClassName('row-selected',$('scrollrows1')); if(rows.length > 0) country = rows[0].getAttribute('rowid'); // } return country; } function getSelectedCities() { var cities = []; var rows = document.getElementsByClassName('row-selected',$('scrollrows1')); if(rows.length > 0) { for(var i; i < rows.length; i++) { cities[cities.length] = rows[i].getAttribute('rowid'); } } return country; } function searchCities() { clearTimeout(tmCts); var country = ''; // if($('checkcountry').checked) { country = getSelectedCountry(); countryFilter = country; scroller2.nomoreRows = false; scroller2.fetchParams.search = null; scroller2.fetchParams.country = country; scroller2.fromVal = 0; country = (isDefined(country)&&String(country).length>0)?'&country='+country:''; // } new Ajax.Request(curl + 'getcitiesbycountry',{ method: "post", parameters:"&ajax=1&search="+($('cities').value==_strings.input_name?'':$('cities').value)+country, onComplete: handleSearchCitiesResponse.bind(this), onFailure: reportError.bind(this)() } ); } function handleSearchCitiesResponse(response){ try{ scroller2.list.style.top = '0px'; $('list2body').update(response.responseText); }catch(e){ } } function reportError(){ return; } Event.observe(document.body, 'click', function(event) { var cell = Event.element(event); if (typeof cell.parentNode.parentNode.parentNode.parentNode != 'undefined') { //обрабатываем события кликов на listbox switch(cell.parentNode.parentNode.parentNode.parentNode.id) { case 'list1': if(!$('checkcountry').checked) { var rows = $('list1').getElementsBySelector('.row-selected'); if(rows.length > 0) $(rows[0]).removeClassName('row-selected'); $(cell.parentNode).addClassName('row-selected'); $('cities').value = ''; searchCities(cell.parentNode.getAttribute('rowid')); } break; case 'list2': if(Element.hasClassName(cell.parentNode, 'row-selected')) { cell.parentNode.removeClassName('row-selected'); } else if(cell.className == 'cell' || cell.className == 'clrsltbg') { cell.parentNode.addClassName('row-selected'); } break; case 'list3': var rows = $('list3').getElementsBySelector('.row-selected'); if(rows.length > 0) $(rows[0]).removeClassName('row-selected'); $(cell.parentNode).addClassName('row-selected'); } } } ); /** * get Curent selected country in List1 */ function checkCountryInList1() { if ($('checkcountry').checked) { var rows = $('scrollrows1').childNodes; for(var i=0; i < rows.length; i++) { if ($(rows[i]).hasClassName('row-selected')) { return rows[i].getAttribute('rowid') ; break ; } } } else return null ; } function addCities() { if(isSingleCityInformer() && $('list3body').childNodes.length > 0) { $('messagebox').update(_strings.informer_one_city_only); return; } var rows = $('list2').getElementsBySelector( 'tr.row-selected'); if(rows.length == 1 || (!isSingleCityInformer() && rows.length > 1)) { for(var i = 0; i < rows.length; i++) { //$('list3body').appendChild(rows[i]); new Insertion.Bottom($('list3body'),rows[i]); rows[i].removeClassName('row-selected'); } $('messagebox').update(); if (informer_struct.type == 'graphic') $('informer').src = getInformerUrl() + flagTuneMode; else if (informer_struct.type == 'flash') updateFlashInformer('full') ; } else { $('messagebox').update(_strings.informer_one_city_only); } } function removeCities() { var rows = $('list3').getElementsBySelector( 'tr.row-selected'); if(rows.length > 0) { for(var i = 0; i < rows.length; i++) { //$('list2body').appendChild(rows[i]); //new Insertion.Top($('list2body'),rows[i]); rows[i].remove(); rows[i].removeClassName('row-selected'); } $('messagebox').innerHTML = ''; } if (informer_struct.type == 'graphic') $('informer').src = getInformerUrl() + flagTuneMode; else if (informer_struct.type == 'flash') updateFlashInformer('full') ; } function upCity() { var rows = $('list3').getElementsBySelector( 'tr.row-selected'); if(rows.length > 0) { var prev = rows[0].previousSibling; if(isDefined(prev)&&prev!=null) new Insertion.Before(prev,rows[0]); } $('informer').src = getInformerUrl() + flagTuneMode; } function downCity(){ var rows = $('list3').getElementsBySelector( 'tr.row-selected'); if(rows.length > 0) { var next = rows[0].nextSibling; if(isDefined(next)&&next!=null) new Insertion.After(next,rows[0]); } $('informer').src = getInformerUrl() + flagTuneMode; } /** * Get formatted URL gets from cities which are added to the list */ function getUrlCityList() { var citis = ''; var rows = $('list3body').childNodes; if(rows.length > 0) { for(var i = 0; i < rows.length; i++) { if (informer_struct.type == 'flash') { if (i == 0) citis += rows[i].getAttribute('rowid') ; else citis += ', ' + rows[i].getAttribute('rowid') ; } else if (informer_struct.type == 'graphic') citis += '&city[]='+rows[i].getAttribute('rowid'); } } return citis; } function getCitiesNamesM() { var names = ''; var rows = $('list3body').childNodes; if(rows.length > 0) { for(var i = 0; i < rows.length; i++) { names += rows[i].getAttribute('city_name_m') + ((i < rows.length-1)?', ':''); } } return names; } function checkCountry() { var curCountry ; if ($('checkcountry').checked) { //var country = $('list1').getElementsBySelector('tr.row-selected'); var rows = $('scrollrows1').childNodes; for(var i=0; i < rows.length; i++) { if ($(rows[i]).hasClassName('row-selected')) { curCountry = rows[i].getAttribute('rowid') ; break ; } } if (curCountry != curCountryInList1) { curCountryInList1 = curCountry; $('scrollrows3').update('') ; $('informer').src = getInformerUrl() + flagTuneMode; } else ; $('messagebox').update(_strings.informer_check_box_only_one_country); } else $('messagebox').update(''); return; } function isSingleCityInformer() { var ret = false; if(multipleCityTypes.indexOf(parseInt(type))==-1) ret = true; return ret; } Event.observe(window, 'load', function(event) { $('checkcountry').disabled = isSingleCityInformer(); if (informer_struct.type == 'graphic') { getInformerUrl(); } else if (informer_struct.type == 'flash') { updateFlashInformer('visible_code') ; } } ); var scroller1 = new Scrollbox({ contId:'cont1', listId:'list1', insertTo:'scrollrows1', prevButton:'prev_country', nextButton:'next_country' ,fetching:true, fromUrl:curl+'getcountries/', fetchParams:{search:searchCountryFilter}, gauge:'regauge_0' }); var scroller2 = new Scrollbox({ contId:'cont2', listId:'list2', insertTo:'list2body', prevButton:'prev_city', nextButton:'next_city' ,fetching:true, fromUrl:curl+'getcitiesbycountry/', fetchParams:{search:searchCountryFilter,country:countryFilter}, gauge:'regauge_1' }); var scroller3 = new Scrollbox({ contId:'cont3', listId:'list3', insertTo:'scrollrows3', prevButton:'prev_chosen', nextButton:'next_chosen' });