Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Function to getElementById
- *
- * @param String eId
- */
- function eId(eId){
- e = document.getElementById(eId);
- if (e){
- return e;
- }else{
- return false;
- }
- }
- /**
- * function to toggle a Object 'display' status
- * default: none|block
- *
- * @param: objectId
- * @param: defaultValue
- */
- function toggleDiv(divId,defaultValue){
- if (!defaultValue){
- defaultValue = "block";
- }
- e = document.getElementById(divId);
- if (e){
- if (e.style.display == "none"){
- e.style.display = defaultValue;
- }else{
- e.style.display = "none";
- }
- }
- }
- function blinkNickVisible(elIdNick){
- return true;
- }
- function clearField(field){
- field.value = "";
- field.focus();
- }
- function checkSearchField(){
- searchField = eId("search_field");
- if (searchField.value.length < 3){
- searchField.style.background = "#f00";
- searchField.value = searchField.value;
- searchField.focus();
- }else if(searchField.value == findGameString){
- searchField.style.background = "#f00";
- clearField(searchField);
- }else{
- document.location.href = searchLocation+"/"+searchField.value.replace(/ /g,"_");
- }
- }
- /**
- * Hintergrund toggeln
- *
- */
- function toggleBackground(elementObj,imageScr){
- elementObj.style.backgroundImage = "url("+imageScr+")";
- }
- /**
- * Tab-Boxen toggeln
- *
- */
- function toggleTabBox(tabGroup,currentTab,maxTabs){
- elControlPrefix = "tabcontrol__";
- elPrefix = "tabbox__";
- elSeperator = "_";
- elActiveClassName = "tabBoxLinkActive";
- fixedTabs = 0;
- for(i=0;i<maxTabs;i++){
- elCurrent = eId(elPrefix+tabGroup+elSeperator+i);
- elCurrentControl = eId(elControlPrefix+tabGroup+elSeperator+i);
- /* toggle for Tab */
- if (elCurrent && i==currentTab){
- elCurrent.style.display = "block";
- fixedTabs++;
- }else if (elCurrent){
- elCurrent.style.display = "none";
- fixedTabs++;
- }
- /* toggle for Control */
- if (elCurrentControl && i==currentTab){
- elClassWords = elCurrentControl.className.split(" ");
- isInArray = false;
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] == elActiveClassName){
- isInArray = true;
- break;
- }
- }
- if (!isInArray){
- elClassWords[elClassWords.length] = elActiveClassName;
- }
- tmpClassName = "";
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] != ""){
- tmpClassName += elClassWords[z];
- }
- if (z<(elClassWords.length-1)){
- tmpClassName += " ";
- }
- }
- elCurrentControl.className = tmpClassName;
- }else if (elCurrent){
- elClassWords = elCurrentControl.className.split(" ");
- isInArray = false;
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] == elActiveClassName){
- elClassWords[z] = "";
- break;
- }
- }
- tmpClassName = "";
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] != ""){
- tmpClassName += elClassWords[z];
- }
- if (z<(elClassWords.length-1)){
- tmpClassName += " ";
- }
- }
- elCurrentControl.className = tmpClassName;
- }
- }
- return fixedTabs;
- }
- /**
- * Absolute Position von links
- */
- function getElementX(el){
- if (typeof(el) != "object"){
- el = eId(el);
- }
- x = el.offsetLeft;
- if (!el.offsetParent) return x;
- else return (x+getElementX(el.offsetParent));
- }
- /**
- * Absolute Position von oben
- */
- function getElementY(el) {
- if (typeof(el) != "object"){
- el = eId(el);
- }
- y = el.offsetTop;
- if (!el.offsetParent) return y;
- else return (y+getElementY(el.offsetParent));
- }
- /**
- * Absolute Position des Element Bodens
- */
- function getElementBottom(el){
- if (typeof(el) != "object"){
- el = eId(el);
- }
- elTop = getElementY(el);
- return elTop+el.offsetHeight;
- }
- /**
- * Absoluter Wert des Container-styles
- */
- function getStyle(el,styleProp){
- if (typeof(el) != "object"){
- el = eId(el);
- }
- if (el.currentStyle){
- var y = el.currentStyle[styleProp];
- }else if (window.getComputedStyle){
- var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
- }
- return y;
- }
- /**
- * Entfernt Pixel/Prozent/Em werte
- * px|%|em
- */
- function rP(text){
- text = text.replace("px","");
- text = text.replace("%","");
- text = text.replace("em","");
- return text;
- }
- /**
- * Funktion, um alle Container auf eine Ebene zu leveln
- */
- function levelContainer(containerVars,forceId){
- containerObjects = new Array();
- heighestIndex = 0;
- for (i=0;i<containerVars.length;i++){
- tmpObject = eId(containerVars[i]);
- if (tmpObject){
- if (forceId == containerVars[i]){
- heighestIndex = containerObjects.length;
- }
- containerObjects[containerObjects.length] = tmpObject;
- }
- }
- if (!forceId){
- for (i=0;i<containerObjects.length;i++){
- if (getElementBottom(containerObjects[i]) > getElementBottom(containerObjects[heighestIndex])){
- heighestIndex = i;
- }
- }
- }
- for (i=0;i<containerObjects.length;i++){
- if (i == heighestIndex){
- continue;
- }
- /** check for browser-differences **/
- if (getStyle(containerObjects[i],"padding-top") == undefined){
- realContainerHeight = containerObjects[i].offsetHeight-rP(getStyle(containerObjects[i],"paddingTop"))-rP(getStyle(containerObjects[i],"paddingBottom"));
- }else{
- realContainerHeight = containerObjects[i].offsetHeight-rP(getStyle(containerObjects[i],"padding-top"))-rP(getStyle(containerObjects[i],"padding-bottom"));
- }
- tmpHeight = (getElementBottom(containerObjects[heighestIndex])-getElementBottom(containerObjects[i])) + realContainerHeight;
- containerObjects[i].style.height = tmpHeight+"px";
- }
- }
- function openPopupGame(gameHash){
- alert("#ToDo!\n"+gameHash);
- }
- /**
- * Refresh header
- */
- function doRefreshHeader(){
- $('#head_container').html($.ajax({
- url: "/account/remote_refresh_header",
- async: false
- }).responseText);
- }
- function levelup(displayDiv){
- if (displayDiv){
- $("#level_up").center();
- $("#level_up").fadeIn(1000);
- $("#content_container").animate({opacity:0.3},100);
- $("body").css("overflow", "hidden");
- }else{
- $("#level_up").fadeOut(500);
- $("#content_container").animate({opacity:1},100);
- $("body").css("overflow", "auto");
- }
- }
- function submitAjaxUpdateFormData(updateId,targetUrl,formName){
- if (formName == null){
- formName = "current_form";
- }
- formValues = {};
- s = $('#'+formName).serializeArray();
- jQuery.each(s,function(){
- formValues[this.name]=this.value;
- });
- $('#'+updateId).html($.ajax({
- url: targetUrl,
- data: formValues,
- async: false
- }).responseText);
- return false;
- }
- function reposWindowContainer(windowId){
- elCont=eId('window_container_'+windowId);
- if (!elCont){
- return true;
- }
- if(window.innerWidth) {
- x = (window.pageXOffset+window.innerWidth);
- }
- else {
- x = (document.documentElement.scrollLeft+window.document.documentElement.clientWidth);
- }
- if(elCont.offsetTop < 0){
- elCont.style.top="10px";
- }else if(elCont.offsetTop > (x+window.innerHeight-10)){
- elCont.style.top=(x+window.innerHeight-20)+"px";
- }
- if(elCont.offsetLeft < 0){
- elCont.style.left="10px";
- }else if(elCont.offsetLeft > (window.innerWidth-10)){
- elCont.style.left=(window.innerWidth-20)+"px";
- }
- }
- function resizeWindowContainer(windowId){
- elCont=eId('window_container_content_'+windowId);
- elContPos=eId('window_container_resizeable_'+windowId);
- elWidth = (elContPos.offsetLeft-elCont.offsetLeft)+"px";
- elHeight = (elContPos.offsetTop-elCont.offsetTop-10)+"px";
- elCont.style.width = elWidth;
- elCont.style.height = elHeight;
- }
- function closeWindowContainer(windowId){
- elCont=eId('window_container_'+windowId);
- if (!elCont){
- return true;
- }
- elCont.parentNode.removeChild(elCont);
- }
- function openWindowContainer(windowId,focusButton){
- elContent=eId('window_container_'+windowId);
- if (!elContent){
- return true;
- }
- elContent.style.display = "block";
- centerDiv(elContent);
- if (focusButton){
- elButtonObj = eId('window_container_'+windowId+'_button');
- if (elButtonObj){
- elButtonObj.focus();
- }
- }
- }
- function centerDiv(node) {
- var x,y;
- if(window.innerWidth) {
- x = (window.pageXOffset+(window.innerWidth/2));
- y = (window.pageYOffset+(window.innerHeight/2));
- }
- else {
- x = (document.documentElement.scrollLeft+(window.document.documentElement.clientWidth/2));
- y = (document.documentElement.scrollTop+(window.document.documentElement.clientHeight/2));
- }
- node.style.top = (y-node.offsetHeight/2)+'px';
- node.style.left = (x-node.offsetWidth/2)+'px';
- }
- function doGetCaretPosition (oField) {
- // Initialize
- var iCaretPos = 0;
- // IE Support
- if (document.selection){
- // Set focus on the element
- oField.focus ();
- // To get cursor position, get empty selection range
- var oSel = document.selection.createRange ();
- // Move selection start to 0 position
- oSel.moveStart ('character', -oField.value.length);
- // The caret position is selection length
- iCaretPos = oSel.text.length;
- }
- // Firefox support
- else if (oField.selectionStart || oField.selectionStart == '0')
- iCaretPos = oField.selectionStart;
- // Return results
- return (iCaretPos);
- }
- function doSetCaretPosition (oField, iCaretPos) {
- // IE Support
- if (document.selection) {
- // Set focus on the element
- oField.focus ();
- // Create empty selection range
- var oSel = document.selection.createRange ();
- // Move selection start and end to 0 position
- oSel.moveStart ('character', -oField.value.length);
- // Move selection start and end to desired position
- oSel.moveStart ('character', iCaretPos);
- oSel.moveEnd ('character', 0);
- oSel.select ();
- }
- // Firefox support
- else if (oField.selectionStart || oField.selectionStart == '0') {
- oField.selectionStart = iCaretPos;
- oField.selectionEnd = iCaretPos;
- oField.focus ();
- }
- }
- /**
- * get Information via Ajax
- */
- function getInformationWindow(infoString){
- $('#dynamic_container').append($.ajax({
- url: "/window/information/"+infoString,
- async: false
- }).responseText);
- }
- /**
- * status toggle
- */
- function toggleStatusContainer(){
- containerObjA = eId("profile_status_inner_container");
- containerObjB = eId("profile_status_change_container");
- if (containerObjA.style.display == "none"){
- containerObjA.style.display = "block";
- containerObjB.style.display = "none";
- }else{
- containerObjA.style.display = "none";
- containerObjB.style.display = "block";
- }
- }
- /**
- * status form
- */
- function submitStatusForm(targetUrl){
- containerObjA = eId("profile_status_inner_container");
- containerObjB = eId("profile_status_change_container");
- containerObjC = eId("profile_status_wait_container");
- buttonObjA = eId("profile_status_submit_button");
- containerObjA.style.display = "none";
- containerObjB.style.display = "none";
- containerObjC.style.display = "block";
- buttonObjA.disabled = true;
- submitAjaxUpdateFormData('profile_status_container',targetUrl,'status_form');
- return false;
- }
- function setStatusClassName(elCurrentControl,elStatus,elActiveClassName){
- /* toggle for Control */
- if (elCurrentControl && elStatus){
- elClassWords = elCurrentControl.className.split(" ");
- isInArray = false;
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] == elActiveClassName){
- isInArray = true;
- break;
- }
- }
- if (!isInArray){
- elClassWords[elClassWords.length] = elActiveClassName;
- }
- tmpClassName = "";
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] != ""){
- tmpClassName += elClassWords[z];
- }
- if (z<(elClassWords.length-1)){
- tmpClassName += " ";
- }
- }
- elCurrentControl.className = tmpClassName;
- }else if (elCurrentControl){
- elClassWords = elCurrentControl.className.split(" ");
- isInArray = false;
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] == elActiveClassName){
- elClassWords[z] = "";
- break;
- }
- }
- tmpClassName = "";
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] != ""){
- tmpClassName += elClassWords[z];
- }
- if (z<(elClassWords.length-1)){
- tmpClassName += " ";
- }
- }
- elCurrentControl.className = tmpClassName;
- }
- }
- function getStatusClassName(elCurrentControl,elActiveClassName){
- elClassWords = elCurrentControl.className.split(" ");
- isInArray = false;
- for (z=0;z<elClassWords.length;z++){
- if (elClassWords[z] == elActiveClassName){
- return true;
- break;
- }
- }
- return false;
- }
- function checkRegistration(){
- elEmail = eId("user_email");
- elNick = eId("user_nick");
- elGenderM = eId("user_gender_m");
- elGenderF = eId("user_gender_f");
- elAgb = eId("user_agb");
- elGenderContainer = eId("user_gender_container");
- elAgbContainer = eId("user_agb_container");
- elNickReserved = eId("user_nick_reserved");
- elNickWrong = eId("user_nick_wrong");
- elRegisterButton = eId("user_register_button");
- elEmailLocked = eId("user_email_locked");
- elEmailSubline = eId("user_email_subline");
- elEmailReserved = eId("user_email_reserved");
- elEmailWrong = eId("user_email_wrong");
- noErrors = true;
- var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
- if(!pattern.test(elEmail.value)){
- elEmail.style.background = "#f00";
- noErrors = false;
- }else{
- /* now check for email */
- /* check, if nick is free */
- var isEmailFree = true;
- isEmailFree = $.ajax({
- url: "/account/remote_check_email/"+encodeURI(elEmail.value),
- async: false
- }).responseText;
- if (isEmailFree == "correct"){
- elEmailLocked.style.display = "none";
- elEmailReserved.style.display = "none";
- elEmailWrong.style.display = "none";
- elEmailSubline.style.display = "block";
- elEmail.style.background = "";
- }
- else if(isEmailFree == "e_reserved"){
- elEmailLocked.style.display = "none";
- elEmailReserved.style.display = "block";
- elEmailWrong.style.display = "none";
- elEmailSubline.style.display = "none";
- elEmail.style.background = "#f00";
- noErrors = false;
- }
- else if(isEmailFree == "e_locked"){
- elEmailLocked.style.display = "block";
- elEmailReserved.style.display = "none";
- elEmailWrong.style.display = "none";
- elEmailSubline.style.display = "none";
- elEmail.style.background = "#f00";
- noErrors = false;
- }
- else if(isEmailFree == "e_wrong"){
- elEmailLocked.style.display = "none";
- elEmailReserved.style.display = "none";
- elEmailWrong.style.display = "block";
- elEmailSubline.style.display = "none";
- elEmail.style.background = "#f00";
- noErrors = false;
- }
- }
- if (elNick.value == ""){
- elNick.style.background = "#f00";
- noErrors = false;
- }else{
- /* check if nick is free */
- var isFree = true;
- isFree = $.ajax({
- url: "/account/remote_check_nick/"+encodeURI(elNick.value),
- async: false
- }).responseText;
- if (isFree == "correct"){
- elNick.style.background = "";
- elNickReserved.style.display = "none";
- elNickWrong.style.display = "none";
- }
- else if(isFree == "e_reserved"){
- elNickReserved.style.display = "block";
- elNickWrong.style.display = "none";
- elNick.style.background = "#f00";
- noErrors = false;
- }
- else if(isFree == "e_wrong"){
- elNickReserved.style.display = "none";
- elNickWrong.style.display = "block";
- elNick.style.background = "#f00";
- noErrors = false;
- }
- }
- if (elGenderM.checked == false && elGenderF.checked == false){
- elGenderContainer.style.border = "1px solid #f00";
- noErrors = false;
- }else{
- elGenderContainer.style.border = "";
- }
- if (elAgb && elAgbContainer){
- if (elAgb.checked == false){
- elAgbContainer.style.border = "1px solid #f00";
- noErrors = false;
- }else{
- elAgbContainer.style.border = "";
- }
- }
- if (noErrors){
- elRegisterButton.disabled = true;
- elRegisterButton.className = "defaultSubmitDisabled";
- }else{
- elRegisterButton.disabled = false;
- elRegisterButton.className = "defaultSubmitSmaller";
- }
- return noErrors;
- }
- function doFadeInBlink(classname, speed) {
- $("."+classname).fadeIn(speed);
- window.setTimeout("doFadeOutBlink('"+ classname + "', " + speed + ")", speed);
- }
- function doFadeOutBlink(classname, speed) {
- $("."+classname).fadeOut(speed);
- window.setTimeout("doFadeInBlink('" + classname + "', " + speed + ")", speed);
- }
- $(document).ready(function(){
- doFadeOutBlink("blinkingObject", 500);
- });
- jQuery.fn.center = function () {
- this.css("position","absolute");
- this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
- this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
- return this;
- }
Advertisement
RAW Paste Data
Copied
Advertisement