var Profile = { _cache: Array(), _cachePageNumber: Array(), _cacheParts: Array(), _gbDeleteEntryWarn: true, _blogDeleteEntryWarn: true, _gbEntryBeingSent: false, _pVoteLast: 0, _pVoteLastTime: 0, profileID: 0, section: 0, part: 0, language: 0, languageActive: 0, pageNumber: 0, accessLevel: 0, adminAccess: 0, popup: true, init: function(profileID, section, part, language, pageNumber, accessLevel, popup, adminAccess) { this.profileID = profileID; this.section = section; this.part = part; this.language = language; this.pageNumber = pageNumber; this.accessLevel = accessLevel; this.adminAccess = adminAccess; this.popup = popup; if(section==4 || section==5 || section==6 || section==7 || (section==2 && part==2)) { this.languageActive = 0; } else { this.languageActive = language; } this._cacheParts[1] = 1; this._cacheParts[2] = 1; this._cacheParts[3] = 1; this._cacheParts[4] = 1; this._cacheParts[5] = 1; this._cacheParts[6] = 1; this._cacheParts[7] = 1; document.observe("dom:loaded", Profile.initPicture); }, changeSection: function(newSection, newPart, newLanguage, hChg, sn, aLevel) { if(newSection == 0) newSection = this.section; if(aLevel < 0) aLevel = this.accessLevel; if(newPart==0) { newPart = this._cacheParts[newSection]; } if(newSection==4 || newSection==5 || newSection==6 || newSection==7 || (newSection==2 && newPart==2)) { newLanguage = 0; try { $("languageOptions").hide(); } catch(e) { } } else { if(newLanguage == 0) newLanguage = this.language; try { $("languageOptions").show(); } catch(e) { } } if(newSection == this.section && newPart == this.part && (newLanguage == this.language || newLanguage == 0) && sn == 0 && hChg<2 && aLevel==this.accessLevel)return; this._checkSectionDef(this.languageActive); this._checkSectionDef(newLanguage); if(sn==0) { sn = this._cachePageNumber[newLanguage][newSection][newPart]; } try { this._cachePageNumber[this.languageActive][this.section][this.part] = this.pageNumber; var oldPageNumber = this._cachePageNumber[this.languageActive][this.section][this.part]; if(sn!=this._cachePageNumber[newLanguage][newSection][newPart]) { this._cachePageNumber[newLanguage][newSection][newPart] = sn; } if(newPart!=this._cacheParts[newSection]) { this._cacheParts[newSection] = newPart; } new Ajax.Request( addSessionID(ABSOLUTE_URI+"/profile.php?task=details&id="+this.profileID+"&language="+newLanguage+"&part="+newSection+"&subpart="+newPart+"&sn="+sn+"&access_level="+aLevel+"&admin_access="+this.adminAccess+"&act=html"), { method: 'get', onSuccess: function(req){ Profile.changeSectionCB(req.responseText, newSection, newPart, newLanguage, sn, aLevel, true); } } ); } catch(e) { if(Page.ProfileID==1) { alert('General JS Loading Error - this should not happen... Error name: '+e.name+' , Error message: '+e.message+', Line number: '+e.lineNumber); } window.location=addSessionID(ABSOLUTE_URI+"/profile.php?task=details&id="+this.profileID+"&language="+newLanguage+"&part="+newSection+"&subpart="+newPart+"&sn="+sn); } }, changeSectionCB: function(content, newSection, newPart, newLanguage, sn, aLevel, cache) { if(Page.checkForErrors(content)) { Page.handleErrors(content); return; } this.pageNumber = sn; this.part = newPart; $("profileContent").innerHTML = content; if(newLanguage!=this.language && newLanguage>0) { try { $("langOpt"+this.language).className = "notSelected"; $("langOpt"+newLanguage).className = "selected"; } catch(e) {} this.language = newLanguage; } if(aLevel!=this.accessLevel) { try { $('pALevel'+this.accessLevel).removeClassName('selected'); $('pALevel'+aLevel).addClassName('selected'); } catch(e) {} this.accessLevel = aLevel; } if(newSection!=this.section) { $('navE'+this.section).removeClassName("selected"); $('navE'+newSection).addClassName("selected"); this.section = newSection; } Position.scrollToTop(); if(this.section==4 || this.section==5 || this.section==6 || this.section==7) { this.languageActive = 0; } else { this.languageActive = this.language; } Page.adjustDOM(); }, _checkSectionDef: function(language) { if(this._cache[language]==undefined) { this._cache[language] = Array(); this._cachePageNumber[language] = Array(); if(language>0) { this._cachePageNumber[language][1] = Array(); this._cachePageNumber[language][1][1] = 1; this._cachePageNumber[language][2] = Array(); this._cachePageNumber[language][2][1] = 1; this._cachePageNumber[language][3] = Array(); this._cachePageNumber[language][3][1] = 1; } else { this._cachePageNumber[language][4] = Array(); this._cachePageNumber[language][4][1] = 1; this._cachePageNumber[language][5] = Array(); this._cachePageNumber[language][5][1] = 1; this._cachePageNumber[language][5][2] = 1; this._cachePageNumber[language][5][3] = 1; this._cachePageNumber[language][5][4] = 1; this._cachePageNumber[language][6] = Array(); this._cachePageNumber[language][6][1] = 1; this._cachePageNumber[language][7] = Array(); this._cachePageNumber[language][7][1] = 1; } } }, deleteBlogEntry: function(id) { if(Profile._blogDeleteEntryWarn==true) { Page.questionMessage({ title: Language['Profile_Delete_Entry_Warn_Title'], text: Language['Profile_Delete_Entry_Warn_Text'], okText: Language['MB_DelWarn_OK'], cancelText: Language['MB_DelWarn_Cancel'], warnAgain: true, warnAgainText: Language['MB_DelWarn_WarnAgain'], functionName: 'Profile.deleteBlogEntryDo', functionParams: id }); } else { Profile.deleteBlogEntryDo(id); } }, deleteBlogEntryDo: function(id) { if(Profile.deleteBlogEntryDo.arguments.length>1) { Profile._blogDeleteEntryWarn = Profile.deleteBlogEntryDo.arguments[1]; } new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/blogs.php?task=delete_entry&blog_id="+id+'&act=html')), { method: 'get', onSuccess: function(req){if(parseInt(req.responseText)==1){ $("PNE"+id).remove(); try { Profile._cache[Profile.languageActive][Profile.section][Profile._cachePageNumber[Profile.languageActive][Profile.section]] = ''; } catch(e) {} } else { Page.handleErrors(req.responseText); } } } ); }, markAsKnown: function(id,type) { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/userlist.php?task=set_known_status&id="+id+'&status=1&act=html')), { method: 'get', onSuccess: function(req){ if(parseInt(req.responseText)==1) { if(type==0) { $('markKnown').hide(); $('unmarkKnown').show(); } else { $('markKnown'+id).hide(); $('unmarkKnown'+id).show(); } } else if(parseInt(req.responseText)==10) { Page.errorMessage({ 'title': Language['UList_Too_Many_Known_Own_Title'], 'text': Language['UList_Too_Many_Known_Own_Text'], 'links': Language['UList_Too_Many_Known_Own_Links'] }); } else if(parseInt(req.responseText)==11) { Page.errorMessage({ 'title': Language['UList_Too_Many_Known_Foreign_Title'], 'text': Language['UList_Too_Many_Known_Foreign_Text'], 'links': Language['UList_Too_Many_Known_Foreign_Links'] }); } else { Page.handleErrors(req.responseText); } } } ); }, unmarkAsKnown: function(id,type) { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/userlist.php?task=set_known_status&id="+id+'&status=-1&act=html')), { method: 'get', onSuccess: function(req){ if(parseInt(req.responseText)==1) { if(type==0) { $('markKnown').show(); $('unmarkKnown').hide(); } else { $('markKnown'+id).show(); $('unmarkKnown'+id).hide(); } } else { Page.handleErrors(req.responseText); } } } ); }, markAsTrusted: function(id,type) { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/userlist.php?task=set_trust_status&id="+id+'&status=1&act=html')), { method: 'get', onSuccess: function(req){ if(parseInt(req.responseText)==1) { $('markTrusted').hide(); $('unmarkTrusted').show(); } else if(parseInt(req.responseText)==20) { Page.errorMessage({ 'title': Language['UList_Too_Many_Trusted_Title'], 'text': Language['UList_Too_Many_Trusted_Text'], 'links': Language['UList_Too_Many_Trusted_Links'] }); } else { Page.handleErrors(req.responseText); } } } ); }, unmarkAsTrusted: function(id,type) { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/userlist.php?task=set_trust_status&id="+id+'&status=-1&act=html')), { method: 'get', onSuccess: function(req){ if(parseInt(req.responseText)==1) { $('markTrusted').show(); $('unmarkTrusted').hide(); } else { Page.handleErrors(req.responseText); } } } ); }, activateGB: function() { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/profile_gb.php?task=activate&act=html")), { method: 'get', onSuccess: function(req){if(parseInt(req.responseText)==1){ $('gbInactive').hide(); $('gbActive').show(); } else { Page.handleErrors(req.responseText); } } } ); }, deactivateGB: function() { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/profile_gb.php?task=deactivate&act=html")), { method: 'get', onSuccess: function(req){if(parseInt(req.responseText)==1){ $('gbActive').hide(); $('gbInactive').show(); } else { Page.handleErrors(req.responseText); } } } ); }, deleteGBAll: function() { Page.questionMessage({ title: Language['GB_Delete_All_Title'], text: Language['GB_Delete_All_Text'], warnAgain: false, okText: Language['MB_DelWarn_OK'], cancelText: Language['MB_DelWarn_Cancel'], functionName: 'Profile.deleteGBAllDo', functionParams: '' }); }, deleteGBAllDo: function() { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/profile_gb.php?task=delete_all&act=html")), { method: 'get', onSuccess: function(req){if(parseInt(req.responseText)==1){ try { Profile._cache[0][6] = Array(); } catch(e) { } Profile.changeSection(6, 0, 0, 2, 1, -1); } else { Page.handleErrors(req.responseText); } } } ); }, deleteGB: function(id) { if(Profile._gbDeleteEntryWarn==true) { Page.questionMessage({ title: Language['Profile_Delete_Entry_Warn_Title'], text: Language['Profile_Delete_Entry_Warn_Text'], okText: Language['MB_DelWarn_OK'], cancelText: Language['MB_DelWarn_Cancel'], warnAgain: true, warnAgainText: Language['MB_DelWarn_WarnAgain'], functionName: 'Profile.deleteGBDo', functionParams: id }); } else { Profile.deleteGBDo(id); } }, deleteGBDo: function(id) { if(Profile.deleteGBDo.arguments.length>1) { Profile._gbDeleteEntryWarn = Profile.deleteGBDo.arguments[1]; } new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+"/profile_gb.php?task=delete&gb_id="+id+'&act=html')), { method: 'get', onSuccess: function(req){if(parseInt(req.responseText)==1){ $("GBE"+id).remove(); try { Profile._cache[Profile.languageActive][Profile.section][Profile._cachePageNumber[Profile.languageActive][Profile.section]] = ''; } catch(e) {} } else { Page.handleErrors(req.responseText); } } } ); }, toggleVote: function() { if($('pVoteOpt').visible()==true) { $('pVoteOpt').hide(); } else { var el; if(Profile._pVoteLast==0 || (Profile._pVoteLastTime+(12*60*60))<Math.round(new Date().getTime()/1000.0)) { $('pVChosen').hide(); $('pVChoose').show(); el = $('pVoteOpt').getElementsByTagName("ul")[0]; var voteOffset = $('pVote').cumulativeOffset(); var topPosition = (voteOffset.top+$('pVote').getHeight()-290); if(topPosition<0) { topPosition = 0; } $('pVoteOpt').setStyle({ top: topPosition + 'px', left: (voteOffset.left+$('pVote').getWidth()) + 'px' }).show(); $('pVoteOpt').setStyle({ height: el.getHeight()+'px' }); } else { $('pVChoose').hide(); $('pVChosen').update('<div id="pVC'+Profile._pVoteLast+'" class="pVC">'+sprintf(Language['PVote_Explain'], '<span class="chosen">'+Language['PVotes'][Profile._pVoteLast]+'</span>')+'</div><div id="pVCNote">'+Language['PVote_Limit']+'</div>').show(); el = $('pVChosen'); var voteOffset = $('pVote').cumulativeOffset(); $('pVoteOpt').setStyle({ top: (voteOffset.top) + 'px', left: (voteOffset.left+$('pVote').getWidth()) + 'px' }).show(); $('pVoteOpt').setStyle({ height: el.getHeight()+'px' }); } } }, vote: function(type) { $('pVoteOpt').hide(); new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+'/profile_votes.php?task=save&profile_id='+this.profileID+'&rating='+parseInt(type)+'&act=html')), { method: 'get', onSuccess: function(req){ Profile.voteCB(type, req.responseText);} } ); }, voteCB: function(type, success) { if(success==1) { Profile.setVoteDecision(type, Math.round(new Date().getTime()/1000.0)); Page.successMessage({ title: Language['PVote_Success_Title'], text: Language['PVote_Success_Text'] }); } else if(success==6) { Page.errorMessage({ title: Language['PVote_Too_Many_Global_Title'], text: Language['PVote_Too_Many_Global_Text'] }); } else if(success==3) { Page.errorMessage({ title: Language['PVote_Too_Many_Local_Title'], text: Language['PVote_Too_Many_Local_Text'] }); } else if(success==4) { Page.errorMessage({ title: Language['IMSG_Ignore_Foreign_Error_Title'], text: Language['IMSG_Ignore_Foreign_Error_Text'] }); } else if(success==5) { Page.errorMessage({ title: Language['IMSG_Ignore_Own_Error_Title'], text: Language['IMSG_Ignore_Own_Error_Text'] }); } else { Page.handleErrors(success); } }, setVoteDecision: function(v, vTime) { Profile._pVoteLast = v; Profile._pVoteLastTime = vTime; }, toggleFolder: function(folderID) { $('picContent'+folderID).toggle(); $$('#folder'+folderID+' .toggleFolder').each(function(el){ el.toggle(); }); }, showPasswordFolder: function(fid, pw) { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+'/profile.php?task=details_picture_folder&profile_id='+this.profileID+'&folder_id='+parseInt(fid)+'&pw='+encodeURIComponent(pw)+'&act=json')), { method: 'get', onSuccess: function(req){ if(Page.checkForErrors(req.responseText)==true) { Page.handleErrors(req.responseText); } else { var result = req.responseText.evalJSON(true); Profile.showPasswordFolderCB(fid, result.result, result.data); } } } ); }, showPasswordFolderCB: function(fid, code, data) { if(parseInt(code)==1) { this.changeSectionCB(data, 4, 0, 0, 1, this.accessLevel, false); } else if(parseInt(code)==2) { Page.errorMessage({ title: Language['Pics_PW_Wrong_Title'], text: Language['Pics_PW_Wrong_Text'] }); } else if(parseInt(code)==3) { Page.errorMessage({ title: Language['Pics_No_Folder_Title'], text: Language['Pics_No_Folder_Text'] }); } else { Page.handleErrors(code); } }, showPicture: function(objLink,pCom,cID,mID) { Page.showProgressBar(); var pageDim = Position.getPageDimensions(); if(Page.IE_Version==6) { $$("select").each(function(e){ e.setStyle({ visibility: 'hidden' }); }); } $('overlay').setStyle({ height: (pageDim.pageHeight + 'px') }).show(); imgPreload = new Image(); imgPreload.onload=function(){ $('lightboxImage').src = objLink.href; Position.prepare(); var lightboxTop = Position.deltaY + ((pageDim.windowHeight - 50 - imgPreload.height) / 2); var lightboxLeft = ((pageDim.pageWidth - (imgPreload.width+40)) / 2); $('lightbox').setStyle({ top: (lightboxTop < 0) ? "0px" : lightboxTop + "px", left: (lightboxLeft < 0) ? "0px" : lightboxLeft + "px" }); var arrowsTop = Position.deltaY + ((pageDim.windowHeight-20) / 2); if(cID>0) { $('lightboxLeft').getElementsByTagName("a")[0].onclick = function(){$('uP'+(cID-1)).onclick();}; $('lightboxLeft').setStyle({ top: (arrowsTop < 0) ? "0px" : arrowsTop + "px", left: "3px" }).show(); } else { $('lightboxLeft').hide(); } if((cID+1)<mID) { $('lightboxRight').getElementsByTagName("a")[0].onclick = function(){$('uP'+(cID+1)).onclick();}; $('lightboxRight').setStyle({ top: (arrowsTop < 0) ? "0px" : arrowsTop + "px", right: "5px" }).show(); } else { $('lightboxRight').hide(); } $('lightboxDetails').setStyle({ width: imgPreload.width + 'px' }); try { var caption = objLink.getAttribute('title').escapeHTML() } catch(e) { var caption = ''; } $('lightboxCaption').update(caption + ' <span class="pDate">' + pCom + '</span>').show(); if (Page.IE_Version>0) { pause(250); } Page.hideProgressBar(); $('lightbox').show(); pageDim = Position.getPageDimensions(); $('overlay').setStyle({ height: (pageDim.pageHeight + 'px') }); document.onkeydown = function(e){ if(e && e.which) { characterCode = e.which; } else if(window.event) { characterCode = window.event.keyCode; } else { characterCode = 0; } if((characterCode==37 || characterCode==52) && cID>0){$('uP'+(cID-1)).onclick();} else if((characterCode==39 || characterCode==54) && (cID+1)<mID){$('uP'+(cID+1)).onclick();} else if(characterCode==120 || characterCode==27) {Profile.hidePicture();} }; return false; }; imgPreload.src = objLink.href; }, hidePicture: function() { $('overlay').hide(); $('lightbox').hide(); $('lightboxLeft').hide(); $('lightboxRight').hide(); if(Page.IE_Version==6) { $$("select").each(function(e){ e.setStyle({ visibility: 'visible' }); }); } document.onkeydown = ''; }, initPicture: function() { var objOverlay = new Element('div', { 'id': 'overlay' }).setStyle({ display: 'none', position: 'absolute', top: 0, left: 0, zIndex: 30000, width: '100%' }).observe('click', Profile.hidePicture); $(document.body).insert({ top: objOverlay }); var objLightbox = new Element('div', { 'id': 'lightbox' }).setStyle({ display: 'none', position: 'absolute', zIndex: 100000 }).insert( (new Element('a', { href: 'javascript:void(0);', 'class': 'image', 'title': 'Click to close' }).update( new Element('img', { 'id': 'lightboxImage' }) )).observe('click', function(){Profile.hidePicture();return false;}) ).insert( new Element('div', { 'id': 'lightboxDetails' }).update( new Element('div', { 'id': 'lightboxCaption' }).hide() ) ).observe('click', Profile.hidePicture); $(document.body).insert({ top: objLightbox }); var objLinkLeft = new Element('a', { href: 'javascript:void(0);', 'class': 'image' }); var objLightboxLeft = new Element('div', { 'id': 'lightboxLeft' }).setStyle({ display: 'none', position: 'absolute', zIndex: 200000 }).update( objLinkLeft ); var imgPreloadNextButton = new Image(); imgPreloadNextButton.onload=function() { var objCloseButton = new Element('img', { src: ABSOLUTE_URI+'/images/'+TEMPLATE_NAME+'/page/arrow_backward_l.png' }).setStyle({ position: 'absolute', zIndex: '200000' }); objLinkLeft.appendChild(objCloseButton); return false; }; imgPreloadNextButton.src = ABSOLUTE_URI+'/images/'+TEMPLATE_NAME+'/page/arrow_backward_l.png'; $(document.body).insert({ top: objLightboxLeft }); var objLinkRight = new Element('a', { href: 'javascript:void(0);', 'class': 'image' }); var objLightboxRight = new Element('div', { 'id': 'lightboxRight' }).setStyle({ display: 'none', position: 'absolute', zIndex: 200000 }).update( objLinkRight ); var imgPreloadPrevButton = new Image(); imgPreloadPrevButton.onload=function() { var objCloseButton = new Element('img', { src: ABSOLUTE_URI+'/images/'+TEMPLATE_NAME+'/page/arrow_forward_l.png' }).setStyle({ position: 'absolute', zIndex: '200000' }); objLinkRight.appendChild(objCloseButton); return false; }; imgPreloadPrevButton.src = ABSOLUTE_URI+'/images/'+TEMPLATE_NAME+'/page/arrow_forward_l.png'; $(document.body).insert({ top: objLightboxRight }); } };
