This file contains 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
/** | |
* Convert wildcard pattern to RegExp | |
* Pattern: | |
* * - Zero or more characters | |
* ? - Exactly one character | |
* | |
* @param {String} pattern Wildcard pattern | |
* @returns {RegExp} regular expression for wildcard matching | |
*/ | |
function wc2reg(pattern) { |
This file contains 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
// A Dict class that works in ES6 using Map. Basically it's identical to Map, but | |
// only expected to be used on string keys. | |
function Dict() { | |
this.elts = new Map(); | |
} | |
// (string) -> any | |
Dict.prototype.get = function get(key) { | |
return this.elts.get(key); |
This file contains 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
var REGEX = { | |
NUMBER : /^-?[0-9]*\.?[0-9]+$/, | |
KEYWORD : /^(?:top\s+|bottom\s+)?(?:right|left)|(?:right\s+|left\s+)?(?:top|bottom)$/ | |
}; | |
var direction = RegExp([ | |
'^(?:', | |
REGEX.NUMBER.source.slice(1, -1), | |
'|', | |
'(?:', REGEX.KEYWORD.source.slice(1, -1), ')deg', |
This file contains 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() { |
This file contains 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
!function() { | |
var doc = document, | |
htm = doc.documentElement, | |
lct = null, // last click target | |
nearest = function(elm, tag) { | |
while (elm && elm.nodeName != tag) { | |
elm = elm.parentNode; | |
} | |
return elm; | |
}; |