var _LogicBoxNickname; var _LogicBoxNav; var _LogicBoxTeaser; var _LogicBoxMainContent; var _LogicDirectZapButtons; var currentdate = new Date(); var active1 = window.setInterval("refreshSession()", 45 * 60 * 1000); /* _________________________________________________________________________________________________ Page Object _________________________________________________________________________________________________ */ var oLogic = { responsePzwebDispatcher : false, modalCommand : "", initialDispatcherCommand : undefined, currentZapButton : undefined, currentBroadcastButton : undefined, broadcastDetection : false, clientDetection : false, clientDetectionWrongBrowser : false, openNewClient : false, openNewBroadcast : false, clientwindow : null, broadcastwindow : null, broadcastPopupOpen : false, pzmoduleEnabled : null, ajaxPipe : Array(), waitForAjaxResponse : false, pageTitle: "", language: "de", init : function(){ /* init */ _LogicBoxNickname = $("#nicknameContainer"); _LogicBoxNav = $("#BoxPageColRight"); _LogicBoxMainContent = $("#mainContainer"); _LogicBoxTeaser = $("#teaserContainer"); /* * set carrot form values */ this.onPageLoad(); /* * scroll */ if(self.document.location.hash.length > 0 && self.document.location.hash.substring(1).length > 0) { $.scrollTo($("#" + self.document.location.hash.substring(1)), "slow"); } }, executeModalCommand : function(){ self.location.href='' + oLogic.modalCommand; }, onPageLoad : function(){ if (this.pageTitle != '') this.setPageTitle(); currentdate = new Date(); //_LogicDirectZapButtons = $(".directZapButtons"); $(".formCarrotRid").attr("value", 'C' + currentdate.getTime()); $(".formCarrotTimezoneoffset").attr("value", currentdate.getTimezoneOffset()); //_LogicDirectZapButtons.zapbutton( { _directConnect:true } ); $("#BtnBroadcast").zapbutton( { _broadcastButton:true } ); /* * enable ajax logout */ if(!$("#LogoutNavItem").hasClass("pz-logoutbutton-complete")) { $("#LogoutNavItem").click(function () { var confirmedLogout = false; if(oLogic.broadcastwindow != null && oLogic.broadcastwindow.closed == false) { confirmedLogout = confirm("Wenn Du Dich ausloggst, wird Dein akuteller Broadcast beendet.\n\nMöchtest Du wirklich?"); } else if(oLogic.broadcastPopupOpen == true) { confirmedLogout = confirm("Wenn Du Dich ausloggst, wird Dein akuteller Broadcast beendet, falls er noch geöffnet ist.\n\nMöchtest Du wirklich?"); } else { confirmedLogout = true; } if(confirmedLogout == true) { if( oLogic.pzmoduleEnabled == null ) { return true; //click wird ausgeführt } else { $.ajax({ url: 'http://www.peoplezapping.com/?act=logout&rid='+currentdate.getTime(), type: 'GET', dataType: 'html', error: function(){ //closeModalDialog(); }, success: function(html){ ajaxReloadPage(); if(getFlexApplicationReference("PZWEBDISPATCHERSWF") != undefined && (typeof getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites == 'function')) { getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites("reload"); getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToClientSite("closeClient"); } else { oLogic.initialDispatcherCommand = "reload"; } //closeModalDialog(); } }); return false; } } else { return false; } }); $("#LogoutNavItem").addClass("pz-logoutbutton-complete"); } oPage.appendLayout(); }, afterAjax : function(){ this.onPageLoad(); }, setPageTitle : function() { document.title = this.pageTitle; this.pageTitle = ''; } }; function scrollToEvents() { if(oLogic.pzmoduleEnabled == "home") { $.scrollTo($(".startEvents"), "slow"); } else { self.document.location.href = "http://www.peoplezapping.com/events/"; } } /* _________________________________________________________________________________________________ ajax Session Update _________________________________________________________________________________________________ */ function refreshSession(){ $.ajax({ url: 'http://www.peoplezapping.com/refresh.php?' + currentdate.getTime(), type: 'GET', dataType: 'html', error: function(){ //; }, success: function(html){ //; } }); } /* _________________________________________________________________________________________________ Modal Dialog _________________________________________________________________________________________________ */ function showModalConfirm(_text, command){ if(_initialized){ oLogic.modalCommand = command; _ModalConfirmText.text(_text); showModalDialog(_ModalConfirm); } } /* _________________________________________________________________________________________________ ajax request to deliver timezoneoffset to gmt _________________________________________________________________________________________________ */ function initTimezoneoffset(){ $.ajax({ url: 'http://www.peoplezapping.com/index.php?act=timezoneoffset&offset=' + currentdate.getTimezoneOffset(), type: 'GET', dataType: 'html', error: function(){ //; }, success: function(html){ if(html == "1") { ajaxReloadPage(); } } }); } /* _________________________________________________________________________________________________ showSnippet AJAX _________________________________________________________________________________________________ */ function showSnippet(targetId, source){ $.ajax({ url: source, type: 'GET', dataType: 'html', error: function(){ //; }, success: function(html){ $("#"+targetId).html(html); $("#"+targetId).show(); } }); } function showSnippetByObject(o, source){ //register new if(o != undefined && source != undefined) { oLogic.ajaxPipe.push( { 'object' : o, 'source' : source}); } if(!oLogic.waitForAjaxResponse) { oLogic.waitForAjaxResponse = true; var request = oLogic.ajaxPipe.shift(); if(request && request.object && request.source) { $.ajax({ url: request.source, type: 'GET', dataType: 'html', error: function(){ oLogic.waitForAjaxResponse = false; showSnippetByObject(); }, success: function(html){ request.object.html(html); request.object.show(); oLogic.afterAjax(); oLogic.waitForAjaxResponse = false; showSnippetByObject(); } }); } else { oLogic.waitForAjaxResponse = false; } } } function replaceSnippetByObject(o, source){ $.ajax({ url: source, type: 'GET', dataType: 'html', error: function(){ //; }, success: function(html){ o.replaceWith(html); o.show(); oLogic.afterAjax(); } }); } /* _________________________________________________________________________________________________ check App. Available AND connect To Keyhole _________________________________________________________________________________________________ */ function getFlexApplicationReference(swfID) { if (window[swfID]) return window[swfID]; else return document[swfID]; } /* _________________________________________________________________________________________________ PZWebDispatcher / ZAP _________________________________________________________________________________________________ */ function invokeJSCommand(param) { var param = "" + param; if(getFlexApplicationReference("PZWEBDISPATCHERSWF") != undefined && (typeof getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites == 'function')) { //alert("dispatcher (receveir): " + param); if (param == "getSID") { getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites("setSID" + $.cookie("PHPSESSID")); } else if (param.substring(0, 6) == "setSID") { // if(param.substr(6) != $.cookie("PHPSESSID")) { // $.cookie("PHPSESSID", param.substr(6)); // //window.setTimeout("ajaxReloadPage()", 300); // ajaxReloadPage(); // } } else if (param == "reload") { // ajaxReloadPage(); } else if (param == "reloadI18N") { // ajaxReloadPage(); } else if (param == "clientThere") { oLogic.openNewClient = false; if(oLogic.currentZapButton != undefined) { oLogic.currentZapButton.children('img:first').attr("src", oLogic.currentZapButton.children('img:first').attr("src").replace('_up.gif', '_over.gif')); oLogic.currentZapButton.css({'cursor' : 'pointer'}); oLogic.clientDetection = true; oLogic.openNewClient = false; } if(oLogic.currentBroadcastButton != undefined) { oLogic.currentBroadcastButton.css({'cursor' : 'pointer'}); oLogic.broadcastDetection = true; oLogic.openNewBroadcast = true; } } else if (param == "clientThereWrongBrowser") { oLogic.broadcastPopupOpen = true; if(oLogic.currentBroadcastButton != undefined) { oLogic.currentBroadcastButton.css({'cursor' : 'pointer'}); oLogic.clientDetectionWrongBrowser = true; } if(oLogic.currentZapButton != undefined) { oLogic.currentZapButton.children('img:first').attr("src", oLogic.currentZapButton.children('img:first').attr("src").replace('_up.gif', '_over.gif')); oLogic.currentZapButton.css({'cursor' : 'pointer'}); oLogic.clientDetectionWrongBrowser = true; } } else if (param == "broadcastThere") { oLogic.broadcastPopupOpen = true; oLogic.openNewBroadcast = false; if(oLogic.currentBroadcastButton != undefined) { oLogic.currentBroadcastButton.css({'cursor' : 'pointer'}); oLogic.broadcastDetection = true; oLogic.openNewBroadcast = false; oLogic.openNewClient = false; } } } } function missingClient() { oLogic.openNewClient = true; oLogic.openNewBroadcast = true; if(oLogic.currentZapButton != undefined) { oLogic.currentZapButton.children('img:first').attr("src", oLogic.currentZapButton.children('img:first').attr("src").replace('_up.gif', '_over.gif')); oLogic.currentZapButton.css({'cursor' : 'pointer'}); oLogic.clientDetection = true; } else if(oLogic.currentBroadcastButton != undefined) { oLogic.currentBroadcastButton.css({'cursor' : 'pointer'}); oLogic.broadcastDetection = true; } } function initializedDispatcher() { if(getFlexApplicationReference("PZWEBDISPATCHERSWF") != undefined && (typeof getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites == 'function')) { getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites("getSID"); if(oLogic.initialDispatcherCommand != undefined) { //alert("dispatcher (init-call): " + oLogic.initialDispatcherCommand); getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites(oLogic.initialDispatcherCommand); } getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites("isClientThere" + navigator.userAgent); } } function sendComment(infocontainer,source){ $(infocontainer + " > form > div > .button").addClass("hidden"); $(infocontainer + " > form > .UIAjaxPreloader").removeClass("hidden"); $.ajax({ url: source, type: 'GET', dataType: 'html', error: function(){ //; }, success: function(html){ $('#AjaxReloadInnerContentComments').html(html); $('#AjaxReloadInnerContentComments').show(); oLogic.afterAjax(); } }); } function showAjaxLogin(){ $('#AjaxReloadEmbeddedMiniLogin').slideDown("slow"); $('#f_login_email').focus(); } function ajaxLogin(type,source){ $('#AjaxReloadEmbededMaxiLogin').slideUp("slow"); $('#AjaxReloadEmbeddedMiniLogin').slideUp("slow"); $.ajax({ url: source, type: 'GET', dataType: 'html', error: function(){ $('#'+type+'LoginErrortext').removeClass('hidden'); }, success: function(html){ if(html == 'true'){ ajaxReloadPage(); if(getFlexApplicationReference("PZWEBDISPATCHERSWF") != undefined && (typeof getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites == 'function')) { getFlexApplicationReference("PZWEBDISPATCHERSWF").dispatchJSToAllSites("reload"); } else { oLogic.initialDispatcherCommand = "reload"; } }else{ $('#AjaxReloadEmbededMaxiLogin').html(html); $('#AjaxReloadEmbededMaxiLogin').slideDown("slow"); } } }); } function ajaxReloadPage(){ showSnippetByObject($('#AjaxCallResponseContainer'), document.URL + '&forceUpdate=1' ); } /* _________________________________________________________________________________________________ Start / Onload _________________________________________________________________________________________________ */ $(document).ready(function(){ oLogic.init(); });