1 2 jQuery(document).ready(function() { 3 var toc_title = jQuery("span.tocsel_title").html(); 4 jQuery( "#tocseltoggle img" ).css( 'cursor', 'pointer' ); 5 6 jQuery( "#selectoc_btn" ).click(function() { 7 var file = this.form.selectoc_id.value; 8 jQuery("#setctoc_out").css('display','block'); 9 if(file.match(/:\*$/)) { 10 jQuery("span.tocsel_title").html('Index'); 11 } 12 else 13 { 14 jQuery("span.tocsel_title").html(toc_title); 15 } 16 var params = "seltoc_val=" + encodeURIComponent(file); 17 params += '&call=tocselect'; 18 19 jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', params, 20 function (data) { 21 if(!data) { 22 document.getElementById("setctoc_out").innerHTML = ""; 23 } 24 else { 25 document.getElementById("setctoc_out").innerHTML = data; 26 } 27 }, 28 'html' 29 ); 30 jQuery("li").off("click").click(function(){ 31 var a = jQuery("#selectoc_id"); 32 a.attr('title',a.attr('value')); 33 }); 34 35 jQuery("#tocsel_rootns").click(function(){ 36 var a = jQuery("#selectoc_id"); 37 a.attr('title',a.attr('value')); 38 }); 39 40 jQuery("#tocseltoggle img").off("click").click(function(){ 41 jQuery("#setctoc_out").toggle(); 42 var dir = DOKU_BASE + 'lib/plugins/tocselect/img/'; 43 var curSrc = jQuery(this).attr('src'); 44 if (curSrc.match(/open/)) { 45 jQuery(this).attr('src', dir +'closed.png'); 46 } 47 if (curSrc.match(/closed/)) { 48 jQuery(this).attr('src', dir +'open.png '); 49 } 50 }); 51 52 }); 53 function ini_textbox(name){ 54 var a =jQuery("#selectoc_id"); 55 a.attr('title',name); 56 } 57 var dom = document.getElementById("selectoc_id"); 58 if(dom && dom.value.match(/curID/)) { 59 dom.value = JSINFO['id']; 60 jQuery( "#selectoc_btn" ).click(); 61 ini_textbox(JSINFO['id']); 62 } 63 else { 64 var cval = tocsel_getCookie('tocselect'); 65 if(cval && document.getElementById("selectoc_id")) { 66 cval = cval.replace(/%3A/g,':'); 67 document.getElementById("selectoc_id").value = cval; 68 jQuery( "#selectoc_btn" ).click(); 69 ini_textbox(cval); 70 } 71 } 72 }); 73 74 75 function tocsel_updatetoc(name) { 76 var dom = document.getElementById("selectoc_id"); 77 dom.value = name; 78 jQuery( "#selectoc_btn" ).click(); 79 } 80 81 function tocsel_getCookie(cname) { 82 var name = cname + "="; 83 var ca = document.cookie.split(';'); 84 for(var i = 0; i <ca.length; i++) { 85 var c = ca[i]; 86 while (c.charAt(0)==' ') { 87 c = c.substring(1); 88 } 89 if (c.indexOf(name) == 0) { 90 return c.substring(name.length,c.length); 91 } 92 } 93 return ""; 94}