var ldr = new ldr(); function ldr() { var arToLoad; var mainSel = '#main'; var wsSplit = '<-[1]->'; var wsSplit2 = '<-[2]->'; this.mustFade = true; this.add = function(obj) { if(arToLoad == undefined) arToLoad = new Array(); arToLoad.push(obj); return this; } this.form = function(frm) { if($(frm).attr('action') == '') return; formObj.p = $(frm).attr('action').substr(3); formObj.data = $(frm).serialize(); formObj.form = frm; this.add(formObj); this.send(); } this.fakeForm = function(p, data) { formObj.p = p; formObj.data = data; this.add(formObj); this.send(); } this.prepDiff = function(id, p, data) { cleanObj.p = p; cleanObj.data = data; cleanObj.ldrDone = function(rsp) { $('#' + id).html(rsp); cleanObj.reset(); }; this.add(cleanObj); this.send(); } this.action = function(str) { //formObj.reset(); formObj.p = str; this.add(formObj); this.send(); } this.send = function () { qStr = ''; $.each(arToLoad, function(i, v) { qStr = qStr + v.p + wsSplit2 + escape(v.data) + wsSplit; }); qStr = qStr.substr(0, qStr.length - wsSplit.length); //qStr = qStr.replace(/&/g, '||ra||'); $.post('ws.php', 'q=' + qStr, function(rsp) { var arRsp = rsp.split(wsSplit); $.each(arToLoad, function(i, v) { if(typeof v.ldrDone == 'function') v.ldrDone(arRsp[i]); }); arToLoad = Array(); }); } this.fillDef = function(obj, rsp) { $(obj.sel).html(rsp); } this.clone = function (obj) { // Handle the 3 simple types, and null or undefined if (null == obj || "object" != typeof obj) return obj; // Handle Date if (obj instanceof Date) { var copy = new Date(); copy.setTime(obj.getTime()); return copy; } // Handle Array if (obj instanceof Array) { var copy = []; var len = obj.length; for (var i = 0 ; i < len; ++i) { copy[i] = clone(obj[i]); } return copy; } // Handle Object if (obj instanceof Object) { var copy = {}; for (var attr in obj) { if (obj.hasOwnProperty(attr)) copy[attr] = this.clone(obj[attr]); } return copy; } throw new Error("Unable to copy obj! Its type isn't supported."); } } var formObj = new formObj(); function formObj () { this.p = ''; this.data = ''; this.form = ''; this.ldrDone = function(rsp) { if(rsp.match('^red: ')) { window.location.href = rsp.substr(5); return false; } if(rsp.match('^Fout: ')) { alert(rsp.substr(6)); /*$.each(arToLoad, function(i, v) { $('#' + i + ' .errorMsg').html(message.substr(6)); return false; }); */ return false; } if(this.form != '') $(this.form).parent().html(rsp); } } var cleanObj = new cleanObj(); function cleanObj () { this.p = ''; this.data = ''; this.form = ''; this.ldrDone = ''; this.reset = function() { this.p = ''; this.data = ''; this.form = ''; this.ldrDone = ''; } } var scrl = new scrl(); function scrl () { this.firstRun = function() { var mustWatch = false; $(window).scroll(function() { var curScrlTop = $(window).scrollTop(); if(curScrlTop >= 590){ $('#pageHeader').css('position', 'fixed').css('top', '-588px'); $('#main .index').hide(); mustWatch = true; $('#pageContent').css('margin-top', '700px'); $('#contentFader').show(0); } else{ if(mustWatch == true) { $('#pageHeader').css('position', '').css('top', ''); $('#pageContent').css('margin-top', '-20px'); mustWatch = false; $('#contentFader').hide(0); $('#main .index').show(); } } if($('#scrollup:visible').length == (curScrlTop >= 600 ? 0 : 1) ) { if(curScrlTop >= 600){ $('#scrollup').fadeIn(700) } else { $('#scrollup').hide(0); } } }); } this.isReading = function() { return ($('#scrollup:visible').length == 1) } this.up = function() { $('#scrollup').fadeOut(700); $('html,body').animate({scrollTop:'585'}, 1000); } this.to = function(obj) { var scrl = $(obj).offset().top - 200; if($(window).scrollTop() <= 590) scrl = scrl - 100; $('html,body').animate({scrollTop:scrl}, 500); } }