Skip to content

Instantly share code, notes, and snippets.

@sillage
Created December 16, 2011 22:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sillage/1488397 to your computer and use it in GitHub Desktop.
Save sillage/1488397 to your computer and use it in GitHub Desktop.
common.js
// *********************************************************************
// 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
});
});
}
}
);
}
);
});
// *********************************************************************
@Frizlab
Copy link

Frizlab commented Dec 16, 2011

In which context should this script be run? What's its use?

@sillage
Copy link
Author

sillage commented Dec 16, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment