diff options
author | andi <andi@splitbrain.org> | 2005-06-05 12:38:42 +0200 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-06-05 12:38:42 +0200 |
commit | f62ea8a1d1cf10eddeae777b11420624e111b7ea (patch) | |
tree | 87a15e898308a5de1ef37874645a4cdcb83c707b /lib/scripts/tw-sack.js | |
parent | 248a73214063d2fe47787c8c4aa292777cddb12b (diff) | |
download | rpg-f62ea8a1d1cf10eddeae777b11420624e111b7ea.tar.gz rpg-f62ea8a1d1cf10eddeae777b11420624e111b7ea.tar.bz2 |
directory layout cleanup !IMPORTANT
This patch changes the directory structure of dokuwiki as suggested
in http://www.freelists.org/archives/dokuwiki/06-2005/msg00045.html
As the changes.log is not managed through darcs you need to move it your
self to the new location in data/changes.log
I think I modified the code at all nessessary places, but I may have
forgotten a few things.
darcs-hash:20050605103842-9977f-af20f63c1d604888375d175d89ac6bd71566d47d.gz
Diffstat (limited to 'lib/scripts/tw-sack.js')
-rw-r--r-- | lib/scripts/tw-sack.js | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/lib/scripts/tw-sack.js b/lib/scripts/tw-sack.js new file mode 100644 index 000000000..8a9d12746 --- /dev/null +++ b/lib/scripts/tw-sack.js @@ -0,0 +1,95 @@ +// ====== Simple Ajax Code Kit ======= +// code by Gregory Wild-Smith (c)2005 +// http://twilightuniverse.com +// If you use this code please keep this credit intact. +// A link or email would be nice, but is not required. +// v1.01 + +function sack(file){ + this.AjaxFailedAlert = "Your browser doesn't support the extended functionality of this website, and therefore you have have an experience that differs from the intended one.\n"; + this.requestFile = file; + this.method = "POST"; + this.URLString = ""; + this.encodeURIString = true; + this.execute = false; + + this.onLoading = function() { }; + this.onLoaded = function() { }; + this.onInteractive = function() { }; + this.onCompletion = function() { }; + + this.createAJAX = function() { + try { + this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (oc) { + this.xmlhttp = null; + } + } + if(!this.xmlhttp && typeof XMLHttpRequest != "undefined") + this.xmlhttp = new XMLHttpRequest(); + if (!this.xmlhttp){ + // no XMLHttpRequest support, so no AJAX. + this.failed = true; + } + }; + + this.encodeURLString = function(string){ + varArray = string.split('&'); + for (i = 0; i < varArray.length; i++){ + urlVars = varArray[i].split('='); + if (urlVars[0].indexOf('amp;') != -1){ + urlVars[0] = urlVars[0].substring(4); + } + urlVars[0] = encodeURIComponent(urlVars[0]); + urlVars[1] = encodeURIComponent(urlVars[1]); + varArray[i] = urlVars.join("="); + } + return varArray.join('&'); + } + + this.runResponse = function(){ + eval(this.response); + } + + this.runAJAX = function(urlstring){ + if (urlstring){ this.URLString = urlstring; } + if (this.element) { this.elementObj = document.getElementById(this.element); } + if (this.xmlhttp) { + var self = this; // wierd fix for odd behavior where "this" wouldn't work in the readystate function. + this.xmlhttp.open(this.method, this.requestFile ,true); + if (this.method == "POST" && this.xmlhttp.setRequestHeader) { + this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') + } + if (this.encodeURIString){ this.URLString = this.encodeURLString(this.URLString); } + this.xmlhttp.send(this.URLString); + this.xmlhttp.onreadystatechange = function() { + switch (self.xmlhttp.readyState){ + case 1: // Loading. + self.onLoading(); + break; + case 2: // Loaded. + self.onLoaded(); + break; + case 3: // Interactive - is called every 4096 bytes.. pretty much just tells you it's downloading data. + self.onInteractive(); + break; + case 4: // Completed. + self.response = self.xmlhttp.responseText; + self.responseXML = self.xmlhttp.responseXML; + self.onCompletion(); + if(self.execute){ self.runResponse(); } + if (self.elementObj) { + self.elementObj.innerHTML = self.response; + } + break; + } + }; + } + }; +this.createAJAX(); +//if(this.failed && this.AjaxFailedAlert){ alert(this.AjaxFailedAlert); } +} +//Setup VIM: ex: et ts=2 enc=utf-8 : |