/* // +----------------------------------------------------------------------+ // | Orginial Code Care Of: | // +----------------------------------------------------------------------+ // | Copyright (c) 2004 Bitflux GmbH | // +----------------------------------------------------------------------+ // | Licensed under the Apache License, Version 2.0 (the "License"); | // | you may not use this file except in compliance with the License. | // | You may obtain a copy of the License at | // | http://www.apache.org/licenses/LICENSE-2.0 | // | Unless required by applicable law or agreed to in writing, software | // | distributed under the License is distributed on an "AS IS" BASIS, | // | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | // | implied. See the License for the specific language governing | // | permissions and limitations under the License. | // +----------------------------------------------------------------------+ // | Author: Bitflux GmbH | // | http://blog.bitflux.ch/p1735.html | // +----------------------------------------------------------------------+ // // // +----------------------------------------------------------------------+ // | Heavily Modified by Jeff Minard (07/09/04) | // +----------------------------------------------------------------------+ // | Same stuff as above, yo! | // +----------------------------------------------------------------------+ // | Author: Jeff Minard | // | http://www.creatimation.net | // +----------------------------------------------------------------------+ // // // +----------------------------------------------------------------------+ // | What is this nonsense?? (07/09/04) | // +----------------------------------------------------------------------+ // | This is a script that, by using XMLHttpRequest javascript objects | // | you can quickly add some very click live interactive feed back to | // | your pages that reuire server side interaction. | // | | // | For instance, you use this to emulate a "live searching" feature | // | wherein users type in key phrases, and once they have stopped typing | // | the script will automatically search and retrive *without* a page | // | reload. // | | // | In another instance, I use this to product live comments by passing | // | the text to a Textile class that parses it to valid HTML. After | // | parsing, the html is returned and displayed on the page as the | // | user types. | // +----------------------------------------------------------------------+ */ /*-------------------------------------- User configured variables --------------------------------------*/ var liveInputId = 'query'; // This is the id on the input/textarea that you want to use as the query. var liveOutputId = 'live'; // use this to have the results populate your own ID'd tag. // leave it blank and a div tag will automatically be added // with an id="liveSearchResults" var liveContentId = 'content'; var liveContentSearchId = 'searchcontent'; var liveProcessURI = '/ajax/livesearch.ajax.php'; // this is the file that you request data from. var liveEmptyString = ''; // What to display in the results field when there's nothing // Leaving this null will cause the results field to be set to display: none var navInputId = 'nav'; var navOutputId = 'navResult'; var navFormId = 'navForm'; var navProcessURI = "/ajax/nav.ajax.php"; var navEmptyString = ''; /*-------------------------------------- Script Stuff --------------------------------------*/ var liveReq = false; var navReq = false; var liveT = null; var navT = null; var liveReqLast = ""; var navReqLast = ""; var isIE = false; var submenuInitialised = false; var liveInputElement; var liveOutputElement; var navInputElement; var navOutputElement; // on !IE we only have to initialize it once if (window.XMLHttpRequest) { liveReq = new XMLHttpRequest(); navReq = new XMLHttpRequest(); } function liveReqInit() { liveInputElement = document.getElementById(liveInputId); liveOutputElement = document.getElementById(liveOutputId); liveContentElement = !document.getElementById(liveContentId) ? document.getElementById(liveContentSearchId) : document.getElementById(liveContentId); liveContentSearchElement = !document.getElementById(liveContentSearchId) ? false : document.getElementById(liveContentSearchId); if( liveInputElement == null || liveOutputElement == null ) return; if (navigator.userAgent.indexOf("Safari") > 0) { liveInputElement.addEventListener("keydown",liveReqStart,false); } else if (navigator.product == "Gecko") { liveInputElement.addEventListener("keypress",liveReqStart,false); } else { liveInputElement.attachEvent('onkeydown',liveReqStart); isIE = true; } if(liveEmptyString == '') { // set the result field to hidden, or to default string liveOutputElement.style.display = "none"; } else { liveOutputElement.innerHTML = liveEmptyString; } } function liveReqStart() { if (liveT) { window.clearTimeout(liveT); } liveT = window.setTimeout("liveReqDoReq()",100); } function liveReqDoReq() { if (liveReqLast != liveInputElement.value && liveInputElement.value != "") { if (liveReq && liveReq.readyState < 4) { liveReq.abort(); } if (window.XMLHttpRequest) { // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { liveReq = new ActiveXObject("Microsoft.XMLHTTP"); } liveReq.onreadystatechange = liveReqProcessReqChange; liveReq.open("GET", liveProcessURI + "?query=" + encodeURI(liveInputElement.value)); liveReqLast = liveInputElement.value; liveReq.send(null); } else if(liveInputElement.value == "") { if(liveEmptyString == '') { liveOutputElement.innerHTML = ''; liveOutputElement.style.display = "none"; } else { liveOutputElement.innerHTML = liveEmptyString; } } } function liveReqProcessReqChange() { if (liveReq.readyState == 4) { liveOutputElement.innerHTML = liveReq.responseText; liveContentElement.style.display = "none"; if(liveContentSearchElement!=false) { liveContentSearchElement.style.display = "none"; } if(liveEmptyString == '') { liveOutputElement.style.display = "block"; } } } function navReqInit() { navInputElement = document.getElementById(navInputId); navOutputElement = document.getElementById(navOutputId); navFormElement = document.getElementById(navFormId); if( navInputElement == null || navOutputElement == null ) return; if (navigator.userAgent.indexOf("Safari") > 0) { navInputElement.addEventListener("change",navReqStart,false); } else if (navigator.product == "Gecko") { navInputElement.addEventListener("change",navReqStart,false); } else { navInputElement.attachEvent('onchange',navReqStart); isIE = true; } if(navInputElement.selectedIndex!=0 && submenuInitialised==false) { //navReqStart(); //submenuInitialised=true; } if(navEmptyString == '') { // set the result field to hidden, or to default string if(navInputElement.selectedIndex==0) { navOutputElement.style.display = "none"; } } else { navOutputElement.innerHTML = navEmptyString; } } function navReqStart() { navFormElement.submit(); //if (navT) { // window.clearTimeout(navT); //} //navT = window.setTimeout("navReqDoReq()",100); } function navReqDoReq() { //if (navReqLast != navInputElement.selectedIndex && navInputElement.selectedIndex != "0") { // if (navReq && navReq.readyState < 4) { // navReq.abort(); // } // if (window.XMLHttpRequest) { // branch for IE/Windows ActiveX version // } else if (window.ActiveXObject) { // navReq = new ActiveXObject("Microsoft.XMLHTTP"); // } // navReq.onreadystatechange = navReqProcessReqChange; // navReq.open("GET", navProcessURI + "?nav=" + encodeURI(navInputElement.options[navInputElement.selectedIndex].value)); // navReqLast = navInputElement.selectedIndex; // navReq.send(null); //} else if(navInputElement.selectedIndex == "0") { // if(navEmptyString == '') { // navOutputElement.innerHTML = ''; // navOutputElement.style.display = "none"; // } else { // navOutputElement.innerHTML = navEmptyString; // } //} } function navReqProcessReqChange() { if (navReq.readyState == 4) { navOutputElement.innerHTML = navReq.responseText; if((navReq.responseText==false || navReq.responseText=="" || navReq.responseText==null) && submenuInitialised==false) { navFormElement.submit(); } else if(submenuInitialised==true) { submenuInitialised=false; } if(navEmptyString == '') { navOutputElement.style.display = "block"; } } } var url ="/ajax/updateForm.ajax.php"; var req; function smartHighlight(id, state) { if(state==false) { document.getElementById(id).className = ''; } else { document.getElementById(id).className = 'smartHighlight'; } } function showForm(id, type) { document.getElementById("title_"+type+"_"+id).style.display = "none"; document.getElementById("form_"+type+"_"+id).style.display = "block"; } function hideForm(id, type) { document.getElementById("title_"+type+"_"+id).style.display = "block"; document.getElementById("form_"+type+"_"+id).style.display = "none"; smartHighlight("title_"+type+"_"+id, false); } function processAjaxForm(id, type) { theId = id; theType = type; form = document.forms["form_"+type+"_"+id]; try { if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Ihr Webbrowser unterstuetzt leider kein Ajax!"); } value = encodeURI(form.fieldValue.value); name = encodeURI(form.fieldName.value); req.open("GET", url+"?n="+name+"&v="+value+"&id="+id , true); req.onreadystatechange = highlightElement; req.send(null); } catch(e) { alert("Fehler: " + e); } return false; } function processUserlevelForm(id, type) { theId = id; theType = type; form = document.forms["form_"+type+"_"+id]; try { if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Ihr Webbrowser unterstuetzt leider kein Ajax!"); } from = encodeURI(form.from.value); asset_id = encodeURI(form.asset_id.value); till = encodeURI(form.till.value); for(i=0;i < form.userlevel.length;i++) { if(form.userlevel[i].checked==true) { value = encodeURI(form.userlevel[i].value); } } req.open("GET", url+"?n="+theType+"&v="+value+"&from="+from+"&till="+till+"&id="+asset_id+"&id_userlevel="+id , true); req.onreadystatechange = highlightElement; req.send(null); } catch(e) { alert("Fehler: " + e); } return false; } function processUserlevelFormExport(publicId, exportId) { theId = '00000001'; theType = 'userlevel'; form = document.forms["form_"+theType+"_"+theId]; try { if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Ihr Webbrowser unterstuetzt leider kein Ajax!"); } from = ''; till = ''; asset_id = document.getElementById('asset_id_'+publicId).value; for(i=0;i < form.elements['userlevel['+publicId+']'].length;i++) { if(form.elements['userlevel['+publicId+']'][i].checked==true) { value = encodeURI(form.elements['userlevel['+publicId+']'][i].value); } } req.open("GET", url+"?n="+theType+"&v="+value+"&from="+from+"&till="+till+"&id="+asset_id+"&id_userlevel="+publicId , true); //alert(url+"?n="+theType+"&v="+value+"&from="+from+"&till="+till+"&id="+asset_id+"&id_userlevel="+publicId); req.send(null); if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Ihr Webbrowser unterstuetzt leider kein Ajax!"); } asset_id = document.getElementById('asset_id_'+exportId).value; for(i=0;i < form.elements['userlevel['+exportId+']'].length;i++) { if(form.elements['userlevel['+exportId+']'][i].checked==true) { value = encodeURI(form.elements['userlevel['+exportId+']'][i].value); } } req.open("GET", url+"?n="+theType+"&v="+value+"&from="+from+"&till="+till+"&id="+asset_id+"&id_userlevel="+exportId , true); //alert(url+"?n="+theType+"&v="+value+"&from="+from+"&till="+till+"&id="+asset_id+"&id_userlevel="+exportId); req.onreadystatechange = highlightElement; req.send(null); } catch(e) { alert("Fehler: " + e); } return false; } function processAssettypeForm(id, type) { theId = id; theType = type; form = document.forms["form_"+type+"_"+id]; try { if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Ihr Webbrowser unterstuetzt leider kein Ajax!"); } id_asset = encodeURI(form.fieldIDAsset.value); value = encodeURI(form.fieldValue.options[form.fieldValue.selectedIndex].value); name = encodeURI(form.fieldName.value); req.open("GET", url+"?n="+name+"&v="+value+"&id="+id_asset, true); req.onreadystatechange = highlightElement; req.send(null); } catch(e) { alert("Fehler: " + e); } return false; } function processAssetcategoryForm(id, type) { theId = id; theType = type; form = document.forms["form_"+type+"_"+id]; try { if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Ihr Webbrowser unterstuetzt leider kein Ajax!"); } id_asset = encodeURI(form.fieldIDAsset.value); id_prev = encodeURI(form.fieldIDPrev.value); value = encodeURI(form.fieldValue.options[form.fieldValue.selectedIndex].value); name = encodeURI(form.fieldName.value); req.open("GET", url+"?n="+name+"&v="+value+"&id="+id_asset+"&id_prev="+id_prev , true); req.onreadystatechange = highlightElement; req.send(null); } catch(e) { alert("Fehler: " + e); } return false; } function processAssetattrForm(id, type) { theId = id; theType = type; form = document.forms["form_"+type+"_"+id]; try { if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Ihr Webbrowser unterstuetzt leider kein Ajax!"); } id_asset = encodeURI(form.fieldIDAsset.value); id_prev = encodeURI(form.fieldIDPrev.value); value = encodeURI(form.fieldValue.options[form.fieldValue.selectedIndex].value); name = encodeURI(form.fieldName.value); req.open("GET", url+"?n="+name+"&v="+value+"&id="+id_asset+"&id_prev="+id_prev , true); req.onreadystatechange = highlightElement; req.send(null); } catch(e) { alert("Fehler: " + e); } return false; } function updateArchiveCheckbox(obj) { if(obj.checked==true) { var val = 'Y'; } else { var val = 'N'; } var url = "/ajax/updateArchiveCheckbox.php?id="+escape(obj.value)+"&value="+escape(val); new Ajax.Request(url); } function updateExportCheckbox(obj) { if(obj.checked==true) { var val = 'Y'; } else { var val = 'N'; } var url = "/ajax/updateExportCheckbox.php?id="+escape(obj.value)+"&value="+escape(val); new Ajax.Request(url); } function updateDomesticCheckbox(obj) { if(obj.checked==true) { var val = 'Y'; } else { var val = 'N'; } var url = "/ajax/updateDomesticCheckbox.php?id="+escape(obj.value)+"&value="+escape(val); new Ajax.Request(url); } function updateAttentionCheckbox(obj) { if(obj.checked==true) { var val = 'Y'; } else { var val = 'N'; } var url = "/ajax/updateAttentionCheckbox.php?id="+escape(obj.value)+"&value="+escape(val); new Ajax.Request(url); } function updateDeprecatedCheckbox(obj) { if(obj.checked==true) { var val = 'Y'; $('archive_checkbox').checked = true; $('archive_checkbox').disabled = true; $('preview_image').className = 'thumb deprecated'; } else { var val = 'N'; $('archive_checkbox').disabled = false; $('preview_image').className = 'thumb normal'; } var url = "/ajax/updateDeprecatedCheckbox.php?id="+escape(obj.value)+"&value="+escape(val); new Ajax.Request(url); } function highlightElement() { divId = "div_"+theType+"_"+theId; titleId = document.getElementById("title_"+theType+"_"+theId); if(req.readyState ==4) { if(req.status!=200 && req.status!=undefined) { hideForm(theId, theType); new Effect.Highlight(divId, {startcolor:'#FF6666', endcolor:'#FFFFFF'}); alert("Fehler " + req.status + ": " + req.statusText); } else { if(form.fieldValue.type.indexOf("select")!=-1) { value = encodeURI(form.fieldValue.options[form.fieldValue.selectedIndex].value); if(form.fieldIDPrev) { form.fieldIDPrev.value = value; theVal = req.responseText; } else { var parts = req.responseText.split(":|_|:"); theVal = parts[0]; $('add_new_assetattr').innerHTML = parts[1]; hideForm(theId, theType); } titleId.innerHTML = theVal; } else if(req.responseText!="" && req.responseText!=null) { theVal = req.responseText; titleId.innerHTML = theVal; } else { if(form.fieldValue.value!="" || (form.fieldValue.value=="" && form.fieldValue.defaultValue!="")) { theVal = form.fieldValue.value; var search = /\n/; var res; while(res = search.exec(theVal)) { theVal = theVal.replace(search, "
"); } titleId.innerHTML = theVal; if(form.fieldValue.value=="" && form.fieldValue.defaultValue!="") { titleId.innerHTML = "keine Angabe"; } } } hideForm(theId, theType); new Effect.Highlight(divId, {startcolor:'#66FF66', endcolor:'#FFFFFF'}); } } } function switchHistoryVisibility(elem, textClosed, textOpen) { theTable = document.getElementById("hidden-"+elem); theHref = document.getElementById("link-"+elem); theHeader = document.getElementById(elem); theStyle = theTable.style.display; if(theStyle!="block") { theTable.style.display = "block"; theHref.innerHTML = "Obere fünf anzeigen"; theHeader.innerHTML = textOpen; } else { theTable.style.display = "none"; theHref.innerHTML = "Alle anzeigen"; theHeader.innerHTML = textClosed; } } //addEvent(window, 'load', liveReqInit, false); //addEvent(window, 'load', navReqInit, false); function addAddress(element, dropon, event) { sendData(element.id, dropon.id); } function sendData (prod, drop) { var url = '/ajax/address.php'; var rand = Math.random(9999); var pars = 'address_id=' + prod + '&rand=' + rand + "&drop=" + drop; var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); } function clearCart () { var url = '/ajax/address.php'; var rand = Math.random(9999); var pars = 'clear=true&rand=' + rand; var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); } function clearAddress (id, drop) { var url = '/ajax/address.php'; var rand = Math.random(9999); var pars = 'clearAddress=true&id=' + id + '&rand=' + rand + "&drop=" + drop; var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); } function showResponse (originalRequest) { //$('loading').style.display = "none"; $('clearCart').style.display = "block"; //alert(originalRequest.responseText); var parts = originalRequest.responseText.split(":|_|:"); $('cart'+parts[0]).innerHTML = parts[1]; if(parts[2]!=null && parts[2]!="") { $('cart'+parts[0]).className = parts[2]; } } function showLoad () { $('clearCart').style.display = "none"; $('loading').style.display = "block"; } function updateCollection(params) { var url = '/ajax/collect.php'; var params = 'f='+params; var myAjax = new Ajax.Request( url, {method: 'get', parameters: params, onSuccess: function(t) { var parts = t.responseText.split(":||:"); if ($('collection-add-delete-'+parts[0])) { $('collection-add-delete-'+parts[0]).innerHTML=parts[1]; } $('collection').innerHTML = parts[2]; new Effect.Highlight('collection', {startcolor:'#C3B215', endcolor:'#676767'}) } }); } function updateBasket(params) { var url = '/ajax/basket.php'; var params = 'f='+params; var myAjax = new Ajax.Request( url, {method: 'get', parameters: params, onSuccess: function(t) { var parts = t.responseText; $('navBasket').innerHTML = parts; new Effect.Highlight('navBasket', {startcolor:'#C3B215', endcolor:'#676767'}) } }); } function getAssetAttrList(id, element) { var url = "/ajax/getAssetAttrList.php"; var para = 'id='+escape(id)+"&element="+element; new Ajax.Updater( element, url, { method: 'get', parameters: para } ); } function getAssetAttrListForCollection(id) { var url = "/ajax/getAssetAttrListForCollection.php"; var para = 'id='+escape(id); new Ajax.Updater( 'assetattrdiv', url, { method: 'get', parameters: para } ); } function getCurrentMultipageFile() { var url = document.getElementById('divBackground').style.backgroundImage; url = url.substring(url.lastIndexOf("/")+1, url.length-1); return url.replace(/"/, ''); } function prevMultipage() { new Ajax.Eval('/ajax/getMultipage.php?prev=true&curFile='+encodeURI(getCurrentMultipageFile())); } function nextMultipage() { new Ajax.Eval('/ajax/getMultipage.php?next=true&curFile='+encodeURI(getCurrentMultipageFile())); } function removeRelation(id_child, id_parent, type) { var url = "/ajax/removeRelation.php"; var para = 'child='+escape(id_child)+'&parent='+escape(id_parent); var myAjax = new Ajax.Request( url, {method: 'get', parameters: para} ); if(type=='child') { Effect.toggle('child-'+id_child, 'blind'); } else { Effect.toggle('parent-'+id_parent, 'blind'); } }