maio
[h2N7SspZmY.git] / lib / plugins / xfortune / script.js
blob8a4dc11f1592ae64688805ea945bfb677e188802
1 /**
2  * Script for plugin_xfortune
3  *
4  * Fetches a new cookie
5  *
6  * @author Andreas Gohr <andi@splitbrain.org>
7  */
8  
9 function plugin_xfortune(){
10     if(!document.getElementById){
11         return;
12     }
13     var obj = document.getElementById('plugin_xfortune');
14     if(obj === null){
15         return;
16     }
18     // We use SACK to do the AJAX requests
19     var ajax = new sack(DOKU_BASE+'lib/plugins/xfortune/ajax.php');
20     ajax_qsearch.sack.AjaxFailedAlert = '';
21     ajax_qsearch.sack.encodeURIString = false;
23     // define callback
24     ajax.onCompletion = function(){
25         var data = this.response;
26         if(data === ''){ return; }
27         var out = document.getElementById('plugin_xfortune');
29         out.style.visibility = 'hidden';
30         out.innerHTML = data;
31         out.style.visibility = 'visible';
33         // restart timer
34         window.setTimeout("plugin_xfortune()",plugin_xfortune_time);
35     };
37     ajax.runAJAX('cookie='+encodeURI(plugin_xfortune_cookie));