Created
December 16, 2011 22:49
-
-
Save sillage/1488397 to your computer and use it in GitHub Desktop.
common.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ********************************************************************* | |
// Add a new button in the toolbar which replaces `s' caracters by a | |
// `ſ' (long s, old style), but NOT at the end of a word. | |
// ********************************************************************* | |
$(function() { | |
$.getScript('https://fr.wikisource.org/w/index.php?title=Utilisateur:FitzSai/xregexp.js&action=raw', // load XRegExp | |
function() { | |
$.getScript('https://fr.wikisource.org/w/index.php?title=Utilisateur:FitzSai/unicode-base.js&action=raw', // load Letter category only | |
function() { | |
// Check that the toolbar is available | |
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) { | |
// Execute on load | |
$( function() { | |
// General format: | |
// $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { configuration object here } ); | |
// Add a button to an existing toolbar group: | |
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |
section: 'advanced', | |
group: 'format', | |
tools: { | |
'long_s': { | |
label: 'ſ (long s)', | |
type: 'button', | |
icon: 'https://upload.wikimedia.org/wikipedia/commons/1/1d/Knop_vrouwelijk.png' | |
} | |
} | |
}); | |
$('img[rel="long_s"]').mouseup(function() { | |
$('#wpTextbox1').val($('#wpTextbox1').val().replace(XRegExp('s(?=\\p{L})', // regex to be matched | |
'g'), // global flag | |
'ſ')); // substitution | |
}); | |
}); | |
} | |
} | |
); | |
} | |
); | |
}); | |
// ********************************************************************* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In which context should this script be run? What's its use?