backup de julho
[h2N7SspZmY.git] / lib / plugins / tag / script.js
blob6b9c614842f32b894ac1b36f5af1091a8f64ceb5
1 /**
2 * Javascript for tagindex management
4 * @author Gina Haeussge, Michael Klier <dokuwiki@chimeric.de>
5 * @author Andreas Gohr <andi@splitbrain.org>
6 */
8 /**
9 * Class to hold some values
11 function plugin_tagindex_class(){
12 this.pages = null;
13 this.page = null;
14 this.sack = null;
15 this.done = 1;
16 this.count = 0;
18 var pl_si = new plugin_tagindex_class();
19 pl_si.sack = new sack(DOKU_BASE + 'lib/plugins/tag/ajax.php');
20 pl_si.sack.AjaxFailedAlert = '';
21 pl_si.sack.encodeURIString = false;
23 /**
24 * Display the loading gif
26 function plugin_tagindex_throbber(on){
27 obj = document.getElementById('pl_si_throbber');
28 if(on){
29 obj.style.visibility='visible';
30 }else{
31 obj.style.visibility='hidden';
35 /**
36 * Gives textual feedback
38 function plugin_tagindex_status(text){
39 obj = document.getElementById('pl_si_out');
40 obj.innerHTML = text;
43 /**
44 * Callback. Gets the list of all pages
46 function plugin_tagindex_cb_clear(){
47 ok = this.response;
48 if(ok == 1){
49 // start indexing
50 window.setTimeout("plugin_tagindex_index()",1000);
51 }else{
52 plugin_tagindex_status(ok);
53 // retry
54 window.setTimeout("plugin_tagindex_clear()",5000);
58 /**
59 * Callback. Gets the list of all pages
61 function plugin_tagindex_cb_pages(){
62 data = this.response;
63 pl_si.pages = data.split("\n");
64 pl_si.count = pl_si.pages.length;
65 plugin_tagindex_status(pl_si.pages.length+" pages found");
67 pl_si.page = pl_si.pages.shift();
68 window.setTimeout("plugin_tagindex_clear()",1000);
71 /**
72 * Callback. Gets the info if indexing of a page was successful
74 * Calls the next index run.
76 function plugin_tagindex_cb_index(){
77 ok = this.response;
78 if(ok == 1){
79 pl_si.page = pl_si.pages.shift();
80 pl_si.done++;
81 // get next one
82 window.setTimeout("plugin_tagindex_index()",1000);
83 }else{
84 plugin_tagindex_status(ok);
85 // get next one
86 window.setTimeout("plugin_tagindex_index()",5000);
90 /**
91 * Starts the indexing of a page.
93 function plugin_tagindex_index(){
94 if(pl_si.page){
95 plugin_tagindex_status('indexing<br />'+pl_si.page+'<br />('+pl_si.done+'/'+pl_si.count+')<br />');
96 pl_si.sack.onCompletion = plugin_tagindex_cb_index;
97 pl_si.sack.URLString = '';
98 pl_si.sack.runAJAX('call=indexpage&page='+encodeURI(pl_si.page));
99 }else{
100 plugin_tagindex_status('finished');
101 plugin_tagindex_throbber(false);
106 * Cleans the index
108 function plugin_tagindex_clear(){
109 plugin_tagindex_status('clearing index...');
110 pl_si.sack.onCompletion = plugin_tagindex_cb_clear;
111 pl_si.sack.URLString = '';
112 pl_si.sack.runAJAX('call=clearindex');
116 * Starts the whole index rebuild process
118 function plugin_tagindex_go(){
119 document.getElementById('pl_si_gobtn').style.display = 'none';
120 plugin_tagindex_throbber(true);
122 plugin_tagindex_status('Finding all pages');
123 pl_si.sack.onCompletion = plugin_tagindex_cb_pages;
124 pl_si.sack.URLString = '';
125 pl_si.sack.runAJAX('call=pagelist');
128 //Setup VIM: ex: et ts=4 enc=utf-8 :