123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- // please no
- module['exports'] = function zalgo(text, options) {
- text = text || " he is here ";
- var soul = {
- "up" : [
- '̍', '̎', '̄', '̅',
- '̿', '̑', '̆', '̐',
- '͒', '͗', '͑', '̇',
- '̈', '̊', '͂', '̓',
- '̈', '͊', '͋', '͌',
- '̃', '̂', '̌', '͐',
- '̀', '́', '̋', '̏',
- '̒', '̓', '̔', '̽',
- '̉', 'ͣ', 'ͤ', 'ͥ',
- 'ͦ', 'ͧ', 'ͨ', 'ͩ',
- 'ͪ', 'ͫ', 'ͬ', 'ͭ',
- 'ͮ', 'ͯ', '̾', '͛',
- '͆', '̚'
- ],
- "down" : [
- '̖', '̗', '̘', '̙',
- '̜', '̝', '̞', '̟',
- '̠', '̤', '̥', '̦',
- '̩', '̪', '̫', '̬',
- '̭', '̮', '̯', '̰',
- '̱', '̲', '̳', '̹',
- '̺', '̻', '̼', 'ͅ',
- '͇', '͈', '͉', '͍',
- '͎', '͓', '͔', '͕',
- '͖', '͙', '͚', '̣'
- ],
- "mid" : [
- '̕', '̛', '̀', '́',
- '͘', '̡', '̢', '̧',
- '̨', '̴', '̵', '̶',
- '͜', '͝', '͞',
- '͟', '͠', '͢', '̸',
- '̷', '͡', ' ҉'
- ]
- },
- all = [].concat(soul.up, soul.down, soul.mid),
- zalgo = {};
- function randomNumber(range) {
- var r = Math.floor(Math.random() * range);
- return r;
- }
- function is_char(character) {
- var bool = false;
- all.filter(function (i) {
- bool = (i === character);
- });
- return bool;
- }
-
- function heComes(text, options) {
- var result = '', counts, l;
- options = options || {};
- options["up"] = typeof options["up"] !== 'undefined' ? options["up"] : true;
- options["mid"] = typeof options["mid"] !== 'undefined' ? options["mid"] : true;
- options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true;
- options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi";
- text = text.split('');
- for (l in text) {
- if (is_char(l)) {
- continue;
- }
- result = result + text[l];
- counts = {"up" : 0, "down" : 0, "mid" : 0};
- switch (options.size) {
- case 'mini':
- counts.up = randomNumber(8);
- counts.mid = randomNumber(2);
- counts.down = randomNumber(8);
- break;
- case 'maxi':
- counts.up = randomNumber(16) + 3;
- counts.mid = randomNumber(4) + 1;
- counts.down = randomNumber(64) + 3;
- break;
- default:
- counts.up = randomNumber(8) + 1;
- counts.mid = randomNumber(6) / 2;
- counts.down = randomNumber(8) + 1;
- break;
- }
- var arr = ["up", "mid", "down"];
- for (var d in arr) {
- var index = arr[d];
- for (var i = 0 ; i <= counts[index]; i++) {
- if (options[index]) {
- result = result + soul[index][randomNumber(soul[index].length)];
- }
- }
- }
- }
- return result;
- }
- // don't summon him
- return heComes(text, options);
- }
|