Χρήστης:Geraki/AddCoordinates.js
Μετά την αποθήκευση πρέπει να καθαρίσετε την κρυφή μνήμη (cache) του browser σας για να δείτε τις αλλαγές: Σε Chrome, Firefox, Safari, Internet Explorer και Edge: Κρατήστε πατημένο το ⇧ Shift και κάντε κλικ στο κουμπί Ανανέωση στην μπάρα εργαλείων.
/**
* Script to add coordinates
* coordinates: A location template to add
**/
var AddCoordinates = {
run : function() {
var coordinates = mw.util.getParamValue('coordinates');
if (coordinates==='') return;
var wptext = document.getElementById('wpTextbox1');
if (!wptext) return;
// Attempt to replace "no coordinate" tempalte
var newtext = wptext.value.replace(/\{\{[Gg]een coördinaten\}\}/g, coordinates);
// If not found, append to the end
if (wptext.value===newtext){
wptext.value = coordinates + '\n' + wptext.value ;
// If found, replace text with the replaced version
} else {
wptext.value = newtext;
}
// Set the edit summary automatically
var wpsummary = document.getElementById('wpSummary');
if (wpsummary) {
wpsummary.value = 'σήμανση';
}
// Click the "Show changes" button (make sure not to load this script again on the target page, to avoid an infinite loop!)
$('#wpSave').click();
}
};
if (wgAction==='edit') {
$(document).ready( AddCoordinates.run );
}