/** * Teeko Framework Javascript class * * @copyright (C) 2009 Webisti Oy. All rights reserved * @version 1.0 * @author Tomi Tuovinen */ function getUnixTimestamp() { return Math.round(new Date().getTime() / 1000); } function addslashes(str) { if(str) { str=str.replace(/\\/g,'\\\\'); str=str.replace(/\'/g,'\\\''); str=str.replace(/\"/g,'\\"'); str=str.replace(/\0/g,'\\0'); return str; } } function stripslashes(str) { str=str.replace(/\\'/g,'\''); str=str.replace(/\\"/g,'"'); str=str.replace(/\\0/g,'\0'); str=str.replace(/\\\\/g,'\\'); return str; } function Error(errortype, efunction, edescription) { var ErrorArr = {}; ErrorArr.scripttype = 'JAVASCRIPT'; // 1=Javascript in Database errorhandler_scripttypes ErrorArr.errortype = errortype; // Database errorhandler_errortypes ErrorArr.file = ''; // Tähän tulee file missä errori on tapahtunut.. miten sen sais automaattisesti? ErrorArr.efunction = efunction; ErrorArr.description = edescription; ErrorArr.trace = ''; // PHP:llä saadaan mukavasti Trace mut mites javascriptillä?!? Request('function/error/SetError', "{'method':'get'}", ErrorArr); } function CreateNewElements(direction) { $('#background *').animate({left:'-300px'},300, 'linear', function() { $('#background *').hide(); Request('function/XML/GetElement',"{'async':false, 'append':'true', 'dest':'background', 'method':'get'}","{'xml':'<?xml version="1.0" encoding="UTF-8"?><template id="Button"> <img><attribute class="resizable"/><attribute src="sites/ilmoitustaulu/images/postit/postit_1_blue_2.png"/><css top="50px"/><css z-index="20"/><css right="-300px"/><css position="absolute"/><css width="100px"/><css height="100px"/></img> </template>'}"); Request('function/XML/GetElement',"{'async':false, 'append':'true', 'dest':'background', 'method':'get'}","{'xml':'<?xml version="1.0" encoding="UTF-8"?><template id="Button"> <img><attribute class="resizable"/><attribute src="sites/ilmoitustaulu/images/postit/postit_2_green_2.png"/><css top="400px"/><css z-index="20"/><css right="-300px"/><css position="absolute"/><css width="100px"/><css height="100px"/></img> </template>'}"); Request('function/XML/GetElement',"{'async':false, 'append':'true', 'dest':'background', 'method':'get'}","{'xml':'<?xml version="1.0" encoding="UTF-8"?><template id="Button"> <img><attribute class="resizable"/><attribute src="sites/ilmoitustaulu/images/polaroid/polaroid1.png"/><css top="80px"/><css z-index="20"/><css left="-300px"/><css position="absolute"/><css width="100px"/><css height="100px"/></img> </template>'}"); $('#background *').animate({right:'300px'},300); } ); } function CheckSiteLogin(json_func_settings, element) { var onErrorFunction = json_func_settings['onError']; var onSuccessFunction = json_func_settings['onSuccess']; var XHR = Request("function/db/CheckLogin", '{method:"get","async":"false"}', element); try { if (XHR.status == 200) { var data = XHR.responseText; if(dest_id && data == 'true') { if(onSuccessFunction) { //Request(act,'{dest:"'+dest_id+'", method:"post"}'); eval(onSuccessFunction); } return true; } else { if(onErrorFunction) { //Request(act,'{dest:"'+dest_id+'", method:"post"}'); eval(onErrorFunction); } return false; } } else {} } catch(ex) {} } function pausecomp(millis) { var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate-date < millis); } function include(filename) { var head = document.getElementsByTagName('head')[0]; script = document.createElement('script'); script.src = filename; script.type = 'text/javascript'; // DEBUG: tässä pitäis tarkistaa onko filenamessa jotain ja palauttaa true tai false // niin että GetElementClasses.js luokassa ei yritetä ees tehä uutta luokkaa jos siinä ei oo // tiedostoa olemassa head.appendChild(script); return true; } function getPageSize() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) return arrayPageSize; }