MediaWiki:Common.js: verschil tussen versies
Uit Dorpsbelang Den Hout
Regel 80: | Regel 80: | ||
sp.innerHTML = this.value+'<input type="hidden" name="tags[]" value="'+this.value+'">'; | sp.innerHTML = this.value+'<input type="hidden" name="tags[]" value="'+this.value+'">'; | ||
− | |||
− | |||
sp.addEventListener('click', function(){ | sp.addEventListener('click', function(){ | ||
this.remove(); | this.remove(); |
Versie van 6 nov 2020 10:26
// JavaScript die hier wordt geplaatst heeft invloed op alle pagina's voor alle gebruikers <script> function removeFile(el, file){ var message = confirm("Weet je zeker dat je dit bestand wilt verwijderen?") if(message == true){ var params = { action: 'delete', title: file, format: 'json' }, api = new mw.Api(); api.postWithToken( 'csrf', params ).done( function ( data ) { console.log( data ); el.closest('.upload-group').remove(); } ); } } function postBericht(el, template, mode){ var titel = ""; var domein = ""; var parameters = ""; var multiparameters = {}; var inputs = el.closest('form').querySelectorAll('textarea, input:not([name="mwreturn"] ):not([name="mwdb"] ):not([name="mwtoken"] ):not([type="file"]):not([name="mwaction"]):not([name="exclude"])'), i; for(i = 0; i < inputs.length; ++i){ if(inputs[i].name == "Titel"){titel = inputs[i].value}; if(inputs[i].name == "Domein"){domein = inputs[i].value}; if(inputs[i].type == "radio"){ if(inputs[i].checked){ parameters += '|'+inputs[i].name+'='+inputs[i].value; } }else{ if(inputs[i].name.includes("[]")){ if(!multiparameters[inputs[i].name.replace('[]', '')]){ multiparameters[inputs[i].name.replace('[]', '')] = []; } multiparameters[inputs[i].name.replace('[]', '')].push(inputs[i].value); }else{ parameters += '|'+inputs[i].name+'='+inputs[i].value; } } } if(mode == "domein"){ var url = domein.replace('.','-'); }else{ var url = domein.replace('.','-')+'/'+titel.replace(' ', '-'); } var multi = ""; for(i = 0; i < Object.keys(multiparameters).length; ++i){ multi += '|'+Object.keys(multiparameters)[i]+'='+multiparameters[Object.keys(multiparameters)[i]].toString(); } var wikitext = '{{'+template+parameters+multi+'}}' console.log(wikitext) var params = { action: 'edit', title: url, text: wikitext, format: 'json' }, api = new mw.Api(); api.postWithToken( 'csrf', params ).done( function ( html ) { window.location.href = window.location.origin+'/index.php/'+url; }) } var multiselect = document.querySelector('#multi-select2'); if(multiselect){ multiselect.addEventListener('change', function(){ var sp = document.createElement('span') sp.innerHTML = this.value+'<input type="hidden" name="tags[]" value="'+this.value+'">'; sp.addEventListener('click', function(){ this.remove(); }, false) document.querySelector('.out').appendChild(sp) this.value = ""}, false); } //js voor menu document.addEventListener('click', function(e){ // if(!e.target.closest('.main-menu li')){ document.querySelectorAll('.main-menu .hover').forEach(function(e){e.classList.remove('hover')}) // } if(e.target.closest('.main-menu li')){ // if(!e.target.href && !e.target.closest('li').classList.contains('hover')){ // e.target.closest('li').classList.add('hover') addthehover(e.target.closest('li')) // }else{ // e.target.closest('li').classList.remove('hover') // } } }) function addthehover(el){ el.classList.add('hover') var ml = el.closest('li'); if(ml == typeof Object){ console.log('?',ml) addthehover(ml) } } var _onPaste_StripFormatting_IEPaste = false; function OnPaste_StripFormatting(elem, e) { if (e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData) { e.preventDefault(); var text = e.originalEvent.clipboardData.getData('text/plain'); window.document.execCommand('insertText', false, text); } else if (e.clipboardData && e.clipboardData.getData) { e.preventDefault(); var text = e.clipboardData.getData('text/plain'); window.document.execCommand('insertText', false, text); } else if (window.clipboardData && window.clipboardData.getData) { // Stop stack overflow if (!_onPaste_StripFormatting_IEPaste) { _onPaste_StripFormatting_IEPaste = true; e.preventDefault(); window.document.execCommand('ms-pasteTextOnly', false); } _onPaste_StripFormatting_IEPaste = false; } }