1function epub_show_throbber(user,client) {
2
3	var dom = document.getElementById('epub_throbber');
4	if(!dom || !user || !epub_title) return;
5	dom.style.display='block';
6	var params="user="+encodeURIComponent(user);
7
8	params += "&location="+encodeURIComponent(window.location);
9	params += "&title="+encodeURIComponent(epub_title);
10
11	params+="&epub_ids="+epub_stringifyArray(epub_id);
12    params+="&epub_titles="+epub_stringifyArray(epub_wikilink);
13
14    if(client) {
15	params += "&client="+encodeURIComponent(client);
16	}
17    if(book_id) {
18        params+= "&book_page="  + encodeURIComponent(book_id);
19    }
20	jQuery.post(
21    DOKU_BASE + 'lib/plugins/epub/scripts/ebook.php',
22    params,
23    function (data) {
24        dom.innerHTML = '<div style="width:800;overflow:auto;text-align:left"><pre>' +decodeURIComponent(decodeURIComponent(data)) + '</pre></div>';
25       regex=/Ebook:\s+(:?epub.*?\.epub)/;
26       result = regex.exec(dom.innerHTML);
27	   if(result) {
28           var epub='http://'+ location.host  + DOKU_BASE + 'lib/exe/fetch.php?media=' + result[1];
29           dom.innerHTML +='<div><center><a href="' + epub + '" class="media mediafile mf_epub" title="' + result[1] +'">' + result[1] +'</a></center></div>';
30	   }
31	},
32    'html'
33	);
34
35}
36
37function epub_stringifyArray(ar) {
38    ar=ar.join(';;');
39	ar= ar.replace(/^;;/,"");
40	ar= ar.replace(/;;$/,"");
41    return encodeURIComponent(ar);
42}
43
44function epub_remove_creator(id) {
45    var params="remove="+encodeURIComponent(id);
46	jQuery.post(
47    DOKU_BASE + 'lib/plugins/epub/scripts/update_files.php',
48    params,
49    function (data) {
50    alert(data);
51	},
52    'html'
53	);
54
55}
56
57
58function _epub_show_throbber(user,client) {
59	      epub_show_throbber(user,client);
60		  var dom = document.getElementById('show_throbberbutton');
61		  dom.style.display='none';
62     epub_check_progress(client,user);
63}
64
65
66function epub_check_progress(client,user) {
67   var dom = document.getElementById('epub_progress');
68     var params="user="+encodeURIComponent(user);
69     if(client) {
70  	   params += "&client="+encodeURIComponent(client);
71	}
72    var secs = 0;
73    var t =window.setInterval(function() {
74        jQuery.post(
75        DOKU_BASE + 'lib/plugins/epub/scripts/check_progess.php',
76        params,
77        function (data) {
78            if(!data) window.clearInterval(t);
79            secs++;
80            dom.innerHTML = data + '[seconds:  ' + secs*15 + ']';
81        },
82        'html'
83        );
84        },
85        15000);
86}
87
88function epub_admin_confirm(which) {
89
90    var f =document.epub_admin;
91    var epubs = new Array();
92    var msg="";
93    for(var i=0; i < f.length; i++) {
94         if(f[i].checked) {
95             matches =  f[i].name.match(/\[([a-z0-9]+)\]/);
96             msg += f[i].value + "\n" ;
97         }
98    }
99    var confirm_msg = "Please confirm that you want to delete the following cache entries";
100    if(which == 'media') {
101       confirm_msg +=" and their ebooks";
102    }
103    if(!confirm(confirm_msg + ":\n" + msg)) return false;
104    return true;
105}
106