1jQuery(function () { 2 3 /** 4 * Execute the tracking script 5 */ 6 const addTracking = function () { 7 const script = jQuery('<script>'); 8 script.text(JSINFO.plugins.cookiebanner.script); 9 script.appendTo('head'); 10 }; 11 12 /** 13 * Handle nay clicks 14 */ 15 const nay = function () { 16 DokuCookie.setValue('pcb', 'nay'); 17 jQuery('.plugin-cookiebanner').remove(); 18 }; 19 20 /** 21 * Handle yes clicks 22 */ 23 const yay = function () { 24 DokuCookie.setValue('pcb', 'yay'); 25 jQuery('.plugin-cookiebanner').remove(); 26 addTracking(); 27 }; 28 29 /** 30 * Show the banner 31 */ 32 const showBanner = function () { 33 const $div = jQuery('<div>'); 34 $div.addClass('plugin-cookiebanner'); 35 $div.html(JSINFO.plugins.cookiebanner.text); 36 37 const $yay = jQuery('<button>'); 38 $yay.addClass('yay'); 39 $yay.text(LANG.plugins.cookiebanner.yay); 40 $yay.on('click', yay); 41 42 const $nay = jQuery('<button>'); 43 $nay.addClass('nay'); 44 $nay.text(LANG.plugins.cookiebanner.nay); 45 $nay.on('click', nay); 46 47 $div.append('<hr>'); 48 $div.append($yay); 49 $div.append($nay); 50 51 $div.appendTo('.dokuwiki'); 52 }; 53 54 // main: check cookie state and decide what to do 55 const state = DokuCookie.getValue('pcb', 'nope'); 56 if (state === 'nope') { 57 showBanner(); 58 } else if (state === 'yay') { 59 addTracking(); 60 } 61}); 62