function CaTourInterface(map) { this.map = map; // map interface object this.isOnTrack; this.isOnPOI; this.urlIconTrack = 'http://www.cykloserver.cz/img/cyklo-ico-bod.gif'; this.urlIconTrackSel = 'http://www.cykloserver.cz/img/cyklo-ico-bod-a.gif'; this.urlIconTrackStart = 'http://www.cykloserver.cz/img/cyklo-ico-start.gif'; this.urlIconTrackStartSel = 'http://www.cykloserver.cz/img/cyklo-ico-start-a.gif'; this.urlIconTrackEnd = 'http://www.cykloserver.cz/img/cyklo-ico-cil.gif'; this.urlIconTrackEndSel = 'http://www.cykloserver.cz/img/cyklo-ico-cil-a.gif'; this.urlIconPOI = 'http://www.cykloserver.cz/img/cyklo-ico-poi.gif'; this.urlIconPOISel = 'http://www.cykloserver.cz/img/cyklo-ico-poi-a.gif'; this.iconTrack; this.iconPOI; this.geomPath; this.featurePath; this.stylePath; this.layerTour; this.layerPath; this.infoBox; this.httpRequest; this.httpRequest2; this.httpRequestElev; this.pointsTrack; this.pointsLastIdTrack; this.pointsCountTrack; this.pointsTrackOrder; this.pointsPOI; this.pointsLastIdPOI; this.pointsCountPOI; this.idPathLenght; this.idPathHeight; this.idImportWait; this.idProfile; this.idSaveCembaOnly; this.idSaveUpdateOnly; this.idSaveLoginSubmit; this.idSaveLoginRegister; this.idSaveLoginCancel; this.idSaveLoginError; this.idSaveLoginName; this.idSaveLoginPass; this.idSaveLoginBlock; this.idSaveBikeType; this.idSaveElev; this.idSaveDif; this.idSaveSubmit; this.idSaveCancel; this.idSaveError; this.idSaveUpdate0; this.idSaveUpdate1; this.idSaveUserInfo; this.idSaveTourName; this.idSaveTourStart; this.idSaveTourEnd; this.idSaveTourPlaces; this.idSaveTourDecription; this.idSaveTourVisible0; this.idSaveTourVisible1; this.idSaveTourCemba0; this.idSaveTourCemba1; this.idSaveDoneFinalLink; this.idSaveDonePhotoLink; this.idSaveDoneError; this.idSaveDone; this.idSaveDoneFinal; this.idPOIEditNameShow; this.idPOIEditNameEdit; this.idPOIEditNameDisplay; this.idPOIEditName; this.idPOIEditDescriptionShow; this.idPOIEditDescriptionEdit; this.idPOIEditDescriptionDisplay; this.idPOIEditDescription; this.contentIdTrack; this.contentIdPOI; this.idTrackSelect; this.idTrackInfo; this.idPOISelect; this.idPOIInfo; this.idPOIEdit; this.detailPOIId; this.rollbackQueue; this.timerCalHeight; this.colors; this.pathColor; this.pExportGPXDoSendRequest; this.pProfileCreateDoSendRequest; this.pProfileRevCreateDoSendRequest; this.pUpdatePathHeightFull; this.pUpdatePathHeightFullRequest; this.pPrintRequest; this.pSaveIsLoggedInRequest; this.pHideTrackCB; this.pHidePOICB; this.pSaveDoLogin; this.pSaveDoLoginRequest; this.pOpenRegistration; this.pCloseLogin; this.pSaveDoOwnerCheckRequest; this.pSaveDoSendRequest; this.pUpdateUserInputElevDifRequest; this.pSaveDoSend; this.pUpdateUserInputElevDif; this.pSaveHideUserInfo; this.pLoadInfoRequest; this.defaultDescription = 'Zájmový bod'; this.defaultName = 'Popis zájmového bodu'; this.txtErrorMessage; this.txtPOIUrl; this.txtPOIUrlSubmitFirst; this.txtChangePointNameTrack; this.txtAtLeastTwoForExport; this.txtAtLeastTwoForProfile; this.txtProfileError; this.txtUnableToExport; this.txtBack; this.txtInReverse; this.txtUnableToPreparePrint; this.txtAtLeastTwoForSave; this.txtMaxSavePart1; this.txtMaxSavePart2; this.txtCanNotCheckLogin; this.txtUnableToCheckAuthor; this.txtUnableToSave; this.txtUnableToPrepareData; this.txtUnableToLoadTourInfo; this.trackPointsLimit1; this.trackPointsLimit2; this.saveOverwrite; this.tourId; this.isTourAuthor; this.insertOpsSuspended; this.deleteOpsSuspended; this.pathTour; this.pathTourPhoto; this.hiProfile; this._create = function() { this.attachEvents(); } this.initialize = function() { this.isOn = false; this.insertOpsSuspended = false; this.deleteOpsSuspended = false;; this.tourId = 0; this.isTourAuthor = false; this.idTrackSelect = 'trasa_body_select'; this.idTrackInfo = 'trasa_info'; this.idPOISelect = 'poi_body_select'; this.idPOIInfo = 'poi_info'; this.idPOIEdit ='zajmovy_bod'; this.idPOIEditNameShow = 'zajmovy_bod_nazev_show'; this.idPOIEditNameEdit = 'zajmovy_bod_nazev_edit'; this.idPOIEditNameDisplay = 'zajmovy_bod_nazev_text'; this.idPOIEditName = 'zajmovy_bod_nazev'; this.idPOIEditDescriptionShow = 'zajmovy_bod_popis_show'; this.idPOIEditDescriptionEdit = 'zajmovy_bod_popis_edit'; this.idPOIEditDescriptionDisplay = 'zajmovy_bod_popis_text'; this.idPOIEditDescription = 'zajmovy_bod_popis'; this.idPathLenght = 'trasa_info_span'; this.idPathHeight = 'trasa_info_nastoupano_span'; this.idProfile = 'vyskovy_profil'; this.idSaveCembaOnly = 'ukladani_cemba_radio'; this.idSaveUpdateOnly = 'ukladani_update_radio'; this.idSaveLoginSubmit = 'login_submit'; this.idSaveLoginRegister = 'login_register'; this.idSaveLoginCancel = 'login_cancel'; this.idSaveLoginError = 'ukladani_login_chyba'; this.idSaveLoginName = 'login_name'; this.idSaveLoginPass = 'login_pw'; this.idSaveLoginBlock = 'ukladani_login'; this.idSaveBikeType = 'ukladani_kolo'; this.idSaveElev = 'ukladani_nastoupano'; this.idSaveDif = 'ukladani_obtiznost'; this.idSaveSubmit = 'ukladani_submit'; this.idSaveCancel = 'ukladani_cancel'; this.idSaveError = 'ukladani_chyba'; this.idSaveUpdate0 = 'ukladani_update_0'; this.idSaveUpdate1 = 'ukladani_update_1'; this.idSaveUserInfo = 'ukladani_user_info'; this.idSaveTourName = 'ukladani_nazev'; this.idSaveTourStart = 'ukladani_start'; this.idSaveTourEnd = 'ukladani_cil'; this.idSaveTourPlaces = 'ukladani_mista'; this.idSaveTourDecription = 'ukladani_popis'; this.idSaveTourVisible0 = 'ukladani_visible_0'; this.idSaveTourVisible1 = 'ukladani_visible_1'; this.idSaveTourCemba0 = 'ukladani_cemba_0'; this.idSaveTourCemba1 = 'ukladani_cemba_1'; this.idSaveDoneFinalLink = 'ukladani_done_final_link'; this.idSaveDonePhotoLink = 'ukladani_done_photo_link'; this.idSaveDoneError = 'ukladani_done_chyba'; this.idSaveDone = 'ukladani_done'; this.idSaveDoneFinal = 'ukladani_done_final'; this.contentIdTrack = 'infoblock_trasa'; this.contentIdPOI = 'infoblock_poi'; this.idImportWait = 'import_tracklogu_wait'; this.detailPOIId = null; this.httpRequest = null; this.pExportGPXDoSendRequest = jQuery.proxy(this.exportGPXDoSendRequest, this); this.pProfileCreateDoSendRequest = jQuery.proxy(this.profileCreateDoSendRequest, this); this.pProfileRevCreateDoSendRequest = jQuery.proxy(this.profileRevCreateDoSendRequest, this); this.pUpdatePathHeightFull = jQuery.proxy(this.updatePathHeightFull, this); this.pUpdatePathHeightFullRequest = jQuery.proxy(this.updatePathHeightFullRequest, this); this.pPrintRequest = jQuery.proxy(this.printRequest, this); this.pSaveIsLoggedInRequest = jQuery.proxy(this.saveIsLoggedInRequest, this); this.pHideTrackCB = jQuery.proxy(this.hideTrackCB, this); this.pHidePOICB = jQuery.proxy(this.hidePOICB, this); this.pSaveDoLogin = jQuery.proxy(this.saveDoLogin, this); this.pSaveDoLoginRequest = jQuery.proxy(this.saveDoLoginRequest, this); this.pOpenRegistration = jQuery.proxy(this.openRegistration, this); this.pCloseLogin = jQuery.proxy(this.closeLogin, this); this.pSaveDoOwnerCheckRequest = jQuery.proxy(this.saveDoOwnerCheckRequest, this); this.pSaveDoSendRequest = jQuery.proxy(this.saveDoSendRequest, this); this.pUpdateUserInputElevDifRequest = jQuery.proxy(this.updateUserInputElevDifRequest, this); this.pSaveDoSend = jQuery.proxy(this.saveDoSend, this); this.pUpdateUserInputElevDif = jQuery.proxy(this.updateUserInputElevDif, this); this.pSaveHideUserInfo = jQuery.proxy(this.saveHideUserInfo, this); this.pLoadInfoRequest = jQuery.proxy(this.loadInfoRequest, this); this.iconTrack = { externalGraphic: this.urlIconTrack, externalGraphicOrig: this.urlIconTrack, externalGraphicSel: this.urlIconTrackSel, externalGraphicStartOrig: this.urlIconTrackStart, externalGraphicStartSel: this.urlIconTrackStartSel, externalGraphicEndOrig: this.urlIconTrackEnd, externalGraphicEndSel: this.urlIconTrackEndSel, graphicWidth: 5, graphicHeight: 5, graphicStartWidth: 30, graphicStartHeight: 24, graphicEndWidth: 30, graphicEndHeight: 24, graphicXOffset: -3, graphicYOffset: -3, graphicStartXOffset: -15, graphicStartYOffset: -23, graphicEndXOffset: -15, graphicEndYOffset: -23, cursor: 'pointer' }; this.iconTrack.sizeNormal = new OpenLayers.Size(this.iconTrack.graphicWidth, this.iconTrack.graphicHeight); this.iconTrack.sizeStart = new OpenLayers.Size(this.iconTrack.graphicStartWidth, this.iconTrack.graphicStartHeight); this.iconTrack.sizeEnd = new OpenLayers.Size(this.iconTrack.graphicEndWidth, this.iconTrack.graphicEndHeight); this.iconTrack.offsetNormal = new OpenLayers.Pixel(this.iconTrack.graphicXOffset, this.iconTrack.graphicYOffset); this.iconTrack.offsetStart = new OpenLayers.Pixel(this.iconTrack.graphicStartXOffset, this.iconTrack.graphicStartYOffset); this.iconTrack.offsetEnd = new OpenLayers.Pixel(this.iconTrack.graphicEndXOffset, this.iconTrack.graphicEndYOffset); this.iconPOI = { externalGraphic: this.urlIconPOI, externalGraphicOrig: this.urlIconPOI, externalGraphicSel: this.urlIconPOISel, graphicWidth: 30, graphicHeight: 24, graphicXOffset: -15, graphicYOffset: -23, cursor: 'pointer' }; this.stylePath = { strokeColor: "#000000", strokeWidth: 7, strokeOpacity: 0.7 }; this.pointsTrack = {}; this.pointsLastIdTrack = -1; this.pointsCountTrack = 0; this.pointsTrackOrder = new Array(); this.pointsPOI = {}; this.pointsLastIdPOI = -1; this.pointsCountPOI = 0; // TODO: REMOVE NOT USED PATH VECTOR LAYER this.layerPath = new OpenLayers.Layer.Vector('OLCaLayerPath', {}); this.map.map.addLayer(this.layerPath); this.layerPath.div.style.zIndex = 550; this.layerPath.presetZIndex = 550; this.layerPath = this.map.vMarkersLayer; this.geomPath = new OpenLayers.Geometry.LineString([]); this.featurePath = new OpenLayers.Feature.Vector(this.geomPath, null, this.stylePath); this.featurePath.onMouseClick = this.onMouseClickPath; this.featurePath.cCaTour = this; this.layerPath.addFeatures([this.featurePath]); this.layerTour = new OpenLayers.Layer.Markers('OLCaLayerTour', {}); this.map.map.addLayer(this.layerTour); this.layerTour.div.style.zIndex = 700; this.layerTour.presetZIndex = 700; this.rollbackQueue = new Array(); this.colors = new Array(); this.colors.push('#189A9A'); this.colors.push('#49CFC9'); this.colors.push('#FC7646'); this.colors.push('#390079'); this.colors.push('#FFEA00'); this.selectPathColor(0); this.trackPointsLimit1 = 900; this.trackPointsLimit2 = 1000; this.attachEvents(); } this.onTrackChanged = function() { this.closeProfile(); } this.onKeyDelete = function(ev) { try { if (ev.target.tagName != 'INPUT') { if (ev.keyCode == 46) { this.onClickDeletePointTrack(); ev.stopPropagation(); ev.preventDefault(); return false; } } } catch (e) {}; } this.onClicGoDB = function() { window.location.href = document.getElementById(this.idSaveDoneFinalLink).href; return false; } this.onClicGoEditGalery = function() { window.location.href = document.getElementById(this.idSaveDonePhotoLink).href ; return false; } this.onClickHideSaveFinal = function() { document.getElementById(this.idSaveDoneFinal).style.display = 'none'; return false; } this.onClickEraseAll = function() { document.getElementById(this.idSaveDoneFinal).style.display = 'none'; this.deleteAllPointsTrack(); this.deleteAllPointsPOI(); return false; } this.blockUI = function() { $.blockUI({ css: { border: 'none', padding: '15px', backgroundColor: '#000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .5, color: '#fff' } }); } this.unblockUI = function() { $.unblockUI() } this.onClickSaveVylet = function(overwrite) { this.saveVylet(); return false; } this.saveVylet = function(overwrite) { if (this.pointsTrackOrder.length > 1) { if (this.pointsTrackOrder.length > this.trackPointsLimit2) { alert(this.txtMaxSavePart1 + " " + this.trackPointsLimit2 + " " + this.txtMaxSavePart2); } else { this.saveIsLoggedIn(overwrite); } } else { alert(this.txtAtLeastTwoForSave); } return false; } this.saveIsLoggedIn = function(overwrite) { this.saveOverwrite = overwrite; url = "http://www.cykloserver.cz/cykloatlas/isloggedin.php"; if (window.ActiveXObject) { this.httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest = new XMLHttpRequest(); } this.httpRequest.open("GET", url, true); this.httpRequest.onreadystatechange = this.pSaveIsLoggedInRequest; this.httpRequest.send(null); this.blockUI(); } this.saveIsLoggedInRequest = function() { if (this.httpRequest.readyState == 4) { if (this.httpRequest.status == 200) { this.unblockUI(); if (doc = this.httpRequest.responseXML) { if (doc.getElementsByTagName("isloggedin")[0].firstChild.data != "1") { this.saveShowLogin(); } else { if (doc.getElementsByTagName("iscemba")[0].firstChild.data != "1") { document.getElementById(this.idSaveCembaOnly).style.display = "none"; } else { document.getElementById(this.idSaveCembaOnly).style.display = "block"; } try { if (this.tourId) { this.saveDoOwnerCheck(this.tourId); } else { document.getElementById(this.idSaveUpdateOnly).style.display = "none"; this.saveShowUserInput(); } } catch (e) { document.getElementById(this.idSaveUpdateOnly).style.display = "none"; this.saveShowUserInput(); } } } else alert(this.txtCanNotCheckLogin); } } } this.saveShowLogin = function() { document.getElementById(this.idSaveLoginSubmit).onclick = this.pSaveDoLogin; document.getElementById(this.idSaveLoginRegister).onclick = this.pOpenRegistration; document.getElementById(this.idSaveLoginCancel).onclick = this.pCloseLogin; document.getElementById(this.idSaveLoginError).style.display = "none"; document.getElementById(this.idSaveLoginName).value = ""; document.getElementById(this.idSaveLoginPass).value = ""; document.getElementById(this.idSaveLoginBlock).style.display = "block"; } this.closeLogin = function() { document.getElementById(this.idSaveLoginBlock).style.display = "none"; } this.openRegistration = function() { window.open('http://www.cykloserver.cz/uzivatel/registrace/'); } this.saveDoLogin = function() { document.getElementById(this.idSaveLoginBlock).style.display = "none"; url = "login.php?u=" + document.getElementById(this.idSaveLoginName).value + "&p=" + document.getElementById(this.idSaveLoginPass).value; if (window.ActiveXObject) { this.httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest = new XMLHttpRequest(); } this.httpRequest.open("GET", url, true); this.httpRequest.onreadystatechange = this.pSaveDoLoginRequest; this.httpRequest.send(null); this.blockUI(); } this.saveDoLoginRequest = function() { if (this.httpRequest.readyState == 4) { if (this.httpRequest.status == 200) { this.unblockUI(); if (doc = this.httpRequest.responseXML) { if (doc.getElementsByTagName("isloggedin")[0].firstChild.data != "1") { this.saveShowLogin(); document.getElementById(this.idSaveLoginError).style.display = "block"; } else { if (doc.getElementsByTagName("iscemba")[0].firstChild.data != "1") { document.getElementById(this.idSaveCembaOnly).style.display = "none"; } else { document.getElementById(this.idSaveCembaOnly).style.display = "block"; } try { if (this.tourId) { this.saveDoOwnerCheck(this.tourId); } else { document.getElementById(this.idSaveUpdateOnly).style.display = "none"; this.saveShowUserInput(); } } catch (e) { document.getElementById(this.idSaveUpdateOnly).style.display = "none"; this.saveShowUserInput(); } } } else alert(this.txtCanNotCheckLogin); } } } this.saveDoOwnerCheck = function(id) { url = "checkowner.php?id=" + id; if (window.ActiveXObject) { this.httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest = new XMLHttpRequest(); } this.httpRequest.open("GET", url, true); this.httpRequest.onreadystatechange = this.pSaveDoOwnerCheckRequest; this.httpRequest.send(null); this.blockUI(); } this.saveDoOwnerCheckRequest = function() { if (this.httpRequest.readyState == 4) { if (this.httpRequest.status == 200) { this.unblockUI(); if (doc = this.httpRequest.responseXML) { if (doc.getElementsByTagName("isowner")[0].firstChild.data != "1") { document.getElementById(this.idSaveUpdateOnly).style.display = "none"; } else { document.getElementById(this.idSaveUpdateOnly).style.display = "block"; if (this.saveOverwrite) { this.loadInfo(); } } this.saveShowUserInput(); } else alert(this.txtUnableToCheckAuthor); } } } this.showSaveError = function(str) { document.getElementById(this.idSaveDoneError).innerHTML = str; } this.loadInfo = function() { var url = "loadinfo.php?id=" + this.tourId; if (window.ActiveXObject) { this.httpRequest2 = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest2 = new XMLHttpRequest(); } this.httpRequest2.open("GET", url, true); this.httpRequest2.onreadystatechange = this.pLoadInfoRequest; this.httpRequest2.send(null); this.blockUI(); return true; } this.loadInfoRequest = function() { if (this.httpRequest2.readyState == 4) { if (this.httpRequest2.status == 200) { this.unblockUI(); if (doc = this.httpRequest2.responseXML) { if (doc.getElementsByTagName("isowner")[0].firstChild.data != "1") { } else { document.getElementById(this.idSaveTourName).value = this.itemDecode(doc.getElementsByTagName("nazev")[0].firstChild.data); try { document.getElementById(this.idSaveTourStart).value = this.itemDecode(doc.getElementsByTagName("start")[0].firstChild.data); } catch (e) { document.getElementById(this.idSaveTourStart).value = ""; } try { document.getElementById(this.idSaveTourEnd).value = this.itemDecode(doc.getElementsByTagName("cil")[0].firstChild.data); } catch (e) { document.getElementById(this.idSaveTourEnd).value = ""; } try { document.getElementById(this.idSaveTourPlaces).value = this.itemDecode(doc.getElementsByTagName("mista")[0].firstChild.data); } catch (e) { document.getElementById(this.idSaveTourPlaces).value = ""; } var idkolo = this.itemDecode(doc.getElementsByTagName("id_kolo")[0].firstChild.data); for (var ti = 0; ti < document.getElementById(this.idSaveBikeType).options.length; ti++) { if (document.getElementById(this.idSaveBikeType).options[ti].value == idkolo) document.getElementById(this.idSaveBikeType).selectedIndex = ti; } try { var popis = this.itemDecode(doc.getElementsByTagName("popis")[0].firstChild.data); } catch (e) { var popis = ""; } var popis = this.itemDecode(popis); popis = popis.replace(/%#P#%/g, " ").replace(/%#\/P#%/g, " ").replace(/%#BR#%/g, " ").replace(/%#STRONG#%/g, " ").replace(/%#\/STRONG#%/g, " ").replace(/%#U#%/g, " ").replace(/%#\/U#%/g, " ").replace(/%#STRIKE#%/g, " ").replace(/%#\/STRIKE#%/g, " ").replace(/%#EM#%/g, " ").replace(/%#\/EM#%/g, " "); popis = popis.replace(/

/g, "%#P#%").replace(/<\/p>/g, "%#/P#%").replace(/
/g, "%#BR#%").replace(//g, "%#BR#%").replace(/
/g, "%#BR#%").replace(//g, "%#STRONG#%").replace(/<\/strong>/g, "%#/STRONG#%").replace(//g, "%#U#%").replace(/<\/u>/g, "%#/U#%").replace(//g, "%#STRIKE#%").replace(/<\/strike>/g, "%#/STRIKE#%").replace(//g, "%#EM#%").replace(/<\/em>/g, "%#/EM#%"); popis = popis.replace(//g, ">"); popis = popis.replace(/%#P#%/g, "

").replace(/%#\/P#%/g, "

").replace(/%#BR#%/g, "
").replace(/%#STRONG#%/g, "").replace(/%#\/STRONG#%/g, "").replace(/%#U#%/g, "").replace(/%#\/U#%/g, "").replace(/%#STRIKE#%/g, "").replace(/%#\/STRIKE#%/g, "").replace(/%#EM#%/g, "").replace(/%#\/EM#%/g, ""); FCKeditorAPI.GetInstance(this.idSaveTourDecription).SetHTML(popis); if (doc.getElementsByTagName("visible")[0].firstChild.data == 1) { document.getElementById(this.idSaveTourVisible1).checked = true; } else { document.getElementById(this.idSaveTourVisible0).checked = true; } if (doc.getElementsByTagName("cembaonly")[0].firstChild.data == 1) { document.getElementById(this.idSaveTourCemba1).checked = true; } else { document.getElementById(this.idSaveTourCemba0).checked = true; } } } else alert(this.txtUnableToLoadTourInfo); } } } this.updateUserInputElevDif = function() { var paramsa = new Array(); paramsa.push("v_type=" + document.getElementById(this.idSaveBikeType).value); paramsa.push("&v_points="); for (var x = 0; x < this.pointsTrackOrder.length; x++) { if (x > 0) paramsa.push("|"); paramsa.push(this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lng.toFixed(8) + ":" + this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lat.toFixed(8)); } var params = paramsa.join(""); url = "preprocessvylet.php"; if (window.ActiveXObject) { this.httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest = new XMLHttpRequest(); } this.httpRequest.open("POST", url, true); this.httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); this.httpRequest.setRequestHeader("Content-length", params.length); this.httpRequest.setRequestHeader("Connection", "close"); this.httpRequest.onreadystatechange = this.pUpdateUserInputElevDifRequest; this.httpRequest.send(params); this.blockUI(); } this.updateUserInputElevDifRequest = function() { if (this.httpRequest.readyState == 4) { if (this.httpRequest.status == 200) { this.unblockUI(); if (doc = this.httpRequest.responseXML) { if (doc.getElementsByTagName("error")[0].firstChild.data != "0") { alert(this.txtUnableToPrepareData); } else { document.getElementById(this.idSaveElev).value = doc.getElementsByTagName("elev")[0].firstChild.data; document.getElementById(this.idSaveDif).selectedIndex = doc.getElementsByTagName("dif")[0].firstChild.data; } } else alert(this.txtUnableToPrepareData); } else { alert(this.txtUnableToPrepareData); } } } this.saveHideUserInfo = function() { document.getElementById(this.idSaveUserInfo).style.display = "none"; } this.saveShowUserInput = function() { this.updateUserInputElevDif(); document.getElementById(this.idSaveSubmit).onclick = this.pSaveDoSend; document.getElementById(this.idSaveBikeType).onchange = this.pUpdateUserInputElevDif; document.getElementById(this.idSaveCancel).onclick = this.pSaveHideUserInfo; document.getElementById(this.idSaveError).style.display = "none"; if (this.saveOverwrite) { document.getElementById(this.idSaveUpdate1).checked = true; } else { document.getElementById(this.idSaveUpdate0).checked = true; } if (this.isTourAuthor) document.getElementById(this.idSaveUpdate1).checked = true; this.loadInfo(); document.getElementById(this.idSaveUserInfo).style.display = "block"; } this.saveDoSend = function() { var url = "processvylet.php"; var params = ""; if (document.getElementById(this.idSaveUpdate1).checked) params+= "id=" + this.tourId; params+= "&v_elev=" + document.getElementById(this.idSaveElev).value; params+= "&v_dif=" + document.getElementById(this.idSaveDif).selectedIndex; params+= "&v_start=" + document.getElementById(this.idSaveTourStart).value.replace(/&/g, "*amp*").replace(/=/g, "*eq*"); params+= "&v_cil=" + document.getElementById(this.idSaveTourEnd).value.replace(/&/g, "*amp*").replace(/=/g, "*eq*"); params+= "&v_mista=" + document.getElementById(this.idSaveTourPlaces).value.replace(/&/g, "*amp*").replace(/=/g, "*eq*"); params+= "&v_kolo=" + document.getElementById(this.idSaveBikeType).value.replace(/&/g, "*amp*").replace(/=/g, "*eq*"); var popis = ""; try{ popis = FCKeditorAPI.GetInstance(this.idSaveTourDecription).GetHTML(); }catch(e){ popis = document.getElementsByName(this.idSaveTourDecription)[0].value; } params+= "&v_popis=" + popis.replace(/&/g, "*amp*").replace(/=/g, "*eq*"); if (document.getElementById(this.idSaveTourVisible0).checked) { params+= "&v_onlyautor=1"; } else { params+= "&v_onlyautor=0"; } if (document.getElementById(this.idSaveTourCemba1).checked) { params+= "&v_onlycemba=1"; } else { params+= "&v_onlycemba=0"; } params+= "&v_points="; for (var x = 0; x < this.pointsTrackOrder.length; x++) { if (x > 0) params+= "|"; var n= ''; if (this.pointsTrack[this.pointsTrackOrder[x]].marker.pointName.length) { n = this.pointsTrack[this.pointsTrackOrder[x]].marker.pointName.replace(/&/g, "*amp*"); n = n.replace(/=/g, "*eq*"); n = n.replace(/\|/g, "*div*"); n = n.replace(/;/g, "*semi*"); n = n.replace(/\:/g, "%col%"); }; params+= this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lng.toFixed(8) + ":" + this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lat.toFixed(8) + ":" + n; } if (this.pointsCountPOI > 0) { //params+= "&v_poi="; var v_poi = new Array(); var x = 0; var key; for (key in this.pointsPOI) { if (this.pointsPOI.hasOwnProperty(key)) { /*if (x > 0) params+= "|"; var nazev = this.pointsPOI[key].marker.pointName.replace(/&/g, '*amp*'); nazev = nazev.replace(/=/g, '*eq*'); nazev = nazev.replace(/\|/g, '*div*'); nazev = nazev.replace(/;/g, '*semi*'); nazev = nazev.replace(/\:/g, '%col%'); var popis = this.pointsPOI[key].marker.pointDescription.replace(/&/g, '*amp*'); popis = popis.replace(/=/g, '*eq*'); popis = popis.replace(/\|/g, '*div*'); popis = popis.replace(/;/g, '*semi*'); popis = popis.replace(/\:/g, '%col%'); params+= this.pointsPOI[key].marker.posLatLng.lng + ':' + this.pointsPOI[key].marker.posLatLng.lat + ':' + nazev + ';' + popis; */ v_poi.push({ 'nazev':this.pointsPOI[key].marker.pointName, 'popis':this.pointsPOI[key].marker.pointDescription, 'lat':this.pointsPOI[key].marker.posLatLng.lat, 'lon':this.pointsPOI[key].marker.posLatLng.lng }); x++; } } params+= "&v_poi2=" + encodeURIComponent(JSON.stringify(v_poi)); } params+= "&v_nazev=" + document.getElementById(this.idSaveTourName).value.replace(/&/g, "*amp*").replace(/=/g, "*eq*"); params+= "&v_barva=" + this.pathColor; if (window.ActiveXObject) { this.httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest = new XMLHttpRequest(); } this.httpRequest.open("POST", url, true); this.httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); this.httpRequest.setRequestHeader("Content-length", params.length); this.httpRequest.setRequestHeader("Connection", "close"); this.httpRequest.onreadystatechange = this.pSaveDoSendRequest; this.httpRequest.send(params); this.blockUI(); } this.saveDoSendRequest = function() { if (this.httpRequest.readyState == 4) { if (this.httpRequest.status == 200) { this.unblockUI(); if (doc = this.httpRequest.responseXML) { if (doc.getElementsByTagName("error")[0].firstChild.data != "0") { document.getElementById(this.idSaveError).innerHTML = doc.getElementsByTagName("errordesc")[0].firstChild.data; this.saveShowUserInput(); document.getElementById(this.idSaveError).style.display = "block"; } else { var newitemid = doc.getElementsByTagName("newitemid")[0].firstChild.data; document.forms[2].action = "inserttnolm.php?id=" + newitemid; document.getElementById(this.idSaveError).innerHTML = ""; document.getElementById(this.idSaveError).style.display = "none"; document.getElementById(this.idSaveUserInfo).style.display = "none"; document.getElementById(this.idSaveDoneFinalLink).href = this.pathTour + newitemid; document.getElementById(this.idSaveDonePhotoLink).href = this.pathTourPhoto + newitemid + "#galerie"; document.getElementById(this.idSaveDoneError).innerHTML = ""; document.getElementById(this.idSaveDone).style.display = "block"; } } else alert(this.txtUnableToSave); } } } this.saveThumb = function() { document.forms[2].target = "ulframe"; document.forms[2].method = "post"; document.forms[2].encoding = "multipart/form-data"; //document.forms[2].action = "inserttnolm.php?id=" + newitemid; document.forms[2].submit(); return false; } this.saveFinal = function() { document.getElementById(this.idSaveDone).style.display = "none"; document.getElementById(this.idSaveDoneError).innerHTML = ""; document.getElementById(this.idSaveDoneFinal).style.display = "block"; return false; } this.onClickPrint = function() { this.print(); return false; } this.print = function() { var urls = 'http://www.cykloserver.cz/cykloatlas/print.php?set=1'; var bbox = this.map.getBoundsObj(); var zoomlevel = this.map.getZoom(); var res = this.map.map.getResolution(); var ext = this.map.map.getExtent(); var x1 = Math.round((ext.left - this.map.map.maxExtent.left) / res); var y1 = Math.round((this.map.map.maxExtent.top - ext.top) / res); var x2 = Math.round((ext.right - this.map.map.maxExtent.left) / res); var y2 = Math.round((this.map.map.maxExtent.top - ext.bottom) / res); var url = "bbox=" + x1 + "," + y1 + "," + x2 + "," + y2; url+= "&bboxgps=" + bbox.left + "," + bbox.bottom + "," + bbox.right + "," + bbox.top; url+= "&zoom=" + zoomlevel; if (this.map.isOnCyklo) { url+= "&maptype=1"; } else if (this.map.isOnWinter) { url+= "&maptype=2"; } if (this.map.cCaUtils.isOnLayerSHOCart1) url+= "&klad1=1"; if (this.map.cCaUtils.isOnLayerSHOCart2) url+= "&klad2=1"; if (this.map.isOnRelief) url+= "&relief=1"; url+= "&v_barva=" + this.pathColor; if (this.pointsTrackOrder.length) { url+= "&v_points="; for (var x = 0; x < this.pointsTrackOrder.length; x++) { var pix_x = Math.round((this.pointsTrack[this.pointsTrackOrder[x]].marker.lonlat.lon - this.map.map.maxExtent.left) / res); var pix_y = Math.round((this.map.map.maxExtent.top - this.pointsTrack[this.pointsTrackOrder[x]].marker.lonlat.lat) / res); if (x > 0) url+= ","; url+= Math.round(pix_x) + ":" + Math.round(pix_y); } } if (this.pointsCountPOI > 0) { url+= "&v_poi="; var x = 0; var key; for (key in this.pointsPOI) { if (this.pointsPOI.hasOwnProperty(key)) { if (x > 0) url+= "|"; var pix_x = Math.round((this.pointsPOI[key].marker.lonlat.lon - this.map.map.maxExtent.left) / res); var pix_y = Math.round((this.map.map.maxExtent.top - this.pointsPOI[key].marker.lonlat.lat) / res); url+= Math.round(pix_x) + ":" + Math.round(pix_y); x++; } } } if (window.ActiveXObject) { this.httpRequest2 = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest2 = new XMLHttpRequest(); } this.httpRequest2.open("POST", urls, true); this.httpRequest2.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); this.httpRequest2.setRequestHeader("Content-length", url.length); this.httpRequest2.setRequestHeader("Connection", "close"); this.httpRequest2.onreadystatechange = this.pPrintRequest; this.httpRequest2.send(url); return false; } this.printRequest = function() { if (this.httpRequest2.readyState == 4) { if (this.httpRequest2.status == 200) { if (this.httpRequest2.responseText == "OK") { var url = "print.php"; window.open(url, "_blank"); } else { alert(this.txtUnableToPreparePrint); } } } } this.updatePathHeight = function() { if (this.timerCalHeight) { clearTimeout(this.timerCalHeight); } this.timerCalHeight = setTimeout(this.pUpdatePathHeightFull, 3000); } this.updatePathHeightFull = function() { if (this.pointsTrackOrder.length > 1) { var coordsa = new Array(); for (var x = 0; x < this.pointsTrackOrder.length; x++) { coordsa.push(this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lat.toFixed(8)); coordsa.push(this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lng.toFixed(8)); } var coords = ""; coords = 'c=' + coordsa.join(','); url = 'http://www.cykloserver.cz/cykloatlas/nastoupanocalc2.php'; if (window.ActiveXObject) { this.httpRequestElev = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequestElev = new XMLHttpRequest(); } this.httpRequestElev.open("POST", url, true); this.httpRequestElev.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); this.httpRequestElev.setRequestHeader("Content-length", coords.length); this.httpRequestElev.setRequestHeader("Connection", "close"); this.httpRequestElev.onreadystatechange = this.pUpdatePathHeightFullRequest; this.httpRequestElev.send(coords); } else { document.getElementById(this.idPathHeight).innerHTML = "0 (" + this.txtBack + " 0)"; } } this.updatePathHeightFullRequest = function() { if (this.httpRequestElev.readyState == 4) { if (this.httpRequestElev.status == 200) { var parts = this.httpRequestElev.responseText.split(":"); if (parts.length != 2) { document.getElementById(this.idPathHeight).innerHTML = "0 (" + this.txtBack + " 0)"; } else { var parts2 = parts[1].split("|"); document.getElementById(this.idPathHeight).innerHTML = "" + parts2[0] + ' (' + this.txtBack + ' ' + parts2[1] + ')'; } } } } this.updatePathLength = function() { var l = 0; if (this.pointsTrackOrder.length > 1) l = this.geomPath.getGeodesicLength(this.map.projection); if (l > 1000) { l = (l / 1000).toFixed(3); l = l + " km"; } else { l = l.toFixed(0); l = l + " m"; } if (document.getElementById(this.idPathLenght)) document.getElementById(this.idPathLenght).innerHTML = l; } this.onClickImportSend = function() { this.importSend(); return false; } this.importSend = function() { document.forms[1].target = 'ulframe'; document.forms[1].method = 'post'; document.forms[1].encoding = 'multipart/form-data'; document.forms[1].action = 'importolm.php'; document.forms[1].submit(); document.getElementById(this.idImportWait).style.display = 'block'; } this.exportGPX = function() { this.exportGPXDoSend(false); return false; } this.profileCreate = function() { this.profileCreateDoSend(false); return false; } this.profileCreateRev = function() { this.profileCreateDoSend(true); return false; } this.exportGPXDoSend = function() { if (this.pointsTrackOrder.length > 1) { var coordsa = new Array(); var coordsai = -1; for (var x = 0; x < this.pointsTrackOrder.length; x++) { if ((x % 50) == 0) { coordsai++; coordsa[coordsai] = new Array(); } if (x > 0) coordsa[coordsai].push("|"); coordsa[coordsai].push(this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lng.toFixed(5)); coordsa[coordsai].push(":"); coordsa[coordsai].push(this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lat.toFixed(5)); if (this.pointsTrack[this.pointsTrackOrder[x]].marker.pointName.length) { coordsa[coordsai].push(":"); coordsa[coordsai].push(this.pointsTrack[this.pointsTrackOrder[x]].marker.pointName.replace(/#/g, "").replace(/\|/g, "").replace(/\?/g, "").replace(/\&/g, "").replace(/;/g, "*semi*")); } } var coords = ""; var coordsaj = new Array(); for (var x = 0; x <= coordsai; x++) { coordsaj[x] = new Array(); coordsaj[x] = coordsa[x].join(""); } coords = coordsaj.join(""); var coordsa = new Array(); var coordsai = -1; var poicoords = ""; var x = 0; if (this.pointsCountPOI > 0) { var key; for (key in this.pointsPOI) { if (this.pointsPOI.hasOwnProperty(key)) { if ((x % 50) == 0) { coordsai++; coordsa[coordsai] = new Array(); } if (x > 0) coordsa[coordsai].push("|"); nazev = this.pointsPOI[key].marker.pointName.replace(/&/g, '*amp*'); nazev = nazev.replace(/=/g, '*eq*'); nazev = nazev.replace(/\|/g, '*div*'); nazev = nazev.replace(/;/g, '*semi*'); nazev = nazev.replace(/\:/g, '*col*'); popis = this.pointsPOI[key].marker.pointDescription.replace(/&/g, '*amp*'); popis = popis.replace(/=/g, '*eq*'); popis = popis.replace(/\|/g, '*div*'); popis = popis.replace(/;/g, '*semi*'); popis = popis.replace(/\:/g, '*col*'); coordsa[coordsai].push(this.pointsPOI[key].marker.posLatLng.lng + ':' + this.pointsPOI[key].marker.posLatLng.lat + ':' + nazev + ';' + popis); } x++; } var coordsaj = new Array(); for (var x = 0; x <= coordsai; x++) { coordsaj[x] = new Array(); coordsaj[x] = coordsa[x].join(""); } poicoords = coordsaj.join(""); } else { poicoords = ""; } var url = "processexport.php"; var params = "line=" + coords + "&pois=" + poicoords + ""; if (window.ActiveXObject) { this.httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { this.httpRequest = new XMLHttpRequest(); } this.httpRequest.open("POST", url, true); this.httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); this.httpRequest.setRequestHeader("Content-length", params.length); this.httpRequest.setRequestHeader("Connection", "close"); this.httpRequest.onreadystatechange = this.pExportGPXDoSendRequest; this.httpRequest.send(params); this.blockUI(); } else alert(this.txtAtLeastTwoForExport); } this.closeProfile = function() { if (this.hiProfile) { this.hiProfile.close(); this.hiProfile = null; } } this.profileCreateDoSend = function(rev) { if (this.hiProfile) this.hiProfile.close(); if (this.pointsTrackOrder.length > 1) { var path = []; var lStart = 0; var lStop = this.pointsTrackOrder.length; var lInc = 1; if (rev) { var lStart = this.pointsTrackOrder.length - 1; var lStop = -1; var lInc = -1; } for (var x = lStart; x != lStop; x+= lInc) { var point = [this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lat.toFixed(5), this.pointsTrack[this.pointsTrackOrder[x]].marker.posLatLng.lng.toFixed(5)]; if (this.pointsTrack[this.pointsTrackOrder[x]].marker.pointName.length) { point.push(this.pointsTrack[this.pointsTrackOrder[x]].marker.pointName); } path.push(point); } this.hiProfile = new HiProfile({ elProfileContainer:document.getElementById(this.idProfile), path:path, requestUrl:'http://www.cykloserver.cz/cykloatlas/hiprofile.php', map:this.map, hide:true, show:true }); this.hiProfile.getProfile(); //this.blockUI(); } else alert(this.txtAtLeastTwoForProfile); } this.exportGPXDoSendRequest = function() { if (this.httpRequest.readyState == 4) { if (this.httpRequest.status == 200) { this.unblockUI(); if (doc = this.httpRequest.responseXML) { if (doc.getElementsByTagName("error")[0].firstChild.data != "0") { alert(this.txtUnableToExport); } else { url = "http://www.cykloserver.cz/cykloatlas/processexport.php?cre=1&r=" + Math.round(Math.random()*1000000); window.location.href = url; } } else alert(this.txtUnableToExport); } } } this.onClickSelectPathColor = function(colId) { this.selectPathColor(colId); return false; } this.selectPathColor = function(colId) { this.pathColor = colId; if (document.getElementById(this.idTrackSelect)) { for (var ti = 0; ti < this.colors.length; ti++) { if (ti == colId) { document.getElementById('trasa_barva_button_' + ti).style.borderColor = '#000000'; } else { document.getElementById('trasa_barva_button_' + ti).style.borderColor = '#FFFFFF'; } } } this.stylePath.strokeColor = this.colors[colId]; this.refreshPath(); } this.onMapClick = function(ev) { if ((this.isOnTrack) || (this.isOnPOI)) { var ll = this.map.getLatLngFromPixel(ev.xy); if (this.isOnTrack) { this.rollbackQueue.push({ type: 'deletePoint', index: this.pointsTrackOrder.length }); this.addPointTrack(ll, '', -1); } else if (this.isOnPOI) { this.addPointPOI(ll); } } return false; } this.addPointTrack = function(pos, name, insertAt) { var point = this.createPointTrack(pos, name, insertAt); if (insertAt == -1) { this.geomPath.addComponent(this.map.pointFromLatLng(point.marker.posLatLng)); } else { this.geomPath.addComponent(this.map.pointFromLatLng(point.marker.posLatLng), insertAt); } if (!this.insertOpsSuspended) { if ((insertAt == -1) || (insertAt == this.pointsTrackOrder.length - 1)) { if (this.pointsTrackOrder.length > 1) { point.marker.setPointType('end'); if (this.pointsTrackOrder.length > 2) { this.pointsTrack[this.pointsTrackOrder[this.pointsTrackOrder.length - 2]].marker.setPointType('normal'); } } } if (((insertAt == -1) && (this.pointsTrackOrder.length == 1)) || (insertAt == 0)) { this.pointsTrack[this.pointsTrackOrder[0]].marker.setPointType('start'); if (this.pointsTrackOrder.length == 2) { this.pointsTrack[this.pointsTrackOrder[1]].marker.setPointType('end'); } else if (this.pointsTrackOrder.length > 2) { this.pointsTrack[this.pointsTrackOrder[1]].marker.setPointType('normal'); } } if (document.getElementById(this.idTrackSelect)) { var indexPos = insertAt; if (insertAt == -1) indexPos = document.getElementById(this.idTrackSelect).length - 1; document.getElementById(this.idTrackSelect).selectedIndex = indexPos; this.onChangeSelectionTrack(); } this.updatePathLength(); this.updatePathHeight(); this.refreshPath(); } this.onTrackChanged(); } this.refreshPath = function(isForced) { this.layerPath.removeFeatures([this.featurePath]); if ((this.geomPath.getVertices().length != this.pointsCountTrack) || (isForced)) { this.featurePath.destroy(); this.geomPath = new OpenLayers.Geometry.LineString([]); this.featurePath = new OpenLayers.Feature.Vector(this.geomPath, null, this.stylePath); this.featurePath.onMouseClick = this.onMouseClickPath; this.featurePath.cCaTour = this; if (this.pointsTrackOrder.length) { for (var ti = 0; ti < this.pointsTrackOrder.length; ti++) { this.geomPath.addComponent(this.map.pointFromLatLng(this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng)); } } } this.layerPath.addFeatures([this.featurePath]); } this.onMouseClickPath = function(ev) { if (this.cCaTour.isOnTrack) { this.cCaTour.clickPath(ev); } } this.clickPath = function(ev) { var ll = this.map.getLatLngFromLonLat(ev.ll); var lastlat = this.pointsTrack[this.pointsTrackOrder[0]].marker.posLatLng.lat; var lastlng = this.pointsTrack[this.pointsTrackOrder[0]].marker.posLatLng.lng; var minx, maxx, miny, maxy; var susp = -1; var suspd = 1000; for (var ti = 1; ti < this.pointsTrackOrder.length; ti++) { if (this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lng < lastlng) { minx = this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lng; maxx = lastlng; } else { minx = lastlng; maxx = this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lng; } if (this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lat < lastlat) { miny = this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lat; maxy = lastlat; } else { miny = lastlat; maxy = this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lat; } if ((ll.lat >= miny) && (ll.lat <= maxy) && (ll.lng >= minx) && (ll.lng <= maxx)) { var a = -1 * (this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lat - lastlat); var b = this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lng - lastlng; var c = -1 * (a * lastlng + b * lastlat); var d = Math.abs(a * ll.lng + b * ll.lat + c) / Math.sqrt(a * a + b * b); if (d < suspd) { susp = ti; suspd = d; } } var lastlat = this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lat; var lastlng = this.pointsTrack[this.pointsTrackOrder[ti]].marker.posLatLng.lng; } this.rollbackQueue.push({ type: 'deletePoint', index: susp }); this.addPointTrack(ll, '', susp); } this.createPointTrack = function(pos, name, insertAt) { var marker = this.createMarkerTrack(pos); marker.setName(name); var point = { marker: marker }; this.layerTour.addMarker(marker); marker.olmLayerAdded = this.layerTour; this.pointsLastIdTrack++; var pointId = 'c' + this.pointsLastIdTrack; point.pointId = pointId; point.marker.pointId = pointId; this.pointsCountTrack++; this.pointsTrack[pointId] = point; if (insertAt == -1) { this.pointsTrackOrder.push(pointId); } else { this.pointsTrackOrder.splice(insertAt, 0, pointId); } if (document.getElementById(this.idTrackSelect)) { if (insertAt == -1) { document.getElementById(this.idTrackSelect).options[this.pointsCountTrack - 1] = new Option(this.pointsCountTrack + ". " + name, pointId); } else { this.refreshSelectTrack(); } } return point; } this.onClickDeletePointTrack = function() { if (document.getElementById(this.idTrackSelect)) { if (document.getElementById(this.idTrackSelect).selectedIndex != -1) { var i = document.getElementById(this.idTrackSelect).selectedIndex; var id = document.getElementById(this.idTrackSelect).options[document.getElementById(this.idTrackSelect).selectedIndex].value; this.rollbackQueue.push({ type: 'addPoint', pos: this.pointsTrack[id].marker.posLatLng, name: this.pointsTrack[id].marker.pointName, index: i }); this.deletePointTrack(id); this.refreshSelectTrack(); if (document.getElementById(this.idTrackSelect)) { var indexPos = i - 1; if (indexPos < 0) indexPos = 0; if (document.getElementById(this.idTrackSelect).length > indexPos) { document.getElementById(this.idTrackSelect).selectedIndex = indexPos; this.onChangeSelectionTrack(); } } } } return false; } this.deletePointTrack = function(id) { this.layerTour.removeMarker(this.pointsTrack[id].marker); delete this.pointsTrack[id]; var indexPos = this.pointsTrackOrder.indexOf(id); this.pointsTrackOrder.splice(indexPos, 1); this.pointsCountTrack--; if (!this.deleteOpsSuspended) { this.refreshPath(); if (this.pointsTrackOrder.length) { this.pointsTrack[this.pointsTrackOrder[this.pointsTrackOrder.length - 1]].marker.setPointType('end'); this.pointsTrack[this.pointsTrackOrder[0]].marker.setPointType('start'); } this.updatePathLength(); this.updatePathHeight(); } this.onTrackChanged(); } this.onClickDeleteAllPointsTrack = function() { this.deleteAllPointsTrack(); return false; } this.deleteAllPointsTrack = function() { var key; this.deleteOpsSuspended = true; for (key in this.pointsTrack) { if (this.pointsTrack.hasOwnProperty(key)) this.deletePointTrack(key); } this.deleteOpsSuspended = false; this.refreshSelectTrack(); this.refreshPath(); this.resetRollbackQueue(); this.updatePathLength(); this.updatePathHeight(); this.onTrackChanged(); } this.refreshSelectTrack = function() { if (document.getElementById(this.idTrackSelect)) { while (document.getElementById(this.idTrackSelect).length) document.getElementById(this.idTrackSelect).remove(0); if (this.pointsTrackOrder.length) { for (var ti = 0; ti < this.pointsTrackOrder.length; ti++) { document.getElementById(this.idTrackSelect).add(new Option((ti + 1) + ". " + this.pointsTrack[this.pointsTrackOrder[ti]].marker.pointName, this.pointsTrackOrder[ti])); } } } } this.onChangeSelectionTrack = function() { if (document.getElementById(this.idTrackSelect)) { this.selectPointTrack(document.getElementById(this.idTrackSelect).options[document.getElementById(this.idTrackSelect).selectedIndex].value, true); } } this.selectPointTrack = function(id, keepSelection) { var key; for (key in this.pointsTrack) { if (this.pointsTrack.hasOwnProperty(key)) { if (key == id) { this.pointsTrack[key].marker.select(); } else { if (this.pointsTrack[key].marker.isSelected) { this.pointsTrack[key].marker.unselect(); } } } } if (document.getElementById(this.idTrackSelect)) { if (!keepSelection) { for (var ti = 0; ti < document.getElementById(this.idTrackSelect).length; ti++) { if (document.getElementById(this.idTrackSelect).options[ti].value == id) document.getElementById(this.idTrackSelect).selectedIndex = ti; } } } } this.onClickFlipPathDisplay = function() { this.flipPathDisplay(); return false; } this.onClickChangeNamePointTrack = function() { this.changeNamePointTrack(); return false; } this.changeNamePointTrack = function() { if (document.getElementById(this.idTrackSelect)) if (document.getElementById(this.idTrackSelect).selectedIndex != -1) { var i = document.getElementById(this.idTrackSelect).selectedIndex; var oldname = this.pointsTrack[document.getElementById(this.idTrackSelect).options[i].value].marker.pointName; var name = '';; name = window.prompt(this.txtChangePointNameTrack, oldname); if (typeof(name) == "string") { var name = name.replace(/:/g, "").replace(/|/g, "").replace(/\"/g, "").replace(/\'/g, "").replace(/&/g, "").replace(/\?/g, "").replace(//g, "").substring(0, 20); this.pointsTrack[document.getElementById(this.idTrackSelect).options[i].value].marker.pointName = name; document.getElementById(this.idTrackSelect).options[i].text = (i + 1) + ". " + name; } } } this.flipPathDisplay = function() { if (this.layerPath.getVisibility()) { this.layerPath.setVisibility(false); } else { this.layerPath.setVisibility(true); } } this.movePointTrack = function(id, pos) { this.pointsTrack[id].marker.moveTo(this.map.map.getLayerPxFromLonLat(pos)); this.pointsTrack[id].marker.posLatLng = this.map.getLatLngFromLonLat(this.pointsTrack[id].marker.lonlat); this.pointsTrack[id].marker.draw(); this.refreshPath(true); this.updatePathLength(); this.updatePathHeight(); this.onTrackChanged(); } this.onClickRollback = function() { this.rollback(); return false; } this.rollback = function() { if (this.rollbackQueue.length) { var item = this.rollbackQueue.pop(); if (item.type == 'addPoint') { this.addPointTrack(item.pos, item.name, item.index); } else if (item.type == 'deletePoint') { this.deletePointTrack(this.pointsTrackOrder[item.index]); this.refreshSelectTrack(); } else { this.movePointTrack(item.id, item.pos); } } this.onTrackChanged(); } this.resetRollbackQueue = function() { this.rollbackQueue = new Array(); } this.addPointPOI = function(pos) { var point = this.createPointPOI(pos, this.defaultName, this.defaultDescription); this.showPOIDetail(point.pointId, true); } this.createPointPOI = function(pos, name, desc) { var marker = this.createMarkerPOI(pos); marker.setName(name); marker.setDescription(desc); var point = { marker: marker }; this.layerTour.addMarker(marker); marker.olmLayerAdded = this.layerTour; this.pointsLastIdPOI++; var pointId = 'c' + this.pointsLastIdPOI; point.pointId = pointId; point.marker.pointId = pointId; this.pointsCountPOI++; this.pointsPOI[pointId] = point; if (document.getElementById(this.idPOISelect)) { document.getElementById(this.idPOISelect).options[this.pointsCountPOI - 1] = new Option(this.pointsCountPOI + ". " + name, pointId); } return point; } this.onClickDeletePointPOI = function() { if (document.getElementById(this.idPOISelect)) { if (document.getElementById(this.idPOISelect).selectedIndex != -1) { this.deletePointPOI(document.getElementById(this.idPOISelect).options[document.getElementById(this.idPOISelect).selectedIndex].value); this.refreshSelectPOI(); } } return false; } this.deletePointPOI = function(id) { this.hidePOIDetail(); this.layerTour.removeMarker(this.pointsPOI[id].marker); delete this.pointsPOI[id]; this.pointsCountPOI--; } this.onClickDeleteAllPointsPOI = function() { this.deleteAllPointsPOI(); return false; } this.deleteAllPointsPOI = function() { this.hidePOIDetail(); var key; for (key in this.pointsPOI) { if (this.pointsPOI.hasOwnProperty(key)) this.deletePointPOI(key); } this.refreshSelectPOI(); } this.refreshSelectPOI = function() { if (document.getElementById(this.idPOISelect)) { while (document.getElementById(this.idPOISelect).length) document.getElementById(this.idPOISelect).remove(0); var key; for (key in this.pointsPOI) { if (this.pointsPOI.hasOwnProperty(key)) document.getElementById(this.idPOISelect).add(new Option((document.getElementById(this.idPOISelect).length + 1) + ". " + this.pointsPOI[key].marker.pointName, key)); } } } this.onChangeSelectionPOI = function() { if (document.getElementById(this.idPOISelect)) { this.selectPointPOI(document.getElementById(this.idPOISelect).options[document.getElementById(this.idPOISelect).selectedIndex].value, true); } } this.selectPointPOI = function(id, keepSelection) { this.hidePOIDetail(); var key; for (key in this.pointsPOI) { if (this.pointsPOI.hasOwnProperty(key)) { if (key == id) { this.pointsPOI[key].marker.select(); } else { if (this.pointsPOI[key].marker.isSelected) { this.pointsPOI[key].marker.unselect(); } } } } if (document.getElementById(this.idPOISelect)) { if (!keepSelection) { for (var ti = 0; ti < document.getElementById(this.idPOISelect).length; ti++) { if (document.getElementById(this.idPOISelect).options[ti].value == id) document.getElementById(this.idPOISelect).selectedIndex = ti; } } } } this.showPOIDetail = function(id, edit) { this.detailPOIId = id; if (edit) { document.getElementById(this.idPOIEditNameShow).style.display = 'none'; document.getElementById(this.idPOIEditNameEdit).style.display = 'block'; document.getElementById(this.idPOIEditDescriptionShow).style.display = 'none'; document.getElementById(this.idPOIEditDescriptionEdit).style.display = 'block'; } else { document.getElementById(this.idPOIEditNameEdit).style.display = 'none'; document.getElementById(this.idPOIEditNameShow).style.display = 'block'; document.getElementById(this.idPOIEditDescriptionEdit).style.display = 'none'; document.getElementById(this.idPOIEditDescriptionShow).style.display = 'block'; } document.getElementById(this.idPOIEditNameDisplay).innerHTML = "
" + this.pointsPOI[id].marker.pointName + "
"; document.getElementById(this.idPOIEditDescriptionDisplay).innerHTML = "
" + this.pointsPOI[id].marker.pointDescription.replace(/\n/g, '
') + "
"; document.getElementById(this.idPOIEditName).value = this.pointsPOI[id].marker.pointName; document.getElementById(this.idPOIEditDescription).value = this.pointsPOI[id].marker.pointDescription; document.getElementById(this.idPOIEdit).style.display = 'block'; } this.onNameChange = function() { document.getElementById(this.idPOIEditName).value = this.pointsPOI[this.detailPOIId].marker.pointName; document.getElementById(this.idPOIEditNameShow).style.display = 'none'; document.getElementById(this.idPOIEditNameEdit).style.display = 'block'; return false; } this.onNameChanged = function() { this.pointsPOI[this.detailPOIId].marker.pointName = document.getElementById(this.idPOIEditName).value.replace(//g, ""); if (document.getElementById(this.idPOISelect)) { for (var ti = 0; ti < document.getElementById(this.idPOISelect).length; ti++) { if (document.getElementById(this.idPOISelect).options[ti].value == this.detailPOIId) document.getElementById(this.idPOISelect).options[ti].text = (ti + 1) + '. ' + this.pointsPOI[this.detailPOIId].marker.pointName; } } document.getElementById(this.idPOIEditNameDisplay).innerHTML = "
" + this.pointsPOI[this.detailPOIId].marker.pointName + "
"; document.getElementById(this.idPOIEditNameEdit).style.display = 'none'; document.getElementById(this.idPOIEditNameShow).style.display = 'block'; return false; } this.onCancelNameChange = function() { document.getElementById(this.idPOIEditNameDisplay).innerHTML = "
" + this.pointsPOI[this.detailPOIId].marker.pointName + "
"; document.getElementById(this.idPOIEditNameEdit).style.display = 'none'; document.getElementById(this.idPOIEditNameShow).style.display = 'block'; return false; } this.onDescriptionChange = function() { document.getElementById(this.idPOIEditDescription).value = this.pointsPOI[this.detailPOIId].marker.pointDescription; document.getElementById(this.idPOIEditDescriptionShow).style.display = 'none'; document.getElementById(this.idPOIEditDescriptionEdit).style.display = 'block'; return false; } this.onDescriptionChanged = function() { this.pointsPOI[this.detailPOIId].marker.pointDescription = document.getElementById(this.idPOIEditDescription).value.replace(//g, ""); document.getElementById(this.idPOIEditDescriptionDisplay).innerHTML = "
" + this.pointsPOI[this.detailPOIId].marker.pointDescription.replace(/\n/g, '
') + "
"; document.getElementById(this.idPOIEditDescriptionEdit).style.display = 'none'; document.getElementById(this.idPOIEditDescriptionShow).style.display = 'block'; return false; } this.onCancelDescriptionChange = function() { document.getElementById(this.idPOIEditDescriptionEdit).style.display = 'none'; document.getElementById(this.idPOIEditDescriptionShow).style.display = 'block'; return false; } this.onClickHidePOIDetail = function() { this.hidePOIDetail(); return false; } this.hidePOIDetail = function() { document.getElementById(this.idPOIEdit).style.display = 'none'; this.detailPOIId = null; } this.onClickCreateURL = function() { this.createURL(); return false; } this.createURL = function() { if ((document.getElementById(this.idPOIEditNameEdit).style.display == "block") || (document.getElementById(this.idPOIEditNameEdit).style.display == "block")) { alert(this.txtPOIUrlSubmitFirst); } else { var pnazev = this.pointsPOI[this.detailPOIId].marker.pointName; var ppopis = this.pointsPOI[this.detailPOIId].marker.pointDescription; var ll = this.map.tranformToOLM(this.pointsPOI[this.detailPOIId].marker.lonlat); px = ll.lon; py = ll.lat; pz = this.map.getZoom(); pmt = 0; if (this.map.isOnCyklo) { pmt = 1; } else if (this.map.isOnWinter) { pmt = 2; } url = "http://www.cykloserver.cz/cykloatlas/?pgx=" + escape(px) + "&pgy=" + escape(py) + "&pgz=" + escape(pz) + "&pmt=" + escape(pmt) + "&pn=%25" + this.base16Encode(pnazev) + "&pp=%25" + this.base16Encode(ppopis); prompt(this.txtPOIUrl, url); } } this.onClickFlipTrack = function() { this.flipTrack(); return false; } this.onClickFlipPOI = function() { this.flipPOI(); return false; } this.flipTrack = function() { if (this.isOnTrack) { this.map.cCaInfoBox.hideInfoBox(); } else { this.showTrack(); } } this.flipPOI = function() { if (this.isOnPOI) { this.map.cCaInfoBox.hideInfoBox(); } else { this.showPOI(); } } this.showTrack = function() { if (!this.isOnTrack) { this.isOnTrack = true; document.getElementById(this.idTrackInfo).style.display = 'block'; this.map.cCaInfoBox.openInfoBox(this.contentIdTrack, this.pHideTrackCB); this.refreshSelectTrack(); this.selectPathColor(this.pathColor); } } this.hideTrack = function() { if (this.isOnTrack) { this.isOnTrack = false; document.getElementById(this.idTrackInfo).style.display = 'none'; } } this.hideTrackCB = function() { this.hideTrack(); } this.showPOI = function() { if (!this.isOnPOI) { this.isOnPOI = true; document.getElementById(this.idPOIInfo).style.display = 'block'; this.map.cCaInfoBox.openInfoBox(this.contentIdPOI, this.pHidePOICB); this.refreshSelectPOI(); } } this.hidePOI = function() { if (this.isOnPOI) { this.isOnPOI = false; document.getElementById(this.idPOIInfo).style.display = 'none'; this.hidePOIDetail(); } } this.hidePOICB = function() { this.hidePOI(); } this.hide = function() { if (this.isOn) { this.clearLayer(); this.hidePath(); //this.infoBox.hide(); this.isOn = false; } } this.itemDecode = function(str) { return str.replace(/#LT#/g, '<').replace(/#GT#/g, '>'); } this.convertDtoDMS = function(a) { var res = Math.floor(a); res+= "°"; var b = (a - Math.floor(a)) * 60; res+= (Math.floor(b) < 10)?("0" + Math.floor(b)):(Math.floor(b)); res+= "'"; var c = (b - Math.floor(b)) * 60; res+= (Math.floor(c) < 10)?("0" + Math.floor(c)):(Math.floor(c)); res+= '"'; return res; } this.createMarkerPOI = function(pos) { var size = new OpenLayers.Size(this.iconPOI.graphicWidth, this.iconPOI.graphicHeight); var offset = new OpenLayers.Pixel(this.iconPOI.graphicXOffset, this.iconPOI.graphicYOffset); var icon = new OpenLayers.Icon(this.iconPOI.externalGraphicOrig, size, offset); var point = this.map.fromLatLng(pos); var marker = new OpenLayers.Marker(point, icon); marker.style = this.iconPOI; marker.pointName = ''; marker.pointDescription = ''; marker.posLatLng = pos; marker.update = function(style) { } marker.setName = function(str) { this.pointName = str; } marker.setDescription = function(str) { this.pointDescription = str; } marker.select = function() { if (!this.isSelected) { this.setUrl(this.style.externalGraphicSel); this.isSelected = true; this.olmMap.map.panTo(this.lonlat); } } marker.unselect = function() { if (this.isSelected) { this.setUrl(this.style.externalGraphicOrig); this.isSelected = false; } } marker.onClick = function() { } marker.onMouseDown = function(e) { this.olmControl.markerMouseDown = this; this.olmControl.markerStartPageX = e.pageX; this.olmControl.markerStartPageY = e.pageY; this.olmControl.markerStartX = parseInt(this.icon.imageDiv.style.left.replace('px', '')); this.olmControl.markerStartY = parseInt(this.icon.imageDiv.style.top.replace('px', '')); this.moved = false; } marker.onMouseUp = function(e) { if (this.olmControl.markerMouseDown) { this.olmControl.markerMouseDown = null; if (!this.moved) { this.olmControl.selectPointPOI(this.pointId, false); this.olmControl.showPOIDetail(this.pointId, false); } else { var pix = this.olmControl.map.map.getPixelFromLonLat(this.lonlat); pix.x+= this.olmControl.markerLastDifPageX; pix.y+= this.olmControl.markerLastDifPageY; this.icon.imageDiv.style.left = (this.olmControl.markerStartPageX) + 'px'; this.icon.imageDiv.style.top = (this.olmControl.markerStartPageY) + 'px'; this.moveTo(this.olmMap.map.getLayerPxFromViewPortPx(pix)); this.posLatLng = this.olmMap.getLatLngFromLonLat(this.lonlat); this.draw(); } } } marker.onMouseMove = function(e) { this.olmControl.markerLastDifPageX = e.pageX - this.olmControl.markerStartPageX; this.olmControl.markerLastDifPageY = e.pageY - this.olmControl.markerStartPageY; this.icon.imageDiv.style.left = (this.olmControl.markerStartX + this.olmControl.markerLastDifPageX) + 'px'; this.icon.imageDiv.style.top = (this.olmControl.markerStartY + this.olmControl.markerLastDifPageY) + 'px'; this.moved = true; } marker.isSelected = false; marker.markerId = -1; marker.olmMap = this.map; marker.olmControl = this; marker.olmLayerAdded = null; marker.events.register('click', marker, marker.onClick); marker.events.register('mousedown', marker, marker.onMouseDown); marker.events.register('mouseup', marker, marker.onMouseUp); return marker; } this.onMouseMove = function(e) { if (this.markerMouseDown) { this.markerMouseDown.onMouseMove(e); } } this.onMouseUp = function(e) { this.markerMouseDown = null; } this.createMarkerTrack = function(pos) { var size = new OpenLayers.Size(this.iconTrack.graphicWidth, this.iconTrack.graphicHeight); var offset = new OpenLayers.Pixel(this.iconTrack.graphicXOffset, this.iconTrack.graphicYOffset); var icon = new OpenLayers.Icon(this.iconTrack.externalGraphicOrig, size, offset); var point = this.map.fromLatLng(pos); var marker = new OpenLayers.Marker(point, icon); marker.style = this.iconTrack; marker.pointName = ''; marker.posLatLng = pos; marker.pointType = 'normal'; marker.update = function(style) { } marker.setName = function(str) { this.pointName = str; } marker.select = function() { if (!this.isSelected) { if (this.pointType == 'normal') { this.setUrl(this.style.externalGraphicSel); } else if (this.pointType == 'start') { this.setUrl(this.style.externalGraphicStartSel); } else { this.setUrl(this.style.externalGraphicEndSel); } this.isSelected = true; //this.olmMap.map.panTo(this.lonlat); } } marker.unselect = function() { if (this.isSelected) { if (this.pointType == 'normal') { this.setUrl(this.style.externalGraphicOrig); } else if (this.pointType == 'start') { this.setUrl(this.style.externalGraphicStartOrig); } else { this.setUrl(this.style.externalGraphicEndOrig); } this.isSelected = false; } } marker.setPointType = function(pointType) { if (pointType != this.pointType) { this.pointType = pointType; if (this.isSelected) { if (this.pointType == 'normal') { this.icon.size = this.style.sizeNormal; this.icon.offset = this.style.offsetNormal; this.setUrl(this.style.externalGraphicSel); } else if (this.pointType == 'start') { this.icon.size = this.style.sizeStart; this.icon.offset = this.style.offsetStart; this.setUrl(this.style.externalGraphicStartSel); } else { this.icon.size = this.style.sizeEnd; this.icon.offset = this.style.offsetEnd; this.setUrl(this.style.externalGraphicEndSel); } } else { if (this.pointType == 'normal') { this.icon.size = this.style.sizeNormal; this.icon.offset = this.style.offsetNormal; this.setUrl(this.style.externalGraphicOrig); } else if (this.pointType == 'start') { this.icon.size = this.style.sizeStart; this.icon.offset = this.style.offsetStart; this.setUrl(this.style.externalGraphicStartOrig); } else { this.icon.size = this.style.sizeEnd; this.icon.offset = this.style.offsetEnd; this.setUrl(this.style.externalGraphicEndOrig); } } } } marker.onClick = function() { //this.olmControl.selectPointTrack(this.pointId, false); } marker.onMouseDown = function(e) { this.olmControl.markerMouseDown = this; this.olmControl.markerStartPageX = e.pageX; this.olmControl.markerStartPageY = e.pageY; this.olmControl.markerStartX = parseInt(this.icon.imageDiv.style.left.replace('px', '')); this.olmControl.markerStartY = parseInt(this.icon.imageDiv.style.top.replace('px', '')); this.moved = false; } marker.onMouseUp = function(e) { if (this.olmControl.markerMouseDown) { this.olmControl.markerMouseDown = null; if (!this.moved) { this.olmControl.selectPointTrack(this.pointId, false); } else { var pix = this.olmControl.map.map.getPixelFromLonLat(this.lonlat); pix.x+= this.olmControl.markerLastDifPageX; pix.y+= this.olmControl.markerLastDifPageY; this.icon.imageDiv.style.left = (this.olmControl.markerStartPageX) + 'px'; this.icon.imageDiv.style.top = (this.olmControl.markerStartPageY) + 'px'; this.olmControl.rollbackQueue.push({ type: 'movePoint', id: this.pointId, pos: this.lonlat }); this.moveTo(this.olmMap.map.getLayerPxFromViewPortPx(pix)); this.posLatLng = this.olmMap.getLatLngFromLonLat(this.lonlat); this.draw(); this.olmControl.refreshPath(true); this.olmControl.updatePathLength(); this.olmControl.updatePathHeight(); this.olmControl.onTrackChanged(); } } } marker.onMouseMove = function(e) { this.olmControl.markerLastDifPageX = e.pageX - this.olmControl.markerStartPageX; this.olmControl.markerLastDifPageY = e.pageY - this.olmControl.markerStartPageY; this.icon.imageDiv.style.left = (this.olmControl.markerStartX + this.olmControl.markerLastDifPageX) + 'px'; this.icon.imageDiv.style.top = (this.olmControl.markerStartY + this.olmControl.markerLastDifPageY) + 'px'; this.moved = true; } marker.isSelected = false; marker.markerId = -1; marker.olmMap = this.map; marker.olmControl = this; marker.olmLayerAdded = null; marker.events.register('click', marker, marker.onClick); marker.events.register('mousedown', marker, marker.onMouseDown); marker.events.register('mouseup', marker, marker.onMouseUp); return marker; } this.base16Encode = function(str) { var alph = "ABCDEFGHIJKLMNOP"; var tstr = ''; for (var ti = 0; ti < str.length; ti++) { var c = str.charCodeAt(ti); if (c < 128) { tstr+= String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { tstr+= String.fromCharCode((c >> 6) | 192); tstr+= String.fromCharCode((c & 63) | 128); } else { tstr+= String.fromCharCode((c >> 12) | 224); tstr+= String.fromCharCode(((c >> 6) & 63) | 128); tstr+= String.fromCharCode((c & 63) | 128); } } str = tstr; var res = ''; for (var ti = 0; ti < str.length; ti++) { var c1 = str.charCodeAt(ti) & 15; var c2 = (str.charCodeAt(ti) >> 4) & 15; res+= alph.charAt(c1); res+= alph.charAt(c2); } return res; } this.base16Decode = function(str) { var alph = "ABCDEFGHIJKLMNOP"; str = str.replace(/[^A-P]/g, ""); if ((str.length % 2) || (!str.length)) return ''; var res = ''; for (var ti = 0; ti < str.length / 2; ti++) { var c1 = alph.indexOf(str.charAt(ti * 2)); var c2 = alph.indexOf(str.charAt(ti * 2 + 1)); var c = c1 | (c2 << 4); res+= String.fromCharCode(c); } var tres = ''; var ti = 0; var c = 0; var c1 = 0; var c2 = 0; while ( ti < res.length ) { c = res.charCodeAt(ti); if (c < 128) { tres+= String.fromCharCode(c); ti++; } else if ((c > 191) && (c < 224)) { c2 = res.charCodeAt(ti + 1); tres+= String.fromCharCode(((c & 31) << 6) | (c2 & 63)); ti+= 2; } else { c2 = res.charCodeAt(ti + 1); c3 = res.charCodeAt(ti + 2); tres+= String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); ti+= 3; } } res = tres; return res; } this.onMapAddLayer = function() { this.resetLayersZIndex(); } this.onMapRemoveLayer = function() { this.resetLayersZIndex(); } this.resetLayersZIndex = function() { if (this.map.map.layers.length) { for (var ti = 0; ti < this.map.map.layers.length; ti++) { if (this.map.map.layers[ti].presetZIndex) { this.map.map.layers[ti].div.style.zIndex = this.map.map.layers[ti].presetZIndex; } else { this.map.map.layers[ti].div.style.zIndex = 560; } if (this.map.map.layers[ti].presetDisplay) if (this.map.map.layers[ti].presetDisplay == 'none') { this.map.map.layers[ti].div.style.width = '0px'; this.map.map.layers[ti].div.style.height = '0px'; this.map.map.layers[ti].div.style.overflow = 'hidden'; } } } } this.attachEvents = function() { this.map.map.events.register('moveend', this, this.onMapMoveEnd); this.map.map.events.register('addlayer', this, this.onMapAddLayer); this.map.map.events.register('removelayer', this, this.onMapRemoveLayer); this.map.map.events.register('click', this, this.onMapClick); this.map.map.events.register('mousemove', this, this.onMouseMove); this.map.map.events.register('mouseup', this, this.onMouseUp); $(document).unbind('keyup'); $(document).bind('keyup', jQuery.proxy(this.onKeyDelete, this)); } this._create(); this.initialize(); }