Completed
Push — master ( 651c35...c2f34b )
by greg
03:07
created

?!?.?!?   F

Complexity

Conditions 18
Paths 298

Size

Total Lines 48

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
nc 298
nop 1
dl 0
loc 48
cc 18
rs 3.6714

How to fix   Complexity   

Complexity

Complex classes like ?!?.?!? often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
2
// shim for using process in browser
3
var process = module.exports = {};
4
5
// cached from whatever global is present so that test runners that stub it
6
// don't break things.  But we need to wrap it in a try catch in case it is
7
// wrapped in strict mode code which doesn't define any globals.  It's inside a
8
// function because try/catches deoptimize in certain engines.
9
10
var cachedSetTimeout;
11
var cachedClearTimeout;
12
13
function defaultSetTimout() {
14
    throw new Error('setTimeout has not been defined');
15
}
16
function defaultClearTimeout () {
17
    throw new Error('clearTimeout has not been defined');
18
}
19
(function () {
20
    try {
21
        if (typeof setTimeout === 'function') {
0 ignored issues
show
Bug introduced by
The variable setTimeout seems to be never declared. If this is a global, consider adding a /** global: setTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
22
            cachedSetTimeout = setTimeout;
23
        } else {
24
            cachedSetTimeout = defaultSetTimout;
25
        }
26
    } catch (e) {
27
        cachedSetTimeout = defaultSetTimout;
28
    }
29
    try {
30
        if (typeof clearTimeout === 'function') {
0 ignored issues
show
Bug introduced by
The variable clearTimeout seems to be never declared. If this is a global, consider adding a /** global: clearTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
31
            cachedClearTimeout = clearTimeout;
32
        } else {
33
            cachedClearTimeout = defaultClearTimeout;
34
        }
35
    } catch (e) {
36
        cachedClearTimeout = defaultClearTimeout;
37
    }
38
} ())
39
function runTimeout(fun) {
40
    if (cachedSetTimeout === setTimeout) {
0 ignored issues
show
Bug introduced by
The variable setTimeout seems to be never declared. If this is a global, consider adding a /** global: setTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
41
        //normal enviroments in sane situations
42
        return setTimeout(fun, 0);
43
    }
44
    // if setTimeout wasn't available but was latter defined
45
    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable setTimeout is declared in the current environment, consider using typeof setTimeout === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
46
        cachedSetTimeout = setTimeout;
47
        return setTimeout(fun, 0);
48
    }
49
    try {
50
        // when when somebody has screwed with setTimeout but no I.E. maddness
51
        return cachedSetTimeout(fun, 0);
52
    } catch(e){
53
        try {
54
            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
55
            return cachedSetTimeout.call(null, fun, 0);
0 ignored issues
show
Bug introduced by
The variable cachedSetTimeout does not seem to be initialized in case cachedSetTimeout === def...etTimeout && setTimeout on line 45 is false. Are you sure this can never be the case?
Loading history...
56
        } catch(e){
57
            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
58
            return cachedSetTimeout.call(this, fun, 0);
59
        }
60
    }
61
62
63
}
64
function runClearTimeout(marker) {
65
    if (cachedClearTimeout === clearTimeout) {
0 ignored issues
show
Bug introduced by
The variable clearTimeout seems to be never declared. If this is a global, consider adding a /** global: clearTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
66
        //normal enviroments in sane situations
67
        return clearTimeout(marker);
68
    }
69
    // if clearTimeout wasn't available but was latter defined
70
    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable clearTimeout is declared in the current environment, consider using typeof clearTimeout === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
71
        cachedClearTimeout = clearTimeout;
72
        return clearTimeout(marker);
73
    }
74
    try {
75
        // when when somebody has screwed with setTimeout but no I.E. maddness
76
        return cachedClearTimeout(marker);
77
    } catch (e){
78
        try {
79
            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
80
            return cachedClearTimeout.call(null, marker);
0 ignored issues
show
Bug introduced by
The variable cachedClearTimeout does not seem to be initialized in case cachedClearTimeout === d...Timeout && clearTimeout on line 70 is false. Are you sure this can never be the case?
Loading history...
81
        } catch (e){
82
            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
83
            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
84
            return cachedClearTimeout.call(this, marker);
85
        }
86
    }
87
88
89
90
}
91
var queue = [];
92
var draining = false;
93
var currentQueue;
94
var queueIndex = -1;
95
96
function cleanUpNextTick() {
97
    if (!draining || !currentQueue) {
98
        return;
99
    }
100
    draining = false;
101
    if (currentQueue.length) {
102
        queue = currentQueue.concat(queue);
103
    } else {
104
        queueIndex = -1;
105
    }
106
    if (queue.length) {
107
        drainQueue();
108
    }
109
}
110
111
function drainQueue() {
112
    if (draining) {
113
        return;
114
    }
115
    var timeout = runTimeout(cleanUpNextTick);
116
    draining = true;
117
118
    var len = queue.length;
119
    while(len) {
120
        currentQueue = queue;
0 ignored issues
show
Bug introduced by
The variable queue is changed as part of the while loop for example by [] on line 121. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
121
        queue = [];
122
        while (++queueIndex < len) {
0 ignored issues
show
Bug introduced by
The variable queueIndex is changed as part of the while loop for example by ++queueIndex on line 122. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
123
            if (currentQueue) {
124
                currentQueue[queueIndex].run();
125
            }
126
        }
127
        queueIndex = -1;
128
        len = queue.length;
129
    }
130
    currentQueue = null;
131
    draining = false;
132
    runClearTimeout(timeout);
133
}
134
135
process.nextTick = function (fun) {
136
    var args = new Array(arguments.length - 1);
137
    if (arguments.length > 1) {
138
        for (var i = 1; i < arguments.length; i++) {
139
            args[i - 1] = arguments[i];
140
        }
141
    }
142
    queue.push(new Item(fun, args));
143
    if (queue.length === 1 && !draining) {
144
        runTimeout(drainQueue);
145
    }
146
};
147
148
// v8 likes predictible objects
149
function Item(fun, array) {
150
    this.fun = fun;
151
    this.array = array;
152
}
153
Item.prototype.run = function () {
154
    this.fun.apply(null, this.array);
155
};
156
process.title = 'browser';
157
process.browser = true;
158
process.env = {};
159
process.argv = [];
160
process.version = ''; // empty string to avoid regexp issues
161
process.versions = {};
162
163
function noop() {}
164
165
process.on = noop;
166
process.addListener = noop;
167
process.once = noop;
168
process.off = noop;
169
process.removeListener = noop;
170
process.removeAllListeners = noop;
171
process.emit = noop;
172
173
process.binding = function (name) {
0 ignored issues
show
Unused Code introduced by
The parameter name is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
174
    throw new Error('process.binding is not supported');
175
};
176
177
process.cwd = function () { return '/' };
178
process.chdir = function (dir) {
0 ignored issues
show
Unused Code introduced by
The parameter dir is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
179
    throw new Error('process.chdir is not supported');
180
};
181
process.umask = function() { return 0; };
182
183
},{}],2:[function(require,module,exports){
184
'use strict';
185
186
var speakingurl = require('speakingurl');
187
var pinyin = require('pinyin');
188
var hepburn = require('hepburn');
189
190
module.exports = function(text, opt) {
191
  var options = opt || {};
192
  var separateNumbers = true;
193
194
  if (typeof options === 'string') {
195
    options = {separator: options};
196
  }
197
198
  if (typeof options.separateNumbers !== 'undefined') {
199
    separateNumbers = options.separateNumbers;
200
  }
201
202
  // Remove apostrophes contained within a word
203
  text = text.replace(/(\S)['\u2018\u2019\u201A\u201B\u2032\u2035\u0301](\S)/g, '$1$2');
204
205
  // Break out any numbers contained within a word
206
  if (separateNumbers) {
207
    text = text.replace(/([^\d\s])([0-9]+)([^\d\s])/g, '$1 $2 $3');
208
  }
209
210
  // Should we remove the separator before a digit where previous word does not end in a digit?
211
  var mergeDigitSuffixes = false;
212
213
  // Language-specific behaviour
214
  var lang = options.lang;
215
  if (typeof lang === 'undefined') {
216
    if (hepburn.containsKana(text)) {
217
      // Convert from Japanese Kana using Hepburn romanisation
218
      text = hepburn.fromKana(text);
219
      // Remove any remaining non-Kana, e.g. Kanji
220
      text = text.replace(/([^A-Za-z0-9\- ]+)/g, '');
221
    } else if (/[\u4e00-\u9fa5]+/.test(text)) {
222
      // Convert Mandarin Chinese to Pinyin with numeric tones
223
      mergeDigitSuffixes = true;
224
      // Should we use tone numbers? (default is true)
225
      var tone = (typeof options.tone === 'boolean') ? options.tone : true;
226
      text = pinyin(text, {
227
        'style': tone ? pinyin.STYLE_TONE2 : pinyin.STYLE_NORMAL
228
      }).join(' ');
229
      // Remove punctuation symbols
230
      text = text.replace(/([^0-9A-Za-z ]+)/g, '');
231
      // Remove space around single character words, caused by non-Mandarin symbols in otherwise Mandarin text
232
      text = text.replace(/([^1-4]) ([A-Za-z]) /g, '$1$2');
233
    }
234
  }
235
  // Convert to slug using speakingurl
236
  var separator = options.replacement || options.separator;
237
  if (typeof separator !== 'string') {
238
    separator = '-';
239
  }
240
  var slug = speakingurl(text, {
241
    lang: lang || 'en',
242
    separator: separator
243
  });
244
  // Remove separator before a digit where previous word does not end in a digit
245
  if (mergeDigitSuffixes) {
246
    slug = slug.replace(/([^0-9])-([0-9])/g, '$1$2');
247
  }
248
  return slug;
249
};
250
251
},{"hepburn":3,"pinyin":5,"speakingurl":9}],3:[function(require,module,exports){
252
/*jslint node: true */
253
'use strict';
254
255
var bulkReplace = require("bulk-replace");
256
257
var hiraganaMonographs = {
258
  "あ": "A", "い": "I", "う": "U", "え": "E", "お": "O",
259
  "か": "KA", "き": "KI", "く": "KU", "け": "KE", "こ": "KO",
260
  "さ": "SA", "し": "SHI", "す": "SU", "せ": "SE", "そ": "SO",
261
  "た": "TA", "ち": "CHI", "つ": "TSU", "て": "TE", "と": "TO",
262
  "な": "NA", "に": "NI", "ぬ": "NU", "ね": "NE", "の": "NO",
263
  "は": "HA", "ひ": "HI", "ふ": "FU", "へ": "HE", "ほ": "HO",
264
  "ま": "MA", "み": "MI", "む": "MU", "め": "ME", "も": "MO",
265
  "や": "YA", "ゆ": "YU", "よ": "YO",
266
  "ら": "RA", "り": "RI", "る": "RU", "れ": "RE", "ろ": "RO",
267
  "わ": "WA", "ゐ": "WI", "ゑ": "WE", "を": "WO", "ん": "N'",
268
  "が": "GA", "ぎ": "GI", "ぐ": "GU", "げ": "GE", "ご": "GO",
269
  "ざ": "ZA", "じ": "JI", "ず": "ZU", "ぜ": "ZE", "ぞ": "ZO",
270
  "だ": "DA", "ぢ": "DJI", "づ": "DZU", "で": "DE", "ど": "DO",
271
  "ば": "BA", "び": "BI", "ぶ": "BU", "べ": "BE", "ぼ": "BO",
272
  "ぱ": "PA", "ぴ": "PI", "ぷ": "PU", "ぺ": "PE", "ぽ": "PO"
273
};
274
275
var hiraganaDigraphs = {
276
  "きゃ": "KYA", "きゅ": "KYU", "きょ": "KYO",
277
  "しゃ": "SHA", "しゅ": "SHU", "しょ": "SHO",
278
  "ちゃ": "CHA", "ちゅ": "CHU", "ちょ": "CHO",
279
  "にゃ": "NYA", "にゅ": "NYU", "にょ": "NYO",
280
  "ひゃ": "HYA", "ひゅ": "HYU", "ひょ": "HYO",
281
  "みゃ": "MYA", "みゅ": "MYU", "みょ": "MYO",
282
  "りゃ": "RYA", "りゅ": "RYU", "りょ": "RYO",
283
  "ぎゃ": "GYA", "ぎゅ": "GYU", "ぎょ": "GYO",
284
  "じゃ": "JA", "じゅ": "JU", "じょ": "JO",
285
  "びゃ": "BYA", "びゅ": "BYU", "びょ": "BYO",
286
  "ぴゃ": "PYA", "ぴゅ": "PYU", "ぴょ": "PYO"
287
};
288
289
var katakanaMonographs = {
290
  "ア": "A", "イ": "I", "ウ": "U", "エ": "E", "オ": "O",
291
  "カ": "KA", "キ": "KI", "ク": "KU", "ケ": "KE", "コ": "KO",
292
  "サ": "SA", "シ": "SHI", "ス": "SU", "セ": "SE", "ソ": "SO",
293
  "タ": "TA", "チ": "CHI", "ツ": "TSU", "テ": "TE", "ト": "TO",
294
  "ナ": "NA", "ニ": "NI", "ヌ": "NU", "ネ": "NE", "ノ": "NO",
295
  "ハ": "HA", "ヒ": "HI", "フ": "FU", "ヘ": "HE", "ホ": "HO",
296
  "マ": "MA", "ミ": "MI", "ム": "MU", "メ": "ME", "モ": "MO",
297
  "ヤ": "YA", "ユ": "YU", "ヨ": "YO",
298
  "ラ": "RA", "リ": "RI", "ル": "RU", "レ": "RE", "ロ": "RO",
299
  "ワ": "WA", "ヰ": "WI", "ヱ": "WE",  "ヲ": "WO", "ン": "N",
300
  "ガ": "GA", "ギ": "GI", "グ": "GU", "ゲ": "GE", "ゴ": "GO",
301
  "ザ": "ZA", "ジ": "JI", "ズ": "ZU", "ゼ": "ZE", "ゾ": "ZO",
302
  "ダ": "DA", "ヂ": "DJI", "ヅ": "DZU", "デ": "DE", "ド": "DO",
303
  "バ": "BA", "ビ": "BI", "ブ": "BU", "ベ": "BE", "ボ": "BO",
304
  "パ": "PA", "ピ": "PI", "プ": "PU", "ペ": "PE", "ポ": "PO"
305
};
306
307
var katakanaDigraphs = {
308
  "アー": "Ā", "イー": "Ī", "ウー": "Ū", "エー": "Ē", "オー": "Ō",
309
  "カー": "KĀ", "キー": "KĪ", "クー": "KŪ", "ケー": "KĒ", "コー": "KŌ",
310
  "サー": "SĀ", "シー": "SHĪ", "スー": "SŪ", "セー": "SĒ", "ソー": "SŌ",
311
  "ター": "TĀ", "チー": "CHĪ", "ツー": "TSŪ", "テー": "TĒ", "トー": "TŌ",
312
  "ナー": "NĀ", "ニー": "NĪ", "ヌー": "NŪ", "ネー": "NĒ", "ノー": "NŌ",
313
  "ハー": "HĀ", "ヒー": "HĪ", "フー": "FŪ", "ヘー": "HĒ", "ホー": "HŌ",
314
  "マー": "MĀ", "ミー": "MĪ", "ムー": "MŪ", "メー": "MĒ", "モー": "MŌ",
315
  "ヤー": "YĀ", "ユー": "YŪ", "ヨー": "YŌ",
316
  "ラー": "RĀ", "リー": "RĪ", "ルー": "RŪ", "レー": "RĒ", "ロー": "RŌ",
317
  "ワー": "WĀ", "ヰー": "WĪ", "ヱー": "WĒ",  "ヲー": "WŌ", "ンー": "N",
318
  "ガー": "GĀ", "ギー": "GĪ", "グー": "GŪ", "ゲー": "GĒ", "ゴー": "GŌ",
319
  "ザー": "ZĀ", "ジー": "JĪ", "ズー": "ZŪ", "ゼー": "ZĒ", "ゾー": "ZŌ",
320
  "ダー": "DĀ", "ヂー": "DJĪ", "ヅー": "DZŪ", "デー": "DĒ", "ドー": "DŌ",
321
  "バー": "BĀ", "ビー": "BĪ", "ブー": "BŪ", "ベー": "BĒ", "ボー": "BŌ",
322
  "パー": "PĀ", "ピー": "PĪ", "プー": "PŪ", "ペー": "PĒ", "ポー": "PŌ",
323
  "キャ": "KYA", "キュ": "KYU", "キョ": "KYO",
324
  "シャ": "SHA", "シュ": "SHU", "ショ": "SHO",
325
  "チャ": "CHA", "チュ": "CHU", "チョ": "CHO",
326
  "ニャ": "NYA", "ニュ": "NYU", "ニョ": "NYO",
327
  "ヒャ": "HYA", "ヒュ": "HYU", "ヒョ": "HYO",
328
  "ミャ": "MYA", "ミュ": "MYU", "ミョ": "MYO",
329
  "リャ": "RYA", "リュ": "RYU", "リョ": "RYO",
330
  "ギャ": "GYA", "ギュ": "GYU", "ギョ": "GYO",
331
  "ジャ": "JA", "ジュ": "JU", "ジョ": "JO",
332
  "ビャ": "BYA", "ビュ": "BYU", "ビョ": "BYO",
333
  "ピャ": "PYA", "ピュ": "PYU", "ピョ": "PYO"
334
};
335
336
var katakanaTrigraphs = {
337
  "キャー": "KYĀ", "キュー": "KYŪ", "キョー": "KYŌ",
338
  "シャー": "SHĀ", "シュー": "SHŪ", "ショー": "SHŌ",
339
  "チャー": "CHĀ", "チュー": "CHŪ", "チョー": "CHŌ",
340
  "ニャー": "NYĀ", "ニュー": "NYŪ", "ニョー": "NYŌ",
341
  "ヒャー": "HYĀ", "ヒュー": "HYŪ", "ヒョー": "HYŌ",
342
  "ミャー": "MYĀ", "ミュー": "MYŪ", "ミョー": "MYŌ",
343
  "リャー": "RYĀ", "リュー": "RYŪ", "リョー": "RYŌ",
344
  "ギャー": "GYĀ", "ギュー": "GYŪ", "ギョー": "GYŌ",
345
  "ジャー": "JĀ", "ジュー": "JŪ", "ジョー": "JŌ",
346
  "ビャー": "BYĀ", "ビュー": "BYŪ", "ビョー": "BYŌ",
347
  "ピャー": "PYĀ", "ピュー": "PYŪ", "ピョー": "PYŌ"
348
};
349
350
// Used to convert old Nihon-Shiki style romaji into the modern Hepburn form.
351
// Source: http://nayuki.eigenstate.org/page/variations-on-japanese-romanization
352
var nihonShiki = {
353
    "SI": "SHI",
354
    "ZI": "JI",
355
    "TI": "CHI",
356
    "DI": "JI",
357
    "TU": "TSU",
358
    "DU": "ZU",
359
    "SHU": "SHU", // Prevent HU from accidentally converting
360
    "CHU": "CHU",
361
    "HU": "FU",
362
    "CYA": "CHA",
363
    "CYO": "CHO",
364
    "CYU": "CHU",
365
    "SYA": "SHA",
366
    "SYU": "SHU",
367
    "SYO": "SHO",
368
    "ZYA": "JA",
369
    "ZYU": "JU",
370
    "ZYO": "JO",
371
    "TYA": "CHA",
372
    "TYU": "CHU",
373
    "TYO": "CHO",
374
    "DYA": "JA",
375
    "DYU": "JU",
376
    "DYO": "JO"
377
};
378
379
// For use with toHiragana
380
var hiraganaMap = {};
381
382
Object.keys(hiraganaMonographs).forEach(function(key) {
383
  var value = hiraganaMonographs[key];
384
  if (!(value in hiraganaMap)) {
385
    hiraganaMap[value] = key;
386
  }
387
});
388
389
Object.keys(hiraganaDigraphs).forEach(function(key) {
390
  var value = hiraganaDigraphs[key];
391
  if (!(value in hiraganaMap)) {
392
    hiraganaMap[value] = key;
393
  }
394
});
395
396
var hiraganaRegex = new RegExp(Object.keys(hiraganaMap).sort(function(a, b) {
397
  return b.length - a.length;
398
}).join("|"), "g");
399
400
// For use with toKatakana
401
var katakanaMap = {};
402
403
Object.keys(katakanaMonographs).forEach(function(key) {
404
  var value = katakanaMonographs[key];
405
  if (!(value in katakanaMap)) {
406
    katakanaMap[value] = key;
407
  }
408
});
409
410
Object.keys(katakanaDigraphs).forEach(function(key) {
411
  var value = katakanaDigraphs[key];
412
  if (!(value in katakanaMap)) {
413
    katakanaMap[value] = key;
414
  }
415
});
416
417
Object.keys(katakanaTrigraphs).forEach(function(key) {
418
  var value = katakanaTrigraphs[key];
419
  if (!(value in katakanaMap)) {
420
    katakanaMap[value] = key;
421
  }
422
});
423
424
var katakanaRegex = new RegExp(Object.keys(katakanaMap).sort(function(a, b) {
425
  return b.length - a.length;
426
}).join("|"), "g");
427
428
// API
429
430
exports.fromKana = function(str) {
431
  // Initial transliteration
432
  str = bulkReplace(str, hiraganaDigraphs);
433
  str = bulkReplace(str, katakanaDigraphs);
434
  str = bulkReplace(str, hiraganaMonographs);
435
  str = bulkReplace(str, katakanaMonographs);
436
437
  // Correct use of sokuon
438
  str = str.replace(/っC/g, "TC").replace(/っ(.)/g, "$1$1");
439
  str = str.replace(/ッC/g, "TC").replace(/ッ(.)/g, "$1$1");
440
441
  // Correct usage of N' (M' is a common mistake)
442
  str = str.replace(/[NM]'([^YAEIOU]|$)/g, "N$1");
443
444
  // Correct use of choonpu
445
  str = str.replace(/Aー/g, "Ā");
446
  str = str.replace(/Iー/g, "Ī");
447
  str = str.replace(/Uー/g, "Ū");
448
  str = str.replace(/Eー/g, "Ē");
449
  str = str.replace(/Oー/g, "Ō");
450
451
  return str;
452
};
453
454
exports.toHiragana = function(str) {
455
  // All conversion is done in upper-case
456
  str = str.toUpperCase();
457
458
  // Correct use of sokuon
459
  str = str.replace(/TC/g, "っC");
460
  str = str.replace(/([^AEIOUN])\1/g, "っ$1");
461
462
  // Transliteration
463
  str = bulkReplace(str, hiraganaRegex, hiraganaMap);
464
465
  // Fix any remaining N/M usage (that isn't a N' usage)
466
  str = str.replace(/N|M/g, "ん");
467
468
  return str;
469
};
470
471
exports.toKatakana = function(str) {
472
  // All conversion is done in upper-case
473
  str = str.toUpperCase();
474
475
  // Correct use of sokuon
476
  str = str.replace(/TC/g, "ッC");
477
  str = str.replace(/([^AEIOUN])\1/g, "ッ$1");
478
479
  // Transliteration
480
  str = bulkReplace(str, katakanaRegex, katakanaMap);
481
482
  // Fix any remaining N/M usage (that isn't a N' usage)
483
  str = str.replace(/N|M/g, "ン");
484
485
  return str;
486
};
487
488
exports.cleanRomaji = function(str) {
489
  // Follows many of the suggestions from:
490
  // http://nayuki.eigenstate.org/page/variations-on-japanese-romanization
491
492
  // All conversion is done in upper-case
493
  str = str.toUpperCase();
494
495
  // Should be using N instead of M
496
  str = str.replace(/(\w)M([^AEIOUY]|$)/g, "$1N$2");
497
498
  // Convert the NN form into the more common N'
499
  str = str.replace(/NN/g, "N'");
500
501
  // Convert usage of OU into the more common OO
502
  // Handle cases like Toukyou
503
  str = str.replace(/OU/g, "OO");
504
505
  // Fix antiquated usage of OH to mean OO
506
  // (handle ambiguous cases like 'Kohusai' vs. 'Tohkyoh')
507
  str = str.replace(/OH([^AIEO]|$)/g, "OO$1");
508
509
  // Replace old Nihon-shiki usage with modern Hepburn form
510
  str = bulkReplace(str, nihonShiki);
511
512
  return str;
513
};
514
515
exports.containsHiragana = function(str) {
516
  return new RegExp(Object.keys(hiraganaMonographs).join('|')).test(str);
517
};
518
519
exports.containsKatakana = function(str) {
520
  return new RegExp(Object.keys(katakanaMonographs).join('|')).test(str);
521
};
522
523
exports.containsKana = function(str){
524
  return (exports.containsHiragana(str) || exports.containsKatakana(str));
525
};
526
527
},{"bulk-replace":4}],4:[function(require,module,exports){
528
module.exports = function(str, regex, map) {
529
    if (arguments.length === 2) {
530
        map = regex;
531
        regex = new RegExp(Object.keys(map).join("|"), "ig");
532
    }
533
534
    return str.replace(regex, function(all) {
535
        if (all in map) {
536
            return map[all];
537
        }
538
539
        return all;
540
    });
541
};
542
543
},{}],5:[function(require,module,exports){
544
545
module.exports = require("./src/pinyin");
546
547
},{"./src/pinyin":8}],6:[function(require,module,exports){
548
module.exports = {
549
"èr":"二贰",
550
"shí":"十时实蚀",
551
"yǐ":"乙已以蚁倚",
552
"yī":"一衣医依伊揖壹",
553
"chǎng,ān,hàn":"厂",
554
"dīng,zhēng":"丁",
555
"qī":"七戚欺漆柒凄嘁",
556
"bǔ,bo":"卜",
557
"rén":"人仁",
558
"rù":"入褥",
559
"jiǔ":"九久酒玖灸韭",
560
"ér":"儿而",
561
"bā":"八巴疤叭芭捌笆",
562
"jǐ,jī":"几",
563
"le,liǎo":"了",
564
"lì":"力历厉立励利例栗粒吏沥荔俐莉砾雳痢",
565
"dāo":"刀",
566
"nǎi":"乃奶",
567
"sān":"三叁",
568
"yòu":"又右幼诱佑",
569
"yú":"于余鱼娱渔榆愚隅逾舆",
570
"shì":"士示世市式势事侍饰试视柿是适室逝释誓拭恃嗜",
571
"gān,gàn":"干",
572
"gōng":"工弓公功攻宫恭躬",
573
"kuī":"亏盔窥",
574
"tǔ":"土",
575
"cùn":"寸",
576
"dà,dài,tài":"大",
577
"cái":"才材财裁",
578
"xià":"下夏",
579
"zhàng":"丈仗帐胀障杖账",
580
"yǔ,yù,yú":"与",
581
"shàng,shǎng":"上",
582
"wàn,mò":"万",
583
"kǒu":"口",
584
"xiǎo":"小晓",
585
"jīn":"巾斤今金津筋襟",
586
"shān":"山删衫珊",
587
"qiān":"千迁牵谦签",
588
"qǐ":"乞企启起",
589
"chuān":"川穿",
590
"gè,gě":"个各",
591
"sháo":"勺芍",
592
"yì":"亿义艺忆议亦异役译易疫益谊意毅翼屹抑邑绎奕逸肄溢",
593
"jí":"及吉级极即急疾集籍棘辑嫉",
594
"fán":"凡烦矾樊",
595
"xī":"夕西吸希析牺息悉惜稀锡溪熄膝昔晰犀熙嬉蟋",
596
"wán":"丸完玩顽",
597
"me,mó,ma,yāo":"么",
598
"guǎng,ān":"广",
599
"wáng,wú":"亡",
600
"mén":"门们",
601
"shī":"尸失师诗狮施湿虱",
602
"zhī":"之支汁芝肢脂蜘",
603
"jǐ":"己挤脊",
604
"zǐ":"子紫姊籽滓",
605
"wèi":"卫未位味畏胃喂慰谓猬蔚魏",
606
"yě":"也冶野",
607
"nǚ,rǔ":"女",
608
"rèn":"刃认韧纫",
609
"fēi":"飞非啡",
610
"xí":"习席袭媳",
611
"mǎ":"马码玛",
612
"chā,chá,chǎ":"叉",
613
"fēng":"丰封疯峰锋蜂枫",
614
"xiāng":"乡香箱厢湘镶",
615
"jǐng":"井警阱",
616
"wáng,wàng":"王",
617
"kāi":"开揩",
618
"tiān":"天添",
619
"wú":"无吴芜梧蜈",
620
"fū,fú":"夫",
621
"zhuān":"专砖",
622
"yuán":"元园原圆援缘源袁猿辕",
623
"yún":"云匀耘",
624
"zhā,zā,zhá":"扎",
625
"mù":"木目牧墓幕暮慕沐募睦穆",
626
"wǔ":"五午伍武侮舞捂鹉",
627
"tīng":"厅听",
628
"bù,fǒu":"不",
629
"qū,ōu":"区",
630
"quǎn":"犬",
631
"tài":"太态泰汰",
632
"yǒu":"友",
633
"chē,jū":"车",
634
"pǐ":"匹",
635
"yóu":"尤由邮犹油游",
636
"jù":"巨拒具俱剧距惧锯聚炬",
637
"yá":"牙芽崖蚜涯衙",
638
"bǐ":"比彼笔鄙匕秕",
639
"jiē":"皆阶接街秸",
640
"hù":"互户护沪",
641
"qiè,qiē":"切",
642
"wǎ,wà":"瓦",
643
"zhǐ":"止旨址纸指趾",
644
"tún,zhūn":"屯",
645
"shǎo,shào":"少",
646
"rì":"日",
647
"zhōng,zhòng":"中",
648
"gāng":"冈刚纲缸肛",
649
"nèi,nà":"内",
650
"bèi":"贝备倍辈狈惫焙",
651
"shuǐ":"水",
652
"jiàn,xiàn":"见",
653
"niú":"牛",
654
"shǒu":"手守首",
655
"máo":"毛矛茅锚",
656
"qì":"气弃汽器迄泣",
657
"shēng":"升生声牲笙甥",
658
"cháng,zhǎng":"长",
659
"shén,shí":"什",
660
"piàn,piān":"片",
661
"pú,pū":"仆",
662
"huà,huā":"化",
663
"bì":"币必毕闭毙碧蔽弊避壁庇蓖痹璧",
664
"chóu,qiú":"仇",
665
"zhuǎ,zhǎo":"爪",
666
"jǐn,jìn":"仅",
667
"réng":"仍",
668
"fù,fǔ":"父",
669
"cóng,zòng":"从",
670
"fǎn":"反返",
671
"jiè":"介戒届界借诫",
672
"xiōng":"凶兄胸匈汹",
673
"fēn,fèn":"分",
674
"fá":"乏伐罚阀筏",
675
"cāng":"仓苍舱沧",
676
"yuè":"月阅悦跃越岳粤",
677
"shì,zhī":"氏",
678
"wù":"勿务物误悟雾坞晤",
679
"qiàn":"欠歉",
680
"fēng,fěng":"风",
681
"dān":"丹耽",
682
"wū":"乌污呜屋巫诬",
683
"fèng":"凤奉",
684
"gōu,gòu":"勾",
685
"wén":"文闻蚊",
686
"liù,lù":"六",
687
"huǒ":"火伙",
688
"fāng":"方芳",
689
"dǒu,dòu":"斗",
690
"wèi,wéi":"为",
691
"dìng":"订定锭",
692
"jì":"计记技忌际季剂迹既继寄绩妓荠寂鲫冀",
693
"xīn":"心辛欣新薪锌",
694
"chǐ,chě":"尺",
695
"yǐn":"引饮蚓瘾",
696
"chǒu":"丑",
697
"kǒng":"孔恐",
698
"duì":"队对",
699
"bàn":"办半扮伴瓣绊",
700
"yǔ,yú":"予",
701
"yǔn":"允陨",
702
"quàn":"劝",
703
"shū":"书叔殊梳舒疏输蔬抒枢淑",
704
"shuāng":"双霜",
705
"yù":"玉育狱浴预域欲遇御裕愈誉芋郁喻寓豫",
706
"huàn":"幻换唤患宦涣焕痪",
707
"kān":"刊堪勘",
708
"mò":"末沫漠墨默茉陌寞",
709
"jī":"击饥圾机肌鸡积基激讥叽唧畸箕",
710
"dǎ,dá":"打",
711
"qiǎo":"巧",
712
"zhèng,zhēng":"正症挣",
713
"pū":"扑",
714
"bā,pá":"扒",
715
"gān":"甘肝竿柑",
716
"qù":"去",
717
"rēng":"扔",
718
"gǔ":"古谷股鼓",
719
"běn":"本",
720
"jié,jiē":"节结",
721
"shù,shú,zhú":"术",
722
"bǐng":"丙柄饼秉禀",
723
"kě,kè":"可",
724
"zuǒ":"左",
725
"bù":"布步怖部埠",
726
"shí,dàn":"石",
727
"lóng":"龙聋隆咙胧窿",
728
"yà":"轧亚讶",
729
"miè":"灭蔑",
730
"píng":"平评凭瓶萍坪",
731
"dōng":"东冬",
732
"kǎ,qiǎ":"卡",
733
"běi,bèi":"北",
734
"yè":"业页夜液谒腋",
735
"jiù":"旧救就舅臼疚",
736
"shuài":"帅蟀",
737
"guī":"归规闺硅瑰",
738
"zhàn,zhān":"占",
739
"dàn":"旦但诞淡蛋氮",
740
"qiě,jū":"且",
741
"yè,xié":"叶",
742
"jiǎ":"甲钾",
743
"dīng":"叮盯",
744
"shēn":"申伸身深呻绅",
745
"hào,háo":"号",
746
"diàn":"电店垫殿玷淀惦奠",
747
"tián":"田甜恬",
748
"shǐ":"史使始驶矢屎",
749
"zhī,zhǐ":"只",
750
"yāng":"央殃秧鸯",
751
"diāo":"叼雕刁碉",
752
"jiào":"叫轿较窖酵",
753
"lìng":"另",
754
"dāo,tāo":"叨",
755
"sì":"四寺饲肆",
756
"tàn":"叹炭探碳",
757
"qiū":"丘秋蚯",
758
"hé":"禾河荷盒",
759
"fù":"付负妇附咐赴复傅富腹覆赋缚",
760
"dài":"代带贷怠袋逮戴",
761
"xiān":"仙先掀锨",
762
"yí":"仪宜姨移遗夷胰",
763
"bái":"白",
764
"zǎi,zǐ,zī":"仔",
765
"chì":"斥赤翅",
766
"tā":"他它塌",
767
"guā":"瓜刮",
768
"hū":"乎呼忽",
769
"cóng":"丛",
770
"lìng,líng,lǐng":"令",
771
"yòng":"用",
772
"shuǎi":"甩",
773
"yìn":"印",
774
"lè,yuè":"乐",
775
"jù,gōu":"句",
776
"cōng":"匆葱聪囱",
777
"fàn":"犯饭泛范贩",
778
"cè":"册厕测策",
779
"wài":"外",
780
"chù,chǔ":"处",
781
"niǎo":"鸟",
782
"bāo":"包胞苞褒",
783
"zhǔ":"主煮嘱拄",
784
"shǎn":"闪陕",
785
"lán":"兰拦栏蓝篮澜",
786
"tóu,tou":"头",
787
"huì":"汇绘贿惠慧讳诲晦秽",
788
"hàn":"汉旱捍悍焊撼翰憾",
789
"tǎo":"讨",
790
"xué":"穴学",
791
"xiě":"写",
792
"níng,nìng,zhù":"宁",
793
"ràng":"让",
794
"lǐ":"礼李里理鲤",
795
"xùn":"训讯迅汛驯逊殉",
796
"yǒng":"永咏泳勇蛹踊",
797
"mín":"民",
798
"chū":"出初",
799
"ní":"尼",
800
"sī":"司丝私斯撕嘶",
801
"liáo":"辽疗僚聊寥嘹缭",
802
"jiā":"加佳嘉枷",
803
"nú":"奴",
804
"zhào,shào":"召",
805
"biān":"边编鞭蝙",
806
"pí":"皮疲脾啤",
807
"yùn":"孕运韵酝蕴",
808
"fā,fà":"发",
809
"shèng":"圣胜剩",
810
"tái,tāi":"台苔",
811
"jiū":"纠究揪鸠",
812
"mǔ":"母亩牡拇姆",
813
"káng,gāng":"扛",
814
"xíng":"刑形型邢",
815
"dòng":"动冻栋洞",
816
"kǎo":"考烤拷",
817
"kòu":"扣寇",
818
"tuō":"托拖脱",
819
"lǎo":"老",
820
"gǒng":"巩汞拱",
821
"zhí":"执直侄值职植",
822
"kuò":"扩阔廓",
823
"yáng":"扬阳杨洋",
824
"dì,de":"地",
825
"sǎo,sào":"扫",
826
"chǎng,cháng":"场",
827
"ěr":"耳尔饵",
828
"máng":"芒忙盲茫",
829
"xiǔ":"朽",
830
"pǔ,pò,pō,piáo":"朴",
831
"quán":"权全泉拳痊",
832
"guò,guo,guō":"过",
833
"chén":"臣尘辰沉陈晨忱",
834
"zài":"再在",
835
"xié":"协胁斜携鞋谐",
836
"yā,yà":"压",
837
"yàn":"厌艳宴验雁焰砚唁谚堰",
838
"yǒu,yòu":"有",
839
"cún":"存",
840
"bǎi":"百摆",
841
"kuā,kuà":"夸",
842
"jiàng":"匠酱",
843
"duó":"夺踱",
844
"huī":"灰挥恢辉徽",
845
"dá":"达",
846
"sǐ":"死",
847
"liè":"列劣烈猎",
848
"guǐ":"轨鬼诡",
849
"xié,yá,yé,yú,xú":"邪",
850
"jiá,jiā,gā,xiá":"夹",
851
"chéng":"成呈诚承城程惩橙",
852
"mài":"迈麦卖",
853
"huà,huá":"划",
854
"zhì":"至志帜制质治致秩智置挚掷窒滞稚",
855
"cǐ":"此",
856
"zhēn":"贞针侦珍真斟榛",
857
"jiān":"尖奸歼坚肩艰兼煎",
858
"guāng":"光",
859
"dāng,dàng":"当",
860
"zǎo":"早枣澡蚤藻",
861
"tù,tǔ":"吐",
862
"xià,hè":"吓",
863
"chóng":"虫崇",
864
"tuán":"团",
865
"tóng,tòng":"同",
866
"qū,qǔ":"曲",
867
"diào":"吊钓掉",
868
"yīn":"因阴音姻茵",
869
"chī":"吃嗤痴",
870
"ma,má,mǎ":"吗",
871
"yǔ":"屿宇羽",
872
"fān":"帆翻",
873
"huí":"回茴蛔",
874
"qǐ,kǎi":"岂",
875
"zé":"则责",
876
"suì":"岁碎穗祟遂隧",
877
"ròu":"肉",
878
"zhū,shú":"朱",
879
"wǎng":"网往枉",
880
"nián":"年",
881
"diū":"丢",
882
"shé":"舌",
883
"zhú":"竹逐烛",
884
"qiáo":"乔侨桥瞧荞憔",
885
"wěi":"伟伪苇纬萎",
886
"chuán,zhuàn":"传",
887
"pāng":"乓",
888
"pīng":"乒",
889
"xiū,xǔ":"休",
890
"fú":"伏扶俘浮符幅福凫芙袱辐蝠",
891
"yōu":"优忧悠幽",
892
"yán":"延严言岩炎沿盐颜阎蜒檐",
893
"jiàn":"件建荐贱剑健舰践鉴键箭涧",
894
"rèn,rén":"任",
895
"huá,huà,huā":"华",
896
"jià,jiè,jie":"价",
897
"shāng":"伤商",
898
"fèn,bīn":"份",
899
"fǎng":"仿访纺",
900
"yǎng,áng":"仰",
901
"zì":"自字",
902
"xiě,xuè":"血",
903
"xiàng":"向项象像橡",
904
"sì,shì":"似",
905
"hòu":"后厚候",
906
"zhōu":"舟州周洲",
907
"háng,xíng":"行",
908
"huì,kuài":"会",
909
"shā":"杀纱杉砂",
910
"hé,gě":"合",
911
"zhào":"兆赵照罩",
912
"zhòng":"众仲",
913
"yé":"爷",
914
"sǎn":"伞",
915
"chuàng,chuāng":"创",
916
"duǒ":"朵躲",
917
"wēi":"危威微偎薇巍",
918
"xún":"旬寻巡询循",
919
"zá":"杂砸",
920
"míng":"名明鸣铭螟",
921
"duō":"多哆",
922
"zhēng":"争征睁筝蒸怔狰",
923
"sè":"色涩瑟",
924
"zhuàng":"壮状撞",
925
"chōng,chòng":"冲",
926
"bīng":"冰兵",
927
"zhuāng":"庄装妆桩",
928
"qìng":"庆",
929
"liú":"刘留流榴琉硫瘤",
930
"qí,jì,zī,zhāi":"齐",
931
"cì":"次赐",
932
"jiāo":"交郊浇娇骄胶椒焦蕉礁",
933
"chǎn":"产铲阐",
934
"wàng":"妄忘旺望",
935
"chōng":"充",
936
"wèn":"问",
937
"chuǎng":"闯",
938
"yáng,xiáng":"羊",
939
"bìng,bīng":"并",
940
"dēng":"灯登蹬",
941
"mǐ":"米",
942
"guān":"关官棺",
943
"hàn,hán":"汗",
944
"jué":"决绝掘诀爵",
945
"jiāng":"江姜僵缰",
946
"tāng,shāng":"汤",
947
"chí":"池驰迟持弛",
948
"xīng,xìng":"兴",
949
"zhái":"宅",
950
"ān":"安氨庵鞍",
951
"jiǎng":"讲奖桨蒋",
952
"jūn":"军均君钧",
953
"xǔ,hǔ":"许",
954
"fěng":"讽",
955
"lùn,lún":"论",
956
"nóng":"农浓脓",
957
"shè":"设社舍涉赦",
958
"nà,nǎ,nèi,nā":"那",
959
"jìn,jǐn":"尽",
960
"dǎo":"导岛蹈捣祷",
961
"sūn,xùn":"孙",
962
"zhèn":"阵振震镇",
963
"shōu":"收",
964
"fáng":"防妨房肪",
965
"rú":"如儒蠕",
966
"mā":"妈",
967
"xì,hū":"戏",
968
"hǎo,hào":"好",
969
"tā,jiě":"她",
970
"guān,guàn":"观冠",
971
"huān":"欢",
972
"hóng,gōng":"红",
973
"mǎi":"买",
974
"xiān,qiàn":"纤",
975
"jì,jǐ":"纪济",
976
"yuē,yāo":"约",
977
"shòu":"寿受授售兽瘦",
978
"nòng,lòng":"弄",
979
"jìn":"进近晋浸",
980
"wéi":"违围唯维桅",
981
"yuǎn,yuàn":"远",
982
"tūn":"吞",
983
"tán":"坛谈痰昙谭潭檀",
984
"fǔ":"抚斧府俯辅腐甫脯",
985
"huài,pēi,pī,péi":"坏",
986
"rǎo":"扰",
987
"pī":"批披坯霹",
988
"zhǎo":"找沼",
989
"chě":"扯",
990
"zǒu":"走",
991
"chāo":"抄钞超",
992
"bà":"坝爸霸",
993
"gòng":"贡",
994
"zhé,shé,zhē":"折",
995
"qiǎng,qiāng,chēng":"抢",
996
"zhuā":"抓",
997
"xiào":"孝笑效哮啸",
998
"pāo":"抛",
999
"tóu":"投",
1000
"kàng":"抗炕",
1001
"fén":"坟焚",
1002
"kēng":"坑",
1003
"dǒu":"抖陡蚪",
1004
"ké,qiào":"壳",
1005
"fāng,fáng":"坊",
1006
"niǔ":"扭纽钮",
1007
"kuài":"块快筷",
1008
"bǎ,bà":"把",
1009
"bào":"报抱爆豹",
1010
"jié":"劫杰洁捷截竭",
1011
"què":"却确鹊",
1012
"huā":"花",
1013
"fēn":"芬吩纷氛",
1014
"qín":"芹琴禽勤秦擒",
1015
"láo":"劳牢",
1016
"lú":"芦炉卢庐颅",
1017
"gān,gǎn":"杆",
1018
"kè":"克刻客课",
1019
"sū,sù":"苏",
1020
"dù":"杜渡妒镀",
1021
"gàng,gāng":"杠",
1022
"cūn":"村",
1023
"qiú":"求球囚",
1024
"xìng":"杏幸性姓",
1025
"gèng,gēng":"更",
1026
"liǎng":"两",
1027
"lì,lí":"丽",
1028
"shù":"束述树竖恕庶墅漱",
1029
"dòu":"豆逗痘",
1030
"hái,huán":"还",
1031
"fǒu,pǐ":"否",
1032
"lái":"来莱",
1033
"lián":"连怜帘莲联廉镰",
1034
"xiàn,xuán":"县",
1035
"zhù,chú":"助",
1036
"dāi":"呆",
1037
"kuàng":"旷况矿框眶",
1038
"ya,yā":"呀",
1039
"zú":"足族",
1040
"dūn":"吨蹲墩",
1041
"kùn":"困",
1042
"nán":"男",
1043
"chǎo,chāo":"吵",
1044
"yuán,yún,yùn":"员",
1045
"chuàn":"串",
1046
"chuī":"吹炊",
1047
"ba,bā":"吧",
1048
"hǒu":"吼",
1049
"gǎng":"岗",
1050
"bié,biè":"别",
1051
"dīng,dìng":"钉",
1052
"gào":"告",
1053
"wǒ":"我",
1054
"luàn":"乱",
1055
"tū":"秃突凸",
1056
"xiù":"秀袖绣锈嗅",
1057
"gū,gù":"估",
1058
"měi":"每美",
1059
"hé,hē,hè":"何",
1060
"tǐ,tī,bèn":"体",
1061
"bó,bǎi,bà":"伯",
1062
"zuò":"作坐座做",
1063
"líng":"伶灵铃陵零龄玲凌菱蛉翎",
1064
"dī":"低堤滴",
1065
"yòng,yōng":"佣",
1066
"nǐ":"你拟",
1067
"zhù":"住注驻柱祝铸贮蛀",
1068
"zào":"皂灶造燥躁噪",
1069
"fó,fú,bì,bó":"佛",
1070
"chè":"彻撤澈",
1071
"tuǒ":"妥椭",
1072
"lín":"邻林临琳磷鳞",
1073
"hán":"含寒函涵韩",
1074
"chà":"岔衩",
1075
"cháng":"肠尝常偿",
1076
"dù,dǔ":"肚",
1077
"guī,jūn,qiū":"龟",
1078
"miǎn":"免勉娩冕缅",
1079
"jiǎo,jué":"角",
1080
"kuáng":"狂",
1081
"tiáo,tiāo":"条",
1082
"luǎn":"卵",
1083
"yíng":"迎盈营蝇赢荧莹萤",
1084
"xì,jì":"系",
1085
"chuáng":"床",
1086
"kù":"库裤酷",
1087
"yìng,yīng":"应",
1088
"lěng":"冷",
1089
"zhè,zhèi":"这",
1090
"xù":"序叙绪续絮蓄旭恤酗婿",
1091
"xián":"闲贤弦咸衔嫌涎舷",
1092
"jiān,jiàn":"间监",
1093
"pàn":"判盼叛畔",
1094
"mēn,mèn":"闷",
1095
"wāng":"汪",
1096
"dì,tì,tuí":"弟",
1097
"shā,shà":"沙",
1098
"shà,shā":"煞",
1099
"càn":"灿",
1100
"wò":"沃卧握",
1101
"méi,mò":"没",
1102
"gōu":"沟钩",
1103
"shěn,chén":"沈",
1104
"huái":"怀槐徊淮",
1105
"sòng":"宋送诵颂讼",
1106
"hóng":"宏虹洪鸿",
1107
"qióng":"穷琼",
1108
"zāi":"灾栽",
1109
"liáng":"良梁粮粱",
1110
"zhèng":"证郑政",
1111
"bǔ":"补捕哺",
1112
"sù":"诉肃素速塑粟溯",
1113
"shí,zhì":"识",
1114
"cí":"词辞慈磁祠瓷雌",
1115
"zhěn":"诊枕疹",
1116
"niào,suī":"尿",
1117
"céng":"层",
1118
"jú":"局菊橘",
1119
"wěi,yǐ":"尾",
1120
"zhāng":"张章彰樟",
1121
"gǎi":"改",
1122
"lù":"陆录鹿路赂",
1123
"ē,ā":"阿",
1124
"zǔ":"阻组祖诅",
1125
"miào":"妙庙",
1126
"yāo":"妖腰邀夭吆",
1127
"nǔ":"努",
1128
"jìn,jìng":"劲",
1129
"rěn":"忍",
1130
"qū":"驱屈岖蛆躯",
1131
"chún":"纯唇醇",
1132
"nà":"纳钠捺",
1133
"bó":"驳脖博搏膊舶渤",
1134
"zòng,zǒng":"纵",
1135
"wén,wèn":"纹",
1136
"lǘ":"驴",
1137
"huán":"环",
1138
"qīng":"青轻倾清蜻氢卿",
1139
"xiàn":"现限线宪陷馅羡献腺",
1140
"biǎo":"表",
1141
"mǒ,mò,mā":"抹",
1142
"lǒng":"拢垄",
1143
"dān,dàn,dǎn":"担",
1144
"bá":"拔跋",
1145
"jiǎn":"拣茧俭捡检减剪简柬碱",
1146
"tǎn":"坦毯袒",
1147
"chōu":"抽",
1148
"yā":"押鸦鸭",
1149
"guǎi":"拐",
1150
"pāi":"拍",
1151
"zhě":"者",
1152
"dǐng":"顶鼎",
1153
"yōng":"拥庸",
1154
"chāi,cā":"拆",
1155
"dǐ":"抵",
1156
"jū,gōu":"拘",
1157
"lā":"垃",
1158
"lā,lá":"拉",
1159
"bàn,pàn":"拌",
1160
"zhāo":"招昭",
1161
"pō":"坡泼颇",
1162
"bō":"拨波玻菠播",
1163
"zé,zhái":"择",
1164
"tái":"抬",
1165
"qí,jī":"其奇",
1166
"qǔ":"取娶",
1167
"kǔ":"苦",
1168
"mào":"茂贸帽貌",
1169
"ruò,rě":"若",
1170
"miáo":"苗描瞄",
1171
"píng,pēng":"苹",
1172
"yīng":"英樱鹰莺婴缨鹦",
1173
"qié":"茄",
1174
"jīng":"茎京经惊晶睛精荆兢鲸",
1175
"zhī,qí":"枝",
1176
"bēi":"杯悲碑卑",
1177
"guì,jǔ":"柜",
1178
"bǎn":"板版",
1179
"sōng":"松",
1180
"qiāng":"枪腔",
1181
"gòu":"构购够垢",
1182
"sàng,sāng":"丧",
1183
"huà":"画话桦",
1184
"huò":"或货获祸惑霍",
1185
"cì,cī":"刺",
1186
"yǔ,yù":"雨语",
1187
"bēn,bèn":"奔",
1188
"fèn":"奋粪愤忿",
1189
"hōng":"轰烘",
1190
"qī,qì":"妻",
1191
"ōu":"欧殴鸥",
1192
"qǐng":"顷请",
1193
"zhuǎn,zhuàn,zhuǎi":"转",
1194
"zhǎn":"斩盏展",
1195
"ruǎn":"软",
1196
"lún":"轮仑伦沦",
1197
"dào":"到盗悼道稻",
1198
"chǐ":"齿耻侈",
1199
"kěn":"肯垦恳啃",
1200
"hǔ":"虎",
1201
"xiē,suò":"些",
1202
"lǔ":"虏鲁卤",
1203
"shèn":"肾渗慎",
1204
"shàng":"尚",
1205
"guǒ":"果裹",
1206
"kūn":"昆坤",
1207
"guó":"国",
1208
"chāng":"昌猖",
1209
"chàng":"畅唱",
1210
"diǎn":"典点碘",
1211
"gù":"固故顾雇",
1212
"áng":"昂",
1213
"zhōng":"忠终钟盅衷",
1214
"ne,ní":"呢",
1215
"àn":"岸按案暗",
1216
"tiě,tiē,tiè,":"帖",
1217
"luó":"罗萝锣箩骡螺逻",
1218
"kǎi":"凯慨",
1219
"lǐng,líng":"岭",
1220
"bài":"败拜",
1221
"tú":"图徒途涂屠",
1222
"chuí":"垂锤捶",
1223
"zhī,zhì":"知织",
1224
"guāi":"乖",
1225
"gǎn":"秆赶敢感橄",
1226
"hé,hè,huó,huò,hú":"和",
1227
"gòng,gōng":"供共",
1228
"wěi,wēi":"委",
1229
"cè,zè,zhāi":"侧",
1230
"pèi":"佩配沛",
1231
"pò,pǎi":"迫",
1232
"de,dì,dí":"的",
1233
"pá":"爬",
1234
"suǒ":"所索锁琐",
1235
"jìng":"径竞竟敬静境镜靖",
1236
"mìng":"命",
1237
"cǎi,cài":"采",
1238
"niàn":"念",
1239
"tān":"贪摊滩瘫",
1240
"rǔ":"乳辱",
1241
"pín":"贫",
1242
"fū":"肤麸孵敷",
1243
"fèi":"肺废沸费吠",
1244
"zhǒng":"肿",
1245
"péng":"朋棚蓬膨硼鹏澎篷",
1246
"fú,fù":"服",
1247
"féi":"肥",
1248
"hūn":"昏婚荤",
1249
"tù":"兔",
1250
"hú":"狐胡壶湖蝴弧葫",
1251
"gǒu":"狗苟",
1252
"bǎo":"饱宝保",
1253
"xiǎng":"享响想",
1254
"biàn":"变遍辨辩辫",
1255
"dǐ,de":"底",
1256
"jìng,chēng":"净",
1257
"fàng":"放",
1258
"nào":"闹",
1259
"zhá":"闸铡",
1260
"juàn,juǎn":"卷",
1261
"quàn,xuàn":"券",
1262
"dān,shàn,chán":"单",
1263
"chǎo":"炒",
1264
"qiǎn,jiān":"浅",
1265
"fǎ":"法",
1266
"xiè,yì":"泄",
1267
"lèi":"泪类",
1268
"zhān":"沾粘毡瞻",
1269
"pō,bó":"泊",
1270
"pào,pāo":"泡",
1271
"xiè":"泻卸屑械谢懈蟹",
1272
"ní,nì":"泥",
1273
"zé,shì":"泽",
1274
"pà":"怕帕",
1275
"guài":"怪",
1276
"zōng":"宗棕踪",
1277
"shěn":"审婶",
1278
"zhòu":"宙昼皱骤咒",
1279
"kōng,kòng,kǒng":"空",
1280
"láng,làng":"郎",
1281
"chèn":"衬趁",
1282
"gāi":"该",
1283
"xiáng,yáng":"详",
1284
"lì,dài":"隶",
1285
"jū":"居鞠驹",
1286
"shuā,shuà":"刷",
1287
"mèng":"孟梦",
1288
"gū":"孤姑辜咕沽菇箍",
1289
"jiàng,xiáng":"降",
1290
"mèi":"妹昧媚",
1291
"jiě":"姐",
1292
"jià":"驾架嫁稼",
1293
"cān,shēn,cēn,sān":"参",
1294
"liàn":"练炼恋链",
1295
"xì":"细隙",
1296
"shào":"绍哨",
1297
"tuó":"驼驮鸵",
1298
"guàn":"贯惯灌罐",
1299
"zòu":"奏揍",
1300
"chūn":"春椿",
1301
"bāng":"帮邦梆",
1302
"dú,dài":"毒",
1303
"guà":"挂卦褂",
1304
"kuǎ":"垮",
1305
"kuà,kū":"挎",
1306
"náo":"挠",
1307
"dǎng,dàng":"挡",
1308
"shuān":"拴栓",
1309
"tǐng":"挺艇",
1310
"kuò,guā":"括",
1311
"shí,shè":"拾",
1312
"tiāo,tiǎo":"挑",
1313
"wā":"挖蛙洼",
1314
"pīn":"拼",
1315
"shèn,shén":"甚",
1316
"mǒu":"某",
1317
"nuó":"挪",
1318
"gé":"革阁格隔",
1319
"xiàng,hàng":"巷",
1320
"cǎo":"草",
1321
"chá":"茶察茬",
1322
"dàng":"荡档",
1323
"huāng":"荒慌",
1324
"róng":"荣绒容熔融茸蓉溶榕",
1325
"nán,nā":"南",
1326
"biāo":"标彪膘",
1327
"yào":"药耀",
1328
"kū":"枯哭窟",
1329
"xiāng,xiàng":"相",
1330
"chá,zhā":"查",
1331
"liǔ":"柳",
1332
"bǎi,bó,bò":"柏",
1333
"yào,yāo":"要",
1334
"wāi":"歪",
1335
"yán,yàn":"研",
1336
"lí":"厘狸离犁梨璃黎漓篱",
1337
"qì,qiè":"砌",
1338
"miàn":"面",
1339
"kǎn":"砍坎",
1340
"shuǎ":"耍",
1341
"nài":"耐奈",
1342
"cán":"残蚕惭",
1343
"zhàn":"战站栈绽蘸",
1344
"bèi,bēi":"背",
1345
"lǎn":"览懒揽缆榄",
1346
"shěng,xǐng":"省",
1347
"xiāo,xuē":"削",
1348
"zhǎ":"眨",
1349
"hǒng,hōng,hòng":"哄",
1350
"xiǎn":"显险",
1351
"mào,mò":"冒",
1352
"yǎ,yā":"哑",
1353
"yìng":"映硬",
1354
"zuó":"昨",
1355
"xīng":"星腥猩",
1356
"pā":"趴",
1357
"guì":"贵桂跪刽",
1358
"sī,sāi":"思",
1359
"xiā":"虾瞎",
1360
"mǎ,mā,mà":"蚂",
1361
"suī":"虽",
1362
"pǐn":"品",
1363
"mà":"骂",
1364
"huá,huā":"哗",
1365
"yè,yàn,yān":"咽",
1366
"zán,zǎ":"咱",
1367
"hā,hǎ,hà":"哈",
1368
"yǎo":"咬舀",
1369
"nǎ,něi,na,né":"哪",
1370
"hāi,ké":"咳",
1371
"xiá":"峡狭霞匣侠暇辖",
1372
"gǔ,gū":"骨",
1373
"gāng,gàng":"钢",
1374
"tiē":"贴",
1375
"yào,yuè":"钥",
1376
"kàn,kān":"看",
1377
"jǔ":"矩举",
1378
"zěn":"怎",
1379
"xuǎn":"选癣",
1380
"zhòng,zhǒng,chóng":"种",
1381
"miǎo":"秒渺藐",
1382
"kē":"科棵颗磕蝌",
1383
"biàn,pián":"便",
1384
"zhòng,chóng":"重",
1385
"liǎ":"俩",
1386
"duàn":"段断缎锻",
1387
"cù":"促醋簇",
1388
"shùn":"顺瞬",
1389
"xiū":"修羞",
1390
"sú":"俗",
1391
"qīn":"侵钦",
1392
"xìn,shēn":"信",
1393
"huáng":"皇黄煌凰惶蝗蟥",
1394
"zhuī,duī":"追",
1395
"jùn":"俊峻骏竣",
1396
"dài,dāi":"待",
1397
"xū":"须虚需",
1398
"hěn":"很狠",
1399
"dùn":"盾顿钝",
1400
"lǜ":"律虑滤氯",
1401
"pén":"盆",
1402
"shí,sì,yì":"食",
1403
"dǎn":"胆",
1404
"táo":"逃桃陶萄淘",
1405
"pàng":"胖",
1406
"mài,mò":"脉",
1407
"dú":"独牍",
1408
"jiǎo":"狡饺绞脚搅",
1409
"yuàn":"怨院愿",
1410
"ráo":"饶",
1411
"wān":"弯湾豌",
1412
"āi":"哀哎埃",
1413
"jiāng,jiàng":"将浆",
1414
"tíng":"亭庭停蜓廷",
1415
"liàng":"亮谅辆晾",
1416
"dù,duó":"度",
1417
"chuāng":"疮窗",
1418
"qīn,qìng":"亲",
1419
"zī":"姿资滋咨",
1420
"dì":"帝递第蒂缔",
1421
"chà,chā,chāi,cī":"差",
1422
"yǎng":"养氧痒",
1423
"qián":"前钱钳潜黔",
1424
"mí":"迷谜靡",
1425
"nì":"逆昵匿腻",
1426
"zhà,zhá":"炸",
1427
"zǒng":"总",
1428
"làn":"烂滥",
1429
"pào,páo,bāo":"炮",
1430
"tì":"剃惕替屉涕",
1431
"sǎ,xǐ":"洒",
1432
"zhuó":"浊啄灼茁卓酌",
1433
"xǐ,xiǎn":"洗",
1434
"qià":"洽恰",
1435
"pài":"派湃",
1436
"huó":"活",
1437
"rǎn":"染",
1438
"héng":"恒衡",
1439
"hún":"浑魂",
1440
"nǎo":"恼脑",
1441
"jué,jiào":"觉",
1442
"hèn":"恨",
1443
"xuān":"宣轩喧",
1444
"qiè":"窃怯",
1445
"biǎn,piān":"扁",
1446
"ǎo":"袄",
1447
"shén":"神",
1448
"shuō,shuì,yuè":"说",
1449
"tuì":"退蜕",
1450
"chú":"除厨锄雏橱",
1451
"méi":"眉梅煤霉玫枚媒楣",
1452
"hái":"孩",
1453
"wá":"娃",
1454
"lǎo,mǔ":"姥",
1455
"nù":"怒",
1456
"hè":"贺赫褐鹤",
1457
"róu":"柔揉蹂",
1458
"bǎng":"绑膀",
1459
"lěi":"垒蕾儡",
1460
"rào":"绕",
1461
"gěi,jǐ":"给",
1462
"luò":"骆洛",
1463
"luò,lào":"络",
1464
"tǒng":"统桶筒捅",
1465
"gēng":"耕羹",
1466
"hào":"耗浩",
1467
"bān":"班般斑搬扳颁",
1468
"zhū":"珠株诸猪蛛",
1469
"lāo":"捞",
1470
"fěi":"匪诽",
1471
"zǎi,zài":"载",
1472
"mái,mán":"埋",
1473
"shāo,shào":"捎稍",
1474
"zhuō":"捉桌拙",
1475
"niē":"捏",
1476
"kǔn":"捆",
1477
"dū,dōu":"都",
1478
"sǔn":"损笋",
1479
"juān":"捐鹃",
1480
"zhé":"哲辙",
1481
"rè":"热",
1482
"wǎn":"挽晚碗惋婉",
1483
"ái,āi":"挨",
1484
"mò,mù":"莫",
1485
"è,wù,ě,wū":"恶",
1486
"tóng":"桐铜童彤瞳",
1487
"xiào,jiào":"校",
1488
"hé,hú":"核",
1489
"yàng":"样漾",
1490
"gēn":"根跟",
1491
"gē":"哥鸽割歌戈",
1492
"chǔ":"础储楚",
1493
"pò":"破魄",
1494
"tào":"套",
1495
"chái":"柴豺",
1496
"dǎng":"党",
1497
"mián":"眠绵棉",
1498
"shài":"晒",
1499
"jǐn":"紧锦谨",
1500
"yūn,yùn":"晕",
1501
"huàng,huǎng":"晃",
1502
"shǎng":"晌赏",
1503
"ēn":"恩",
1504
"ài,āi":"唉",
1505
"ā,á,ǎ,à,a":"啊",
1506
"bà,ba,pí":"罢",
1507
"zéi":"贼",
1508
"tiě":"铁",
1509
"zuàn,zuān":"钻",
1510
"qiān,yán":"铅",
1511
"quē":"缺",
1512
"tè":"特",
1513
"chéng,shèng":"乘",
1514
"dí":"敌笛涤嘀嫡",
1515
"zū":"租",
1516
"chèng":"秤",
1517
"mì,bì":"秘泌",
1518
"chēng,chèn,chèng":"称",
1519
"tòu":"透",
1520
"zhài":"债寨",
1521
"dào,dǎo":"倒",
1522
"tǎng,cháng":"倘",
1523
"chàng,chāng":"倡",
1524
"juàn":"倦绢眷",
1525
"chòu,xiù":"臭",
1526
"shè,yè,yì":"射",
1527
"xú":"徐",
1528
"háng":"航杭",
1529
"ná":"拿",
1530
"wēng":"翁嗡",
1531
"diē":"爹跌",
1532
"ài":"爱碍艾隘",
1533
"gē,gé":"胳搁",
1534
"cuì":"脆翠悴粹",
1535
"zàng":"脏葬",
1536
"láng":"狼廊琅榔",
1537
"féng":"逢",
1538
"è":"饿扼遏愕噩鳄",
1539
"shuāi,cuī":"衰",
1540
"gāo":"高糕羔篙",
1541
"zhǔn":"准",
1542
"bìng":"病",
1543
"téng":"疼腾誊藤",
1544
"liáng,liàng":"凉量",
1545
"táng":"唐堂塘膛糖棠搪",
1546
"pōu":"剖",
1547
"chù,xù":"畜",
1548
"páng,bàng":"旁磅",
1549
"lǚ":"旅屡吕侣铝缕履",
1550
"fěn":"粉",
1551
"liào":"料镣",
1552
"shāo":"烧",
1553
"yān":"烟淹",
1554
"tāo":"涛掏滔",
1555
"lào":"涝酪",
1556
"zhè":"浙蔗",
1557
"xiāo":"消宵销萧硝箫嚣",
1558
"hǎi":"海",
1559
"zhǎng,zhàng":"涨",
1560
"làng":"浪",
1561
"rùn":"润闰",
1562
"tàng":"烫",
1563
"yǒng,chōng":"涌",
1564
"huǐ":"悔毁",
1565
"qiāo,qiǎo":"悄",
1566
"hài":"害亥骇",
1567
"jiā,jia,jie":"家",
1568
"kuān":"宽",
1569
"bīn":"宾滨彬缤濒",
1570
"zhǎi":"窄",
1571
"lǎng":"朗",
1572
"dú,dòu":"读",
1573
"zǎi":"宰",
1574
"shàn,shān":"扇",
1575
"shān,shàn":"苫",
1576
"wà":"袜",
1577
"xiáng":"祥翔",
1578
"shuí":"谁",
1579
"páo":"袍咆",
1580
"bèi,pī":"被",
1581
"tiáo,diào,zhōu":"调",
1582
"yuān":"冤鸳渊",
1583
"bō,bāo":"剥",
1584
"ruò":"弱",
1585
"péi":"陪培赔",
1586
"niáng":"娘",
1587
"tōng":"通",
1588
"néng,nài":"能",
1589
"nán,nàn,nuó":"难",
1590
"sāng":"桑",
1591
"pěng":"捧",
1592
"dǔ":"堵赌睹",
1593
"yǎn":"掩眼演衍",
1594
"duī":"堆",
1595
"pái,pǎi":"排",
1596
"tuī":"推",
1597
"jiào,jiāo":"教",
1598
"lüè":"掠略",
1599
"jù,jū":"据",
1600
"kòng":"控",
1601
"zhù,zhuó,zhe":"著",
1602
"jūn,jùn":"菌",
1603
"lè,lēi":"勒",
1604
"méng":"萌盟檬朦",
1605
"cài":"菜",
1606
"tī":"梯踢剔",
1607
"shāo,sào":"梢",
1608
"fù,pì":"副",
1609
"piào,piāo":"票",
1610
"shuǎng":"爽",
1611
"shèng,chéng":"盛",
1612
"què,qiāo,qiǎo":"雀",
1613
"xuě":"雪",
1614
"chí,shi":"匙",
1615
"xuán":"悬玄漩",
1616
"mī,mí":"眯",
1617
"la,lā":"啦",
1618
"shé,yí":"蛇",
1619
"lèi,léi,lěi":"累",
1620
"zhǎn,chán":"崭",
1621
"quān,juàn,juān":"圈",
1622
"yín":"银吟淫",
1623
"bèn":"笨",
1624
"lóng,lǒng":"笼",
1625
"mǐn":"敏皿闽悯",
1626
"nín":"您",
1627
"ǒu":"偶藕",
1628
"tōu":"偷",
1629
"piān":"偏篇翩",
1630
"dé,děi,de":"得",
1631
"jiǎ,jià":"假",
1632
"pán":"盘",
1633
"chuán":"船",
1634
"cǎi":"彩睬踩",
1635
"lǐng":"领",
1636
"liǎn":"脸敛",
1637
"māo,máo":"猫",
1638
"měng":"猛锰",
1639
"cāi":"猜",
1640
"háo":"毫豪壕嚎",
1641
"má":"麻",
1642
"guǎn":"馆管",
1643
"còu":"凑",
1644
"hén":"痕",
1645
"kāng":"康糠慷",
1646
"xuán,xuàn":"旋",
1647
"zhe,zhuó,zháo,zhāo":"着",
1648
"lǜ,shuài":"率",
1649
"gài,gě,hé":"盖",
1650
"cū":"粗",
1651
"lín,lìn":"淋",
1652
"qú,jù":"渠",
1653
"jiàn,jiān":"渐溅",
1654
"hùn,hún":"混",
1655
"pó":"婆",
1656
"qíng":"情晴擎",
1657
"cǎn":"惨",
1658
"sù,xiǔ,xiù":"宿",
1659
"yáo":"窑谣摇遥肴姚",
1660
"móu":"谋",
1661
"mì":"密蜜觅",
1662
"huǎng":"谎恍幌",
1663
"tán,dàn":"弹",
1664
"suí":"随",
1665
"yǐn,yìn":"隐",
1666
"jǐng,gěng":"颈",
1667
"shéng":"绳",
1668
"qí":"骑棋旗歧祈脐畦崎鳍",
1669
"chóu":"绸酬筹稠愁畴",
1670
"lǜ,lù":"绿",
1671
"dā":"搭",
1672
"kuǎn":"款",
1673
"tǎ":"塔",
1674
"qū,cù":"趋",
1675
"tí,dī,dǐ":"提",
1676
"jiē,qì":"揭",
1677
"xǐ":"喜徙",
1678
"sōu":"搜艘",
1679
"chā":"插",
1680
"lǒu,lōu":"搂",
1681
"qī,jī":"期",
1682
"rě":"惹",
1683
"sàn,sǎn":"散",
1684
"dǒng":"董懂",
1685
"gě,gé":"葛",
1686
"pú":"葡菩蒲",
1687
"zhāo,cháo":"朝",
1688
"luò,là,lào":"落",
1689
"kuí":"葵魁",
1690
"bàng":"棒傍谤",
1691
"yǐ,yī":"椅",
1692
"sēn":"森",
1693
"gùn,hùn":"棍",
1694
"bī":"逼",
1695
"zhí,shi":"殖",
1696
"xià,shà":"厦",
1697
"liè,liě":"裂",
1698
"xióng":"雄熊",
1699
"zàn":"暂赞",
1700
"yǎ":"雅",
1701
"chǎng":"敞",
1702
"zhǎng":"掌",
1703
"shǔ":"暑鼠薯黍蜀署曙",
1704
"zuì":"最罪醉",
1705
"hǎn":"喊罕",
1706
"jǐng,yǐng":"景",
1707
"lǎ":"喇",
1708
"pēn,pèn":"喷",
1709
"pǎo,páo":"跑",
1710
"chuǎn":"喘",
1711
"hē,hè,yè":"喝",
1712
"hóu":"喉猴",
1713
"pù,pū":"铺",
1714
"hēi":"黑",
1715
"guō":"锅郭",
1716
"ruì":"锐瑞",
1717
"duǎn":"短",
1718
"é":"鹅额讹俄",
1719
"děng":"等",
1720
"kuāng":"筐",
1721
"shuì":"税睡",
1722
"zhù,zhú":"筑",
1723
"shāi":"筛",
1724
"dá,dā":"答",
1725
"ào":"傲澳懊",
1726
"pái":"牌徘",
1727
"bǎo,bǔ,pù":"堡",
1728
"ào,yù":"奥",
1729
"fān,pān":"番",
1730
"là,xī":"腊",
1731
"huá":"猾滑",
1732
"rán":"然燃",
1733
"chán":"馋缠蝉",
1734
"mán":"蛮馒",
1735
"tòng":"痛",
1736
"shàn":"善擅膳赡",
1737
"zūn":"尊遵",
1738
"pǔ":"普谱圃浦",
1739
"gǎng,jiǎng":"港",
1740
"céng,zēng":"曾",
1741
"wēn":"温瘟",
1742
"kě":"渴",
1743
"zhā":"渣",
1744
"duò":"惰舵跺",
1745
"gài":"溉概丐钙",
1746
"kuì":"愧",
1747
"yú,tōu":"愉",
1748
"wō":"窝蜗",
1749
"cuàn":"窜篡",
1750
"qún":"裙群",
1751
"qiáng,qiǎng,jiàng":"强",
1752
"shǔ,zhǔ":"属",
1753
"zhōu,yù":"粥",
1754
"sǎo":"嫂",
1755
"huǎn":"缓",
1756
"piàn":"骗",
1757
"mō":"摸",
1758
"shè,niè":"摄",
1759
"tián,zhèn":"填",
1760
"gǎo":"搞稿镐",
1761
"suàn":"蒜算",
1762
"méng,mēng,měng":"蒙",
1763
"jìn,jīn":"禁",
1764
"lóu":"楼娄",
1765
"lài":"赖癞",
1766
"lù,liù":"碌",
1767
"pèng":"碰",
1768
"léi":"雷",
1769
"báo":"雹",
1770
"dū":"督",
1771
"nuǎn":"暖",
1772
"xiē":"歇楔蝎",
1773
"kuà":"跨胯",
1774
"tiào,táo":"跳",
1775
"é,yǐ":"蛾",
1776
"sǎng":"嗓",
1777
"qiǎn":"遣谴",
1778
"cuò":"错挫措锉",
1779
"ǎi":"矮蔼",
1780
"shǎ":"傻",
1781
"cuī":"催摧崔",
1782
"tuǐ":"腿",
1783
"chù":"触矗",
1784
"jiě,jiè,xiè":"解",
1785
"shù,shǔ,shuò":"数",
1786
"mǎn":"满",
1787
"liū,liù":"溜",
1788
"gǔn":"滚",
1789
"sāi,sài,sè":"塞",
1790
"pì,bì":"辟",
1791
"dié":"叠蝶谍碟",
1792
"fèng,féng":"缝",
1793
"qiáng":"墙",
1794
"piě,piē":"撇",
1795
"zhāi":"摘斋",
1796
"shuāi":"摔",
1797
"mó,mú":"模",
1798
"bǎng,bàng":"榜",
1799
"zhà":"榨乍诈",
1800
"niàng":"酿",
1801
"zāo":"遭糟",
1802
"suān":"酸",
1803
"shang,cháng":"裳",
1804
"sòu":"嗽",
1805
"là":"蜡辣",
1806
"qiāo":"锹敲跷",
1807
"zhuàn":"赚撰",
1808
"wěn":"稳吻紊",
1809
"bí":"鼻荸",
1810
"mó":"膜魔馍摹蘑",
1811
"xiān,xiǎn":"鲜",
1812
"yí,nǐ":"疑",
1813
"gāo,gào":"膏",
1814
"zhē":"遮",
1815
"duān":"端",
1816
"màn":"漫慢曼幔",
1817
"piāo,piào,piǎo":"漂",
1818
"lòu":"漏陋",
1819
"sài":"赛",
1820
"nèn":"嫩",
1821
"dèng":"凳邓瞪",
1822
"suō,sù":"缩",
1823
"qù,cù":"趣",
1824
"sā,sǎ":"撒",
1825
"tàng,tāng":"趟",
1826
"chēng":"撑",
1827
"zēng":"增憎",
1828
"cáo":"槽曹",
1829
"héng,hèng":"横",
1830
"piāo":"飘",
1831
"mán,mén":"瞒",
1832
"tí":"题蹄啼",
1833
"yǐng":"影颖",
1834
"bào,pù":"暴",
1835
"tà":"踏蹋",
1836
"kào":"靠铐",
1837
"pì":"僻屁譬",
1838
"tǎng":"躺",
1839
"dé":"德",
1840
"mó,mā":"摩",
1841
"shú":"熟秫赎",
1842
"hú,hū,hù":"糊",
1843
"pī,pǐ":"劈",
1844
"cháo":"潮巢",
1845
"cāo":"操糙",
1846
"yàn,yān":"燕",
1847
"diān":"颠掂",
1848
"báo,bó,bò":"薄",
1849
"cān":"餐",
1850
"xǐng":"醒",
1851
"zhěng":"整拯",
1852
"zuǐ":"嘴",
1853
"zèng":"赠",
1854
"mó,mò":"磨",
1855
"níng":"凝狞柠",
1856
"jiǎo,zhuó":"缴",
1857
"cā":"擦",
1858
"cáng,zàng":"藏",
1859
"fán,pó":"繁",
1860
"bì,bei":"臂",
1861
"bèng":"蹦泵",
1862
"pān":"攀潘",
1863
"chàn,zhàn":"颤",
1864
"jiāng,qiáng":"疆",
1865
"rǎng":"壤攘",
1866
"jiáo,jué,jiào":"嚼",
1867
"rǎng,rāng":"嚷",
1868
"chǔn":"蠢",
1869
"lù,lòu":"露",
1870
"náng,nāng":"囊",
1871
"dǎi":"歹",
1872
"rǒng":"冗",
1873
"hāng,bèn":"夯",
1874
"āo,wā":"凹",
1875
"féng,píng":"冯",
1876
"yū":"迂淤",
1877
"xū,yù":"吁",
1878
"lèi,lē":"肋",
1879
"kōu":"抠",
1880
"lūn,lún":"抡",
1881
"jiè,gài":"芥",
1882
"xīn,xìn":"芯",
1883
"chā,chà":"杈",
1884
"xiāo,xiào":"肖",
1885
"zhī,zī":"吱",
1886
"ǒu,ōu,òu":"呕",
1887
"nà,nè":"呐",
1888
"qiàng,qiāng":"呛",
1889
"tún,dùn":"囤",
1890
"kēng,háng":"吭",
1891
"shǔn":"吮",
1892
"diàn,tián":"佃",
1893
"sì,cì":"伺",
1894
"zhǒu":"肘帚",
1895
"diàn,tián,shèng":"甸",
1896
"páo,bào":"刨",
1897
"lìn":"吝赁躏",
1898
"duì,ruì,yuè":"兑",
1899
"zhuì":"坠缀赘",
1900
"kē,kě":"坷",
1901
"tuò,tà,zhí":"拓",
1902
"fú,bì":"拂",
1903
"nǐng,níng,nìng":"拧",
1904
"ào,ǎo,niù":"拗",
1905
"kē,hē":"苛",
1906
"yān,yǎn":"奄",
1907
"hē,a,kē":"呵",
1908
"gā,kā":"咖",
1909
"biǎn":"贬匾",
1910
"jiǎo,yáo":"侥",
1911
"chà,shā":"刹",
1912
"āng":"肮",
1913
"wèng":"瓮",
1914
"nüè,yào":"疟",
1915
"páng":"庞螃",
1916
"máng,méng":"氓",
1917
"gē,yì":"疙",
1918
"jǔ,jù":"沮",
1919
"zú,cù":"卒",
1920
"nìng":"泞",
1921
"chǒng":"宠",
1922
"wǎn,yuān":"宛",
1923
"mí,mǐ":"弥",
1924
"qì,qiè,xiè":"契",
1925
"xié,jiā":"挟",
1926
"duò,duǒ":"垛",
1927
"jiá":"荚颊",
1928
"zhà,shān,shi,cè":"栅",
1929
"bó,bèi":"勃",
1930
"zhóu,zhòu":"轴",
1931
"nüè":"虐",
1932
"liē,liě,lié,lie":"咧",
1933
"dǔn":"盹",
1934
"xūn":"勋",
1935
"yo,yō":"哟",
1936
"mī":"咪",
1937
"qiào,xiào":"俏",
1938
"hóu,hòu":"侯",
1939
"pēi":"胚",
1940
"tāi":"胎",
1941
"luán":"峦",
1942
"sà":"飒萨",
1943
"shuò":"烁",
1944
"xuàn":"炫",
1945
"píng,bǐng":"屏",
1946
"nà,nuó":"娜",
1947
"pá,bà":"耙",
1948
"gěng":"埂耿梗",
1949
"niè":"聂镊孽",
1950
"mǎng":"莽",
1951
"qī,xī":"栖",
1952
"jiǎ,gǔ":"贾",
1953
"chěng":"逞",
1954
"pēng":"砰烹",
1955
"láo,lào":"唠",
1956
"bàng,bèng":"蚌",
1957
"gōng,zhōng":"蚣",
1958
"li,lǐ,lī":"哩",
1959
"suō":"唆梭嗦",
1960
"hēng":"哼",
1961
"zāng":"赃",
1962
"qiào":"峭窍撬",
1963
"mǎo":"铆",
1964
"ǎn":"俺",
1965
"sǒng":"耸",
1966
"juè,jué":"倔",
1967
"yīn,yān,yǐn":"殷",
1968
"guàng":"逛",
1969
"něi":"馁",
1970
"wō,guō":"涡",
1971
"lào,luò":"烙",
1972
"nuò":"诺懦糯",
1973
"zhūn":"谆",
1974
"niǎn,niē":"捻",
1975
"qiā":"掐",
1976
"yè,yē":"掖",
1977
"chān,xiān,càn,shǎn":"掺",
1978
"dǎn,shàn":"掸",
1979
"fēi,fěi":"菲",
1980
"qián,gān":"乾",
1981
"shē":"奢赊",
1982
"shuò,shí":"硕",
1983
"luō,luó,luo":"啰",
1984
"shá":"啥",
1985
"hǔ,xià":"唬",
1986
"tuò":"唾",
1987
"bēng":"崩",
1988
"dāng,chēng":"铛",
1989
"xiǎn,xǐ":"铣",
1990
"jiǎo,jiáo":"矫",
1991
"tiáo":"笤",
1992
"kuǐ,guī":"傀",
1993
"xìn":"衅",
1994
"dōu":"兜",
1995
"jì,zhài":"祭",
1996
"xiáo":"淆",
1997
"tǎng,chǎng":"淌",
1998
"chún,zhūn":"淳",
1999
"shuàn":"涮",
2000
"dāng":"裆",
2001
"wèi,yù":"尉",
2002
"duò,huī":"堕",
2003
"chuò,chāo":"绰",
2004
"bēng,běng,bèng":"绷",
2005
"zōng,zèng":"综",
2006
"zhuó,zuó":"琢",
2007
"chuǎi,chuài,chuāi,tuán,zhuī":"揣",
2008
"péng,bāng":"彭",
2009
"chān":"搀",
2010
"cuō":"搓",
2011
"sāo":"搔",
2012
"yē":"椰",
2013
"zhuī,chuí":"椎",
2014
"léng,lēng,líng":"棱",
2015
"hān":"酣憨",
2016
"sū":"酥",
2017
"záo":"凿",
2018
"qiào,qiáo":"翘",
2019
"zhā,chā":"喳",
2020
"bǒ":"跛",
2021
"há,gé":"蛤",
2022
"qiàn,kàn":"嵌",
2023
"bāi":"掰",
2024
"yān,ā":"腌",
2025
"wàn":"腕",
2026
"dūn,duì":"敦",
2027
"kuì,huì":"溃",
2028
"jiǒng":"窘",
2029
"sāo,sǎo":"骚",
2030
"pìn":"聘",
2031
"bǎ":"靶",
2032
"xuē":"靴薛",
2033
"hāo":"蒿",
2034
"léng":"楞",
2035
"kǎi,jiē":"楷",
2036
"pín,bīn":"频",
2037
"zhuī":"锥",
2038
"tuí":"颓",
2039
"sāi":"腮",
2040
"liú,liù":"馏",
2041
"nì,niào":"溺",
2042
"qǐn":"寝",
2043
"luǒ":"裸",
2044
"miù":"谬",
2045
"jiǎo,chāo":"剿",
2046
"áo,āo":"熬",
2047
"niān":"蔫",
2048
"màn,wàn":"蔓",
2049
"chá,chā":"碴",
2050
"xūn,xùn":"熏",
2051
"tiǎn":"舔",
2052
"sēng":"僧",
2053
"da,dá":"瘩",
2054
"guǎ":"寡",
2055
"tuì,tùn":"褪",
2056
"niǎn":"撵碾",
2057
"liáo,liāo":"撩",
2058
"cuō,zuǒ":"撮",
2059
"ruǐ":"蕊",
2060
"cháo,zhāo":"嘲",
2061
"biē":"憋鳖",
2062
"hēi,mò":"嘿",
2063
"zhuàng,chuáng":"幢",
2064
"jī,qǐ":"稽",
2065
"lǒu":"篓",
2066
"lǐn":"凛檩",
2067
"biě,biē":"瘪",
2068
"liáo,lào,lǎo":"潦",
2069
"chéng,dèng":"澄",
2070
"lèi,léi":"擂",
2071
"piáo":"瓢",
2072
"shà":"霎",
2073
"mò,má":"蟆",
2074
"qué":"瘸",
2075
"liáo,liǎo":"燎",
2076
"liào,liǎo":"瞭",
2077
"sào,sāo":"臊",
2078
"mí,méi":"糜",
2079
"ái":"癌",
2080
"tún":"臀",
2081
"huò,huō,huá":"豁",
2082
"pù,bào":"瀑",
2083
"chuō":"戳",
2084
"zǎn,cuán":"攒",
2085
"cèng":"蹭",
2086
"bò,bǒ":"簸",
2087
"bó,bù":"簿",
2088
"bìn":"鬓",
2089
"suǐ":"髓",
2090
"ráng":"瓤",
2091
};
2092
2093
},{}],7:[function(require,module,exports){
2094
// 带音标字符。
2095
module.exports = {
2096
  "ā": "a1",
2097
  "á": "a2",
2098
  "ǎ": "a3",
2099
  "à": "a4",
2100
  "ē": "e1",
2101
  "é": "e2",
2102
  "ě": "e3",
2103
  "è": "e4",
2104
  "ō": "o1",
2105
  "ó": "o2",
2106
  "ǒ": "o3",
2107
  "ò": "o4",
2108
  "ī": "i1",
2109
  "í": "i2",
2110
  "ǐ": "i3",
2111
  "ì": "i4",
2112
  "ū": "u1",
2113
  "ú": "u2",
2114
  "ǔ": "u3",
2115
  "ù": "u4",
2116
  "ü": "v0",
2117
  "ǘ": "v2",
2118
  "ǚ": "v3",
2119
  "ǜ": "v4",
2120
  "ń": "n2",
2121
  "ň": "n3",
2122
  "": "m2",
2123
};
2124
2125
},{}],8:[function(require,module,exports){
2126
(function (process){
2127
"use strict";
2128
2129
var isNode = typeof process === "object" &&
2130
  process.toString() === "[object process]";
2131
2132
// 分词模块
2133
var jieba;
2134
var PHRASES_DICT;
2135
var PINYIN_DICT;
2136
2137
2138
// 解压拼音库。
2139
// @param {Object} dict_combo, 压缩的拼音库。
2140
// @param {Object} 解压的拼音库。
2141
function buildPinyinCache(dict_combo){
2142
  var hans;
2143
  var uncomboed = {};
2144
2145
  for(var py in dict_combo){
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
2146
    hans = dict_combo[py];
2147
    for(var i = 0, han, l = hans.length; i < l; i++){
2148
      han = hans.charCodeAt(i);
2149
      if(!uncomboed.hasOwnProperty(han)){
2150
        uncomboed[han] = py;
2151
      }else{
2152
        uncomboed[han] += "," + py;
2153
      }
2154
    }
2155
  }
2156
2157
  return uncomboed;
2158
}
2159
2160
function segment(hans) {
2161
  try {
2162
    jieba = jieba || module["require"]("nodejieba");
2163
  } catch (ex) {
2164
    console.error();
2165
    console.error("    Segment need nodejieba, please run '$ npm install nodejieba'.");
2166
    console.error("    分词需要使用 nodejieba 模块,请运行 '$ npm install nodejieba' 并确保安装完成。");
2167
    console.error();
2168
    throw ex;
2169
  }
2170
  // 词语拼音库。
2171
  PHRASES_DICT = PHRASES_DICT || module["require"]("./phrases-dict");
2172
  return jieba.cut(hans);
2173
}
2174
if(isNode){
2175
  // 拼音词库,node 版无需使用压缩合并的拼音库。
2176
  PINYIN_DICT = module["require"]("./dict-zi");
2177
}else{
2178
  PINYIN_DICT = buildPinyinCache(require("./dict-zi-web"));
2179
}
2180
2181
2182
// 声母表。
2183
var INITIALS = "b,p,m,f,d,t,n,l,g,k,h,j,q,x,r,zh,ch,sh,z,c,s".split(",");
2184
// 韵母表。
2185
//var FINALS = "ang,eng,ing,ong,an,en,in,un,er,ai,ei,ui,ao,ou,iu,ie,ve,a,o,e,i,u,v".split(",");
2186
var PINYIN_STYLE = {
2187
  NORMAL: 0,  // 普通风格,不带音标。
2188
  TONE: 1,    // 标准风格,音标在韵母的第一个字母上。
2189
  TONE2: 2,   // 声调中拼音之后,使用数字 1~4 标识。
2190
  INITIALS: 3,// 仅需要声母部分。
2191
  FIRST_LETTER: 4, // 仅保留首字母。
2192
};
2193
// 带音标字符。
2194
var PHONETIC_SYMBOL = require("./phonetic-symbol.js");
2195
var re_phonetic_symbol_source = "";
2196
for(var k in PHONETIC_SYMBOL){
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
2197
    re_phonetic_symbol_source += k;
2198
}
2199
var RE_PHONETIC_SYMBOL = new RegExp("([" + re_phonetic_symbol_source + "])", "g");
2200
var RE_TONE2 = /([aeoiuvnm])([0-4])$/;
2201
var DEFAULT_OPTIONS = {
2202
  style: PINYIN_STYLE.TONE, // 风格
2203
  segment: false, // 分词。
2204
  heteronym: false, // 多音字
2205
};
2206
2207
2208
// 将 more 的属性值,覆盖 origin 中已有的属性。
2209
// @param {Object} origin.
2210
// @param {Object} more.
2211
// @return 返回新的对象。
2212
function extend(origin, more){
2213
  var obj = {};
2214
  for(var k in origin){
2215
    if(more.hasOwnProperty(k)){
2216
      obj[k] = more[k];
2217
    }else{
2218
      obj[k] = origin[k];
2219
    }
2220
  }
2221
  return obj;
2222
}
2223
2224
// 修改拼音词库表中的格式。
2225
// @param {String} pinyin, 单个拼音。
2226
// @param {PINYIN_STYLE} style, 拼音风格。
2227
// @return {String}
2228
function toFixed(pinyin, style){
2229
  var tone = ""; // 声调。
2230
  switch(style){
2231
  case PINYIN_STYLE.INITIALS:
0 ignored issues
show
Bug introduced by
The variable PINYIN_STYLE seems to be never declared. If this is a global, consider adding a /** global: PINYIN_STYLE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2232
    return initials(pinyin);
2233
2234
  case PINYIN_STYLE.FIRST_LETTER:
2235
    var first_letter = pinyin.charAt(0);
2236
    if(PHONETIC_SYMBOL.hasOwnProperty(first_letter)){
2237
      first_letter = PHONETIC_SYMBOL[first_letter].charAt(0);
2238
    }
2239
    return first_letter;
2240
2241
  case PINYIN_STYLE.NORMAL:
2242
    return pinyin.replace(RE_PHONETIC_SYMBOL, function($0, $1_phonetic){
2243
      return PHONETIC_SYMBOL[$1_phonetic].replace(RE_TONE2, "$1");
2244
    });
2245
2246
  case PINYIN_STYLE.TONE2:
0 ignored issues
show
Bug introduced by
The variable PINYIN_STYLE seems to be never declared. If this is a global, consider adding a /** global: PINYIN_STYLE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2247
    var py = pinyin.replace(RE_PHONETIC_SYMBOL, function($0, $1){
2248
      // 声调数值。
2249
      tone = PHONETIC_SYMBOL[$1].replace(RE_TONE2, "$2");
2250
2251
      return PHONETIC_SYMBOL[$1].replace(RE_TONE2, "$1");
2252
    });
2253
    return py + tone;
2254
2255
  case PINYIN_STYLE.TONE:
0 ignored issues
show
Bug introduced by
The variable PINYIN_STYLE seems to be never declared. If this is a global, consider adding a /** global: PINYIN_STYLE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2256
  default:
2257
    return pinyin;
2258
  }
2259
}
2260
2261
// 单字拼音转换。
2262
// @param {String} han, 单个汉字
2263
// @return {Array} 返回拼音列表,多音字会有多个拼音项。
2264
function single_pinyin(han, options){
2265
2266
  if(typeof han !== "string"){
2267
    return [];
2268
  }
2269
  if(han.length !== 1){
2270
    return single_pinyin(han.charAt(0), options);
2271
  }
2272
2273
  var hanCode = han.charCodeAt(0);
2274
2275
  if(!PINYIN_DICT[hanCode]){
2276
    return [han];
2277
  }
2278
2279
  var pys = PINYIN_DICT[hanCode].split(",");
2280
  if(!options.heteronym){
2281
    return [toFixed(pys[0], options.style)];
2282
  }
2283
2284
  // 临时存储已存在的拼音,避免多音字拼音转换为非注音风格出现重复。
2285
  var py_cached = {};
2286
  var pinyins = [];
2287
  for(var i = 0, py, l = pys.length; i < l; i++){
2288
    py = toFixed(pys[i], options.style);
2289
    if(py_cached.hasOwnProperty(py)){
2290
      continue;
2291
    }
2292
    py_cached[py] = py;
2293
2294
    pinyins.push(py);
2295
  }
2296
  return pinyins;
2297
}
2298
2299
// 词语注音
2300
// @param {String} phrases, 指定的词组。
2301
// @param {Object} options, 选项。
2302
// @return {Array}
2303
function phrases_pinyin(phrases, options){
2304
  var py = [];
2305
  if(PHRASES_DICT.hasOwnProperty(phrases)){
2306
    //! copy pinyin result.
2307
    PHRASES_DICT[phrases].forEach(function(item, idx){
2308
      py[idx] = [];
2309
      if (options.heteronym){
2310
        item.forEach(function(py_item, py_index){
2311
          py[idx][py_index] = toFixed(py_item, options.style);
2312
        });
2313
      } else {
2314
        py[idx][0] = toFixed(item[0], options.style);
2315
      }
2316
    });
2317
  }else{
2318
    for(var i = 0, l = phrases.length; i < l; i++){
2319
      py.push(single_pinyin(phrases[i], options));
2320
    }
2321
  }
2322
  return py;
2323
}
2324
2325
// @param {String} hans 要转为拼音的目标字符串(汉字)。
2326
// @param {Object} options, 可选,用于指定拼音风格,是否启用多音字。
2327
// @return {Array} 返回的拼音列表。
2328
function pinyin(hans, options){
2329
2330
  if(typeof hans !== "string"){
2331
    return [];
2332
  }
2333
2334
  options = extend(DEFAULT_OPTIONS, options || {});
2335
2336
  var phrases = isNode && options.segment ? segment(hans) : hans;
2337
  var pys = [];
2338
2339
  for(var i = 0, nohans = "", firstCharCode, words, l = phrases.length; i < l; i++){
2340
2341
    words = phrases[i];
2342
    firstCharCode = words.charCodeAt(0);
2343
2344
    if(PINYIN_DICT[firstCharCode]){
2345
2346
      // ends of non-chinese words.
2347
      if(nohans.length > 0){
2348
        pys.push([nohans]);
2349
        nohans = ""; // reset non-chinese words.
2350
      }
2351
2352
      if(words.length === 1){
2353
          pys.push(single_pinyin(words, options));
2354
      }else{
2355
        pys = pys.concat(phrases_pinyin(words, options));
2356
      }
2357
2358
    }else{
2359
      nohans += words;
2360
    }
2361
  }
2362
2363
  // 清理最后的非中文字符串。
2364
  if(nohans.length > 0){
2365
    pys.push([nohans]);
2366
    nohans = ""; // reset non-chinese words.
0 ignored issues
show
Unused Code introduced by
The assignment to variable nohans seems to be never used. Consider removing it.
Loading history...
2367
  }
2368
  return pys;
2369
}
2370
2371
2372
// 格式化为声母(Initials)、韵母(Finals)。
2373
// @param {String}
2374
// @return {String}
2375
function initials(pinyin) {
2376
  for (var i = 0, l = INITIALS.length; i < l; i++){
2377
    if (pinyin.indexOf(INITIALS[i]) === 0) {
2378
      return INITIALS[i];
2379
    }
2380
  }
2381
  return "";
2382
}
2383
2384
pinyin.STYLE_NORMAL = PINYIN_STYLE.NORMAL;
2385
pinyin.STYLE_TONE = PINYIN_STYLE.TONE;
2386
pinyin.STYLE_TONE2 = PINYIN_STYLE.TONE2;
2387
pinyin.STYLE_INITIALS = PINYIN_STYLE.INITIALS;
2388
pinyin.STYLE_FIRST_LETTER = PINYIN_STYLE.FIRST_LETTER;
2389
2390
module.exports = pinyin;
2391
2392
}).call(this,require('_process'))
2393
},{"./dict-zi-web":6,"./phonetic-symbol.js":7,"_process":1}],9:[function(require,module,exports){
2394
module.exports = require('./lib/speakingurl');
2395
2396
},{"./lib/speakingurl":10}],10:[function(require,module,exports){
2397
(function (root, undefined) {
0 ignored issues
show
Unused Code introduced by
The parameter undefined is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
2398
    'use strict';
2399
2400
    /**
2401
     * getSlug
2402
     * @param  {string} input input string
2403
     * @param  {object|string} opts config object or separator string/char
2404
     * @api    public
2405
     * @return {string}  sluggified string
2406
     */
2407
    var getSlug = function getSlug(input, opts) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable getSlug already seems to be declared on line 2407. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
2408
2409
        var separator = '-';
2410
        var uricChars = [';', '?', ':', '@', '&', '=', '+', '$', ',', '/'];
2411
        var uricNoSlashChars = [';', '?', ':', '@', '&', '=', '+', '$', ','];
2412
        var markChars = ['.', '!', '~', '*', '\'', '(', ')'];
2413
        var result = '';
2414
        var diatricString = '';
2415
        var convertSymbols = true;
0 ignored issues
show
Unused Code introduced by
The assignment to variable convertSymbols seems to be never used. Consider removing it.
Loading history...
2416
        var customReplacements = {};
2417
        var maintainCase;
2418
        var titleCase;
2419
        var truncate;
2420
        var uricFlag;
2421
        var uricNoSlashFlag;
2422
        var markFlag;
2423
        var symbol;
2424
        var langChar;
2425
        var lucky;
2426
        var i;
2427
        var ch;
2428
        var l;
2429
        var lastCharWasSymbol;
2430
        var lastCharWasDiatric;
2431
        var allowedChars;
2432
2433
        /**
2434
         * charMap
2435
         * @type {Object}
2436
         */
2437
        var charMap = {
2438
2439
            // latin
2440
            'À': 'A',
2441
            'Á': 'A',
2442
            'Â': 'A',
2443
            'Ã': 'A',
2444
            'Ä': 'Ae',
2445
            'Å': 'A',
2446
            'Æ': 'AE',
2447
            'Ç': 'C',
2448
            'È': 'E',
2449
            'É': 'E',
2450
            'Ê': 'E',
2451
            'Ë': 'E',
2452
            'Ì': 'I',
2453
            'Í': 'I',
2454
            'Î': 'I',
2455
            'Ï': 'I',
2456
            'Ð': 'D',
2457
            'Ñ': 'N',
2458
            'Ò': 'O',
2459
            'Ó': 'O',
2460
            'Ô': 'O',
2461
            'Õ': 'O',
2462
            'Ö': 'Oe',
2463
            'Ő': 'O',
2464
            'Ø': 'O',
2465
            'Ù': 'U',
2466
            'Ú': 'U',
2467
            'Û': 'U',
2468
            'Ü': 'Ue',
2469
            'Ű': 'U',
2470
            'Ý': 'Y',
2471
            'Þ': 'TH',
2472
            'ß': 'ss',
2473
            'à': 'a',
2474
            'á': 'a',
2475
            'â': 'a',
2476
            'ã': 'a',
2477
            'ä': 'ae',
2478
            'å': 'a',
2479
            'æ': 'ae',
2480
            'ç': 'c',
2481
            'è': 'e',
2482
            'é': 'e',
2483
            'ê': 'e',
2484
            'ë': 'e',
2485
            'ì': 'i',
2486
            'í': 'i',
2487
            'î': 'i',
2488
            'ï': 'i',
2489
            'ð': 'd',
2490
            'ñ': 'n',
2491
            'ò': 'o',
2492
            'ó': 'o',
2493
            'ô': 'o',
2494
            'õ': 'o',
2495
            'ö': 'oe',
2496
            'ő': 'o',
2497
            'ø': 'o',
2498
            'ù': 'u',
2499
            'ú': 'u',
2500
            'û': 'u',
2501
            'ü': 'ue',
2502
            'ű': 'u',
2503
            'ý': 'y',
2504
            'þ': 'th',
2505
            'ÿ': 'y',
2506
            'ẞ': 'SS',
2507
2508
            // language specific
2509
2510
            // Arabic
2511
            'ا': 'a',
2512
            'أ': 'a',
2513
            'إ': 'i',
2514
            'آ': 'aa',
2515
            'ؤ': 'u',
2516
            'ئ': 'e',
2517
            'ء': 'a',
2518
            'ب': 'b',
2519
            'ت': 't',
2520
            'ث': 'th',
2521
            'ج': 'j',
2522
            'ح': 'h',
2523
            'خ': 'kh',
2524
            'د': 'd',
2525
            'ذ': 'th',
2526
            'ر': 'r',
2527
            'ز': 'z',
2528
            'س': 's',
2529
            'ش': 'sh',
2530
            'ص': 's',
2531
            'ض': 'dh',
2532
            'ط': 't',
2533
            'ظ': 'z',
2534
            'ع': 'a',
2535
            'غ': 'gh',
2536
            'ف': 'f',
2537
            'ق': 'q',
2538
            'ك': 'k',
2539
            'ل': 'l',
2540
            'م': 'm',
2541
            'ن': 'n',
2542
            'ه': 'h',
2543
            'و': 'w',
2544
            'ي': 'y',
2545
            'ى': 'a',
2546
            'ة': 'h',
2547
            'ﻻ': 'la',
2548
            'ﻷ': 'laa',
2549
            'ﻹ': 'lai',
2550
            'ﻵ': 'laa',
2551
2552
            // Persian additional characters than Arabic
2553
            'گ': 'g',
2554
            'چ': 'ch',
2555
            'پ': 'p',
2556
            'ژ': 'zh',
2557
            'ک': 'k',
2558
            'ی': 'y',
2559
2560
            // Arabic diactrics
2561
            'َ': 'a',
2562
            'ً': 'an',
2563
            'ِ': 'e',
2564
            'ٍ': 'en',
2565
            'ُ': 'u',
2566
            'ٌ': 'on',
2567
            'ْ': '',
2568
2569
            // Arabic numbers
2570
            '٠': '0',
2571
            '١': '1',
2572
            '٢': '2',
2573
            '٣': '3',
2574
            '٤': '4',
2575
            '٥': '5',
2576
            '٦': '6',
2577
            '٧': '7',
2578
            '٨': '8',
2579
            '٩': '9',
2580
2581
            // Persian numbers
2582
            '۰': '0',
2583
            '۱': '1',
2584
            '۲': '2',
2585
            '۳': '3',
2586
            '۴': '4',
2587
            '۵': '5',
2588
            '۶': '6',
2589
            '۷': '7',
2590
            '۸': '8',
2591
            '۹': '9',
2592
2593
            // Burmese consonants
2594
            'က': 'k',
2595
            'ခ': 'kh',
2596
            'ဂ': 'g',
2597
            'ဃ': 'ga',
2598
            'င': 'ng',
2599
            'စ': 's',
2600
            'ဆ': 'sa',
2601
            'ဇ': 'z',
2602
            'စျ': 'za',
2603
            'ည': 'ny',
2604
            'ဋ': 't',
2605
            'ဌ': 'ta',
2606
            'ဍ': 'd',
2607
            'ဎ': 'da',
2608
            'ဏ': 'na',
2609
            'တ': 't',
2610
            'ထ': 'ta',
2611
            'ဒ': 'd',
2612
            'ဓ': 'da',
2613
            'န': 'n',
2614
            'ပ': 'p',
2615
            'ဖ': 'pa',
2616
            'ဗ': 'b',
2617
            'ဘ': 'ba',
2618
            'မ': 'm',
2619
            'ယ': 'y',
2620
            'ရ': 'ya',
2621
            'လ': 'l',
2622
            'ဝ': 'w',
2623
            'သ': 'th',
2624
            'ဟ': 'h',
2625
            'ဠ': 'la',
2626
            'အ': 'a',
2627
            // consonant character combos
2628
            'ြ': 'y',
2629
            'ျ': 'ya',
2630
            'ွ': 'w',
2631
            'ြွ': 'yw',
2632
            'ျွ': 'ywa',
2633
            'ှ': 'h',
2634
            // independent vowels
2635
            'ဧ': 'e',
2636
            '၏': '-e',
2637
            'ဣ': 'i',
2638
            'ဤ': '-i',
2639
            'ဉ': 'u',
2640
            'ဦ': '-u',
2641
            'ဩ': 'aw',
2642
            'သြော': 'aw',
2643
            'ဪ': 'aw',
2644
            // numbers
2645
            '၀': '0',
2646
            '၁': '1',
2647
            '၂': '2',
2648
            '၃': '3',
2649
            '၄': '4',
2650
            '၅': '5',
2651
            '၆': '6',
2652
            '၇': '7',
2653
            '၈': '8',
2654
            '၉': '9',
2655
            // virama and tone marks which are silent in transliteration
2656
            '္': '',
2657
            '့': '',
2658
            'း': '',
2659
2660
            // Czech
2661
            'č': 'c',
2662
            'ď': 'd',
2663
            'ě': 'e',
2664
            'ň': 'n',
2665
            'ř': 'r',
2666
            'š': 's',
2667
            'ť': 't',
2668
            'ů': 'u',
2669
            'ž': 'z',
2670
            'Č': 'C',
2671
            'Ď': 'D',
2672
            'Ě': 'E',
2673
            'Ň': 'N',
2674
            'Ř': 'R',
2675
            'Š': 'S',
2676
            'Ť': 'T',
2677
            'Ů': 'U',
2678
            'Ž': 'Z',
2679
2680
            // Dhivehi
2681
            'ހ': 'h',
2682
            'ށ': 'sh',
2683
            'ނ': 'n',
2684
            'ރ': 'r',
2685
            'ބ': 'b',
2686
            'ޅ': 'lh',
2687
            'ކ': 'k',
2688
            'އ': 'a',
2689
            'ވ': 'v',
2690
            'މ': 'm',
2691
            'ފ': 'f',
2692
            'ދ': 'dh',
2693
            'ތ': 'th',
2694
            'ލ': 'l',
2695
            'ގ': 'g',
2696
            'ޏ': 'gn',
2697
            'ސ': 's',
2698
            'ޑ': 'd',
2699
            'ޒ': 'z',
2700
            'ޓ': 't',
2701
            'ޔ': 'y',
2702
            'ޕ': 'p',
2703
            'ޖ': 'j',
2704
            'ޗ': 'ch',
2705
            'ޘ': 'tt',
2706
            'ޙ': 'hh',
2707
            'ޚ': 'kh',
2708
            'ޛ': 'th',
2709
            'ޜ': 'z',
2710
            'ޝ': 'sh',
2711
            'ޞ': 's',
2712
            'ޟ': 'd',
2713
            'ޠ': 't',
2714
            'ޡ': 'z',
2715
            'ޢ': 'a',
2716
            'ޣ': 'gh',
2717
            'ޤ': 'q',
2718
            'ޥ': 'w',
2719
            'ަ': 'a',
2720
            'ާ': 'aa',
2721
            'ި': 'i',
2722
            'ީ': 'ee',
2723
            'ު': 'u',
2724
            'ޫ': 'oo',
2725
            'ެ': 'e',
2726
            'ޭ': 'ey',
2727
            'ޮ': 'o',
2728
            'ޯ': 'oa',
2729
            'ް': '',
2730
2731
            // Greek
2732
            'α': 'a',
2733
            'β': 'v',
2734
            'γ': 'g',
2735
            'δ': 'd',
2736
            'ε': 'e',
2737
            'ζ': 'z',
2738
            'η': 'i',
2739
            'θ': 'th',
2740
            'ι': 'i',
2741
            'κ': 'k',
2742
            'λ': 'l',
2743
            'μ': 'm',
2744
            'ν': 'n',
2745
            'ξ': 'ks',
2746
            'ο': 'o',
2747
            'π': 'p',
2748
            'ρ': 'r',
2749
            'σ': 's',
2750
            'τ': 't',
2751
            'υ': 'y',
2752
            'φ': 'f',
2753
            'χ': 'x',
2754
            'ψ': 'ps',
2755
            'ω': 'o',
2756
            'ά': 'a',
2757
            'έ': 'e',
2758
            'ί': 'i',
2759
            'ό': 'o',
2760
            'ύ': 'y',
2761
            'ή': 'i',
2762
            'ώ': 'o',
2763
            'ς': 's',
2764
            'ϊ': 'i',
2765
            'ΰ': 'y',
2766
            'ϋ': 'y',
2767
            'ΐ': 'i',
2768
            'Α': 'A',
2769
            'Β': 'B',
2770
            'Γ': 'G',
2771
            'Δ': 'D',
2772
            'Ε': 'E',
2773
            'Ζ': 'Z',
2774
            'Η': 'I',
2775
            'Θ': 'TH',
2776
            'Ι': 'I',
2777
            'Κ': 'K',
2778
            'Λ': 'L',
2779
            'Μ': 'M',
2780
            'Ν': 'N',
2781
            'Ξ': 'KS',
2782
            'Ο': 'O',
2783
            'Π': 'P',
2784
            'Ρ': 'R',
2785
            'Σ': 'S',
2786
            'Τ': 'T',
2787
            'Υ': 'Y',
2788
            'Φ': 'F',
2789
            'Χ': 'X',
2790
            'Ψ': 'PS',
2791
            'Ω': 'W',
2792
            'Ά': 'A',
2793
            'Έ': 'E',
2794
            'Ί': 'I',
2795
            'Ό': 'O',
2796
            'Ύ': 'Y',
2797
            'Ή': 'I',
2798
            'Ώ': 'O',
2799
            'Ϊ': 'I',
2800
            'Ϋ': 'Y',
2801
2802
            // Latvian
2803
            'ā': 'a',
2804
            // 'č': 'c', // duplicate
2805
            'ē': 'e',
2806
            'ģ': 'g',
2807
            'ī': 'i',
2808
            'ķ': 'k',
2809
            'ļ': 'l',
2810
            'ņ': 'n',
2811
            // 'š': 's', // duplicate
2812
            'ū': 'u',
2813
            // 'ž': 'z', // duplicate
2814
            'Ā': 'A',
2815
            // 'Č': 'C', // duplicate
2816
            'Ē': 'E',
2817
            'Ģ': 'G',
2818
            'Ī': 'I',
2819
            'Ķ': 'k',
2820
            'Ļ': 'L',
2821
            'Ņ': 'N',
2822
            // 'Š': 'S', // duplicate
2823
            'Ū': 'U',
2824
            // 'Ž': 'Z', // duplicate
2825
2826
            // Macedonian
2827
            'Ќ': 'Kj',
2828
            'ќ': 'kj',
2829
            'Љ': 'Lj',
2830
            'љ': 'lj',
2831
            'Њ': 'Nj',
2832
            'њ': 'nj',
2833
            'Тс': 'Ts',
2834
            'тс': 'ts',
2835
2836
            // Polish
2837
            'ą': 'a',
2838
            'ć': 'c',
2839
            'ę': 'e',
2840
            'ł': 'l',
2841
            'ń': 'n',
2842
            // 'ó': 'o', // duplicate
2843
            'ś': 's',
2844
            'ź': 'z',
2845
            'ż': 'z',
2846
            'Ą': 'A',
2847
            'Ć': 'C',
2848
            'Ę': 'E',
2849
            'Ł': 'L',
2850
            'Ń': 'N',
2851
            'Ś': 'S',
2852
            'Ź': 'Z',
2853
            'Ż': 'Z',
2854
2855
            // Ukranian
2856
            'Є': 'Ye',
2857
            'І': 'I',
2858
            'Ї': 'Yi',
2859
            'Ґ': 'G',
2860
            'є': 'ye',
2861
            'і': 'i',
2862
            'ї': 'yi',
2863
            'ґ': 'g',
2864
2865
            // Romanian
2866
            'ă': 'a',
2867
            'Ă': 'A',
2868
            'ș': 's',
2869
            'Ș': 'S',
2870
            // 'ş': 's', // duplicate
2871
            // 'Ş': 'S', // duplicate
2872
            'ț': 't',
2873
            'Ț': 'T',
2874
            'ţ': 't',
2875
            'Ţ': 'T',
2876
2877
            // Russian https://en.wikipedia.org/wiki/Romanization_of_Russian
2878
            // ICAO
2879
2880
            'а': 'a',
2881
            'б': 'b',
2882
            'в': 'v',
2883
            'г': 'g',
2884
            'д': 'd',
2885
            'е': 'e',
2886
            'ё': 'yo',
2887
            'ж': 'zh',
2888
            'з': 'z',
2889
            'и': 'i',
2890
            'й': 'i',
2891
            'к': 'k',
2892
            'л': 'l',
2893
            'м': 'm',
2894
            'н': 'n',
2895
            'о': 'o',
2896
            'п': 'p',
2897
            'р': 'r',
2898
            'с': 's',
2899
            'т': 't',
2900
            'у': 'u',
2901
            'ф': 'f',
2902
            'х': 'kh',
2903
            'ц': 'c',
2904
            'ч': 'ch',
2905
            'ш': 'sh',
2906
            'щ': 'sh',
2907
            'ъ': '',
2908
            'ы': 'y',
2909
            'ь': '',
2910
            'э': 'e',
2911
            'ю': 'yu',
2912
            'я': 'ya',
2913
            'А': 'A',
2914
            'Б': 'B',
2915
            'В': 'V',
2916
            'Г': 'G',
2917
            'Д': 'D',
2918
            'Е': 'E',
2919
            'Ё': 'Yo',
2920
            'Ж': 'Zh',
2921
            'З': 'Z',
2922
            'И': 'I',
2923
            'Й': 'I',
2924
            'К': 'K',
2925
            'Л': 'L',
2926
            'М': 'M',
2927
            'Н': 'N',
2928
            'О': 'O',
2929
            'П': 'P',
2930
            'Р': 'R',
2931
            'С': 'S',
2932
            'Т': 'T',
2933
            'У': 'U',
2934
            'Ф': 'F',
2935
            'Х': 'Kh',
2936
            'Ц': 'C',
2937
            'Ч': 'Ch',
2938
            'Ш': 'Sh',
2939
            'Щ': 'Sh',
2940
            'Ъ': '',
2941
            'Ы': 'Y',
2942
            'Ь': '',
2943
            'Э': 'E',
2944
            'Ю': 'Yu',
2945
            'Я': 'Ya',
2946
2947
            // Serbian
2948
            'ђ': 'dj',
2949
            'ј': 'j',
2950
            // 'љ': 'lj',  // duplicate
2951
            // 'њ': 'nj', // duplicate
2952
            'ћ': 'c',
2953
            'џ': 'dz',
2954
            'Ђ': 'Dj',
2955
            'Ј': 'j',
2956
            // 'Љ': 'Lj', // duplicate
2957
            // 'Њ': 'Nj', // duplicate
2958
            'Ћ': 'C',
2959
            'Џ': 'Dz',
2960
2961
            // Slovak
2962
            'ľ': 'l',
2963
            'ĺ': 'l',
2964
            'ŕ': 'r',
2965
            'Ľ': 'L',
2966
            'Ĺ': 'L',
2967
            'Ŕ': 'R',
2968
2969
            // Turkish
2970
            'ş': 's',
2971
            'Ş': 'S',
2972
            'ı': 'i',
2973
            'İ': 'I',
2974
            // 'ç': 'c', // duplicate
2975
            // 'Ç': 'C', // duplicate
2976
            // 'ü': 'u', // duplicate, see langCharMap
2977
            // 'Ü': 'U', // duplicate, see langCharMap
2978
            // 'ö': 'o', // duplicate, see langCharMap
2979
            // 'Ö': 'O', // duplicate, see langCharMap
2980
            'ğ': 'g',
2981
            'Ğ': 'G',
2982
2983
            // Vietnamese
2984
            'ả': 'a',
2985
            'Ả': 'A',
2986
            'ẳ': 'a',
2987
            'Ẳ': 'A',
2988
            'ẩ': 'a',
2989
            'Ẩ': 'A',
2990
            'đ': 'd',
2991
            'Đ': 'D',
2992
            'ẹ': 'e',
2993
            'Ẹ': 'E',
2994
            'ẽ': 'e',
2995
            'Ẽ': 'E',
2996
            'ẻ': 'e',
2997
            'Ẻ': 'E',
2998
            'ế': 'e',
2999
            'Ế': 'E',
3000
            'ề': 'e',
3001
            'Ề': 'E',
3002
            'ệ': 'e',
3003
            'Ệ': 'E',
3004
            'ễ': 'e',
3005
            'Ễ': 'E',
3006
            'ể': 'e',
3007
            'Ể': 'E',
3008
            'ọ': 'o',
3009
            'Ọ': 'o',
3010
            'ố': 'o',
3011
            'Ố': 'O',
3012
            'ồ': 'o',
3013
            'Ồ': 'O',
3014
            'ổ': 'o',
3015
            'Ổ': 'O',
3016
            'ộ': 'o',
3017
            'Ộ': 'O',
3018
            'ỗ': 'o',
3019
            'Ỗ': 'O',
3020
            'ơ': 'o',
3021
            'Ơ': 'O',
3022
            'ớ': 'o',
3023
            'Ớ': 'O',
3024
            'ờ': 'o',
3025
            'Ờ': 'O',
3026
            'ợ': 'o',
3027
            'Ợ': 'O',
3028
            'ỡ': 'o',
3029
            'Ỡ': 'O',
3030
            'Ở': 'o',
3031
            'ở': 'o',
3032
            'ị': 'i',
3033
            'Ị': 'I',
3034
            'ĩ': 'i',
3035
            'Ĩ': 'I',
3036
            'ỉ': 'i',
3037
            'Ỉ': 'i',
3038
            'ủ': 'u',
3039
            'Ủ': 'U',
3040
            'ụ': 'u',
3041
            'Ụ': 'U',
3042
            'ũ': 'u',
3043
            'Ũ': 'U',
3044
            'ư': 'u',
3045
            'Ư': 'U',
3046
            'ứ': 'u',
3047
            'Ứ': 'U',
3048
            'ừ': 'u',
3049
            'Ừ': 'U',
3050
            'ự': 'u',
3051
            'Ự': 'U',
3052
            'ữ': 'u',
3053
            'Ữ': 'U',
3054
            'ử': 'u',
3055
            'Ử': 'ư',
3056
            'ỷ': 'y',
3057
            'Ỷ': 'y',
3058
            'ỳ': 'y',
3059
            'Ỳ': 'Y',
3060
            'ỵ': 'y',
3061
            'Ỵ': 'Y',
3062
            'ỹ': 'y',
3063
            'Ỹ': 'Y',
3064
            'ạ': 'a',
3065
            'Ạ': 'A',
3066
            'ấ': 'a',
3067
            'Ấ': 'A',
3068
            'ầ': 'a',
3069
            'Ầ': 'A',
3070
            'ậ': 'a',
3071
            'Ậ': 'A',
3072
            'ẫ': 'a',
3073
            'Ẫ': 'A',
3074
            // 'ă': 'a', // duplicate
3075
            // 'Ă': 'A', // duplicate
3076
            'ắ': 'a',
3077
            'Ắ': 'A',
3078
            'ằ': 'a',
3079
            'Ằ': 'A',
3080
            'ặ': 'a',
3081
            'Ặ': 'A',
3082
            'ẵ': 'a',
3083
            'Ẵ': 'A',
3084
3085
            // symbols
3086
            '“': '"',
3087
            '”': '"',
3088
            '‘': '\'',
3089
            '’': '\'',
3090
            '∂': 'd',
3091
            'ƒ': 'f',
3092
            '™': '(TM)',
3093
            '©': '(C)',
3094
            'œ': 'oe',
3095
            'Œ': 'OE',
3096
            '®': '(R)',
3097
            '†': '+',
3098
            '℠': '(SM)',
3099
            '…': '...',
3100
            '˚': 'o',
3101
            'º': 'o',
3102
            'ª': 'a',
3103
            '•': '*',
3104
            '၊': ',',
3105
            '။': '.',
3106
3107
            // currency
3108
            '$': 'USD',
3109
            '€': 'EUR',
3110
            '₢': 'BRN',
3111
            '₣': 'FRF',
3112
            '£': 'GBP',
3113
            '₤': 'ITL',
3114
            '₦': 'NGN',
3115
            '₧': 'ESP',
3116
            '₩': 'KRW',
3117
            '₪': 'ILS',
3118
            '₫': 'VND',
3119
            '₭': 'LAK',
3120
            '₮': 'MNT',
3121
            '₯': 'GRD',
3122
            '₱': 'ARS',
3123
            '₲': 'PYG',
3124
            '₳': 'ARA',
3125
            '₴': 'UAH',
3126
            '₵': 'GHS',
3127
            '¢': 'cent',
3128
            '¥': 'CNY',
3129
            '元': 'CNY',
3130
            '円': 'YEN',
3131
            '﷼': 'IRR',
3132
            '₠': 'EWE',
3133
            '฿': 'THB',
3134
            '₨': 'INR',
3135
            '₹': 'INR',
3136
            '₰': 'PF'
3137
3138
        };
3139
3140
        /**
3141
         * special look ahead character array
3142
         * These characters form with consonants to become 'single'/consonant combo
3143
         * @type [Array]
3144
         */
3145
        var lookAheadCharArray = [
3146
            // burmese
3147
            '်',
3148
3149
            // Dhivehi
3150
            'ް'
3151
        ];
3152
3153
        /**
3154
         * diatricMap for languages where transliteration changes entirely as more diatrics are added
3155
         * @type {Object}
3156
         */
3157
        var diatricMap = {
3158
            // Burmese
3159
            // dependent vowels
3160
            'ာ': 'a',
3161
            'ါ': 'a',
3162
            'ေ': 'e',
3163
            'ဲ': 'e',
3164
            'ိ': 'i',
3165
            'ီ': 'i',
3166
            'ို': 'o',
3167
            'ု': 'u',
3168
            'ူ': 'u',
3169
            'ေါင်': 'aung',
3170
            'ော': 'aw',
3171
            'ော်': 'aw',
3172
            'ေါ': 'aw',
3173
            'ေါ်': 'aw',
3174
            '်': '်', // this is special case but the character will be converted to latin in the code
3175
            'က်': 'et',
3176
            'ိုက်': 'aik',
3177
            'ောက်': 'auk',
3178
            'င်': 'in',
3179
            'ိုင်': 'aing',
3180
            'ောင်': 'aung',
3181
            'စ်': 'it',
3182
            'ည်': 'i',
3183
            'တ်': 'at',
3184
            'ိတ်': 'eik',
3185
            'ုတ်': 'ok',
3186
            'ွတ်': 'ut',
3187
            'ေတ်': 'it',
3188
            'ဒ်': 'd',
3189
            'ိုဒ်': 'ok',
3190
            'ုဒ်': 'ait',
3191
            'န်': 'an',
3192
            'ာန်': 'an',
3193
            'ိန်': 'ein',
3194
            'ုန်': 'on',
3195
            'ွန်': 'un',
3196
            'ပ်': 'at',
3197
            'ိပ်': 'eik',
3198
            'ုပ်': 'ok',
3199
            'ွပ်': 'ut',
3200
            'န်ုပ်': 'nub',
3201
            'မ်': 'an',
3202
            'ိမ်': 'ein',
3203
            'ုမ်': 'on',
3204
            'ွမ်': 'un',
3205
            'ယ်': 'e',
3206
            'ိုလ်': 'ol',
3207
            'ဉ်': 'in',
3208
            'ံ': 'an',
3209
            'ိံ': 'ein',
3210
            'ုံ': 'on',
3211
3212
            // Dhivehi
3213
            'ައް': 'ah',
3214
            'ަށް': 'ah',
3215
        };
3216
3217
        /**
3218
         * langCharMap language specific characters translations
3219
         * @type   {Object}
3220
         */
3221
        var langCharMap = {
3222
3223
            'en': {}, // default language
3224
3225
            'az': { // Azerbaijani
3226
                'ç': 'c',
3227
                'ə': 'e',
3228
                'ğ': 'g',
3229
                'ı': 'i',
3230
                'ö': 'o',
3231
                'ş': 's',
3232
                'ü': 'u',
3233
                'Ç': 'C',
3234
                'Ə': 'E',
3235
                'Ğ': 'G',
3236
                'İ': 'I',
3237
                'Ö': 'O',
3238
                'Ş': 'S',
3239
                'Ü': 'U'
3240
            },
3241
3242
            'cs': { // Czech
3243
                'č': 'c',
3244
                'ď': 'd',
3245
                'ě': 'e',
3246
                'ň': 'n',
3247
                'ř': 'r',
3248
                'š': 's',
3249
                'ť': 't',
3250
                'ů': 'u',
3251
                'ž': 'z',
3252
                'Č': 'C',
3253
                'Ď': 'D',
3254
                'Ě': 'E',
3255
                'Ň': 'N',
3256
                'Ř': 'R',
3257
                'Š': 'S',
3258
                'Ť': 'T',
3259
                'Ů': 'U',
3260
                'Ž': 'Z'
3261
            },
3262
3263
            'fi': { // Finnish
3264
                // 'å': 'a', duplicate see charMap/latin
3265
                // 'Å': 'A', duplicate see charMap/latin
3266
                'ä': 'a', // ok
3267
                'Ä': 'A', // ok
3268
                'ö': 'o', // ok
3269
                'Ö': 'O' // ok
3270
            },
3271
3272
            'hu': { // Hungarian
3273
                'ä': 'a', // ok
3274
                'Ä': 'A', // ok
3275
                // 'á': 'a', duplicate see charMap/latin
3276
                // 'Á': 'A', duplicate see charMap/latin
3277
                'ö': 'o', // ok
3278
                'Ö': 'O', // ok
3279
                // 'ő': 'o', duplicate see charMap/latin
3280
                // 'Ő': 'O', duplicate see charMap/latin
3281
                'ü': 'u',
3282
                'Ü': 'U',
3283
                'ű': 'u',
3284
                'Ű': 'U'
3285
            },
3286
3287
            'lt': { // Lithuanian
3288
                'ą': 'a',
3289
                'č': 'c',
3290
                'ę': 'e',
3291
                'ė': 'e',
3292
                'į': 'i',
3293
                'š': 's',
3294
                'ų': 'u',
3295
                'ū': 'u',
3296
                'ž': 'z',
3297
                'Ą': 'A',
3298
                'Č': 'C',
3299
                'Ę': 'E',
3300
                'Ė': 'E',
3301
                'Į': 'I',
3302
                'Š': 'S',
3303
                'Ų': 'U',
3304
                'Ū': 'U'
3305
            },
3306
3307
            'lv': { // Latvian
3308
                'ā': 'a',
3309
                'č': 'c',
3310
                'ē': 'e',
3311
                'ģ': 'g',
3312
                'ī': 'i',
3313
                'ķ': 'k',
3314
                'ļ': 'l',
3315
                'ņ': 'n',
3316
                'š': 's',
3317
                'ū': 'u',
3318
                'ž': 'z',
3319
                'Ā': 'A',
3320
                'Č': 'C',
3321
                'Ē': 'E',
3322
                'Ģ': 'G',
3323
                'Ī': 'i',
3324
                'Ķ': 'k',
3325
                'Ļ': 'L',
3326
                'Ņ': 'N',
3327
                'Š': 'S',
3328
                'Ū': 'u',
3329
                'Ž': 'Z'
3330
            },
3331
3332
            'pl': { // Polish
3333
                'ą': 'a',
3334
                'ć': 'c',
3335
                'ę': 'e',
3336
                'ł': 'l',
3337
                'ń': 'n',
3338
                'ó': 'o',
3339
                'ś': 's',
3340
                'ź': 'z',
3341
                'ż': 'z',
3342
                'Ą': 'A',
3343
                'Ć': 'C',
3344
                'Ę': 'e',
3345
                'Ł': 'L',
3346
                'Ń': 'N',
3347
                'Ó': 'O',
3348
                'Ś': 'S',
3349
                'Ź': 'Z',
3350
                'Ż': 'Z'
3351
            },
3352
3353
            'sk': { // Slovak
3354
                'ä': 'a',
3355
                'Ä': 'A'
3356
            },
3357
3358
            'sr': { // Serbian
3359
                'љ': 'lj',
3360
                'њ': 'nj',
3361
                'Љ': 'Lj',
3362
                'Њ': 'Nj',
3363
                'đ': 'dj',
3364
                'Đ': 'Dj'
3365
            },
3366
3367
            'tr': { // Turkish
3368
                'Ü': 'U',
3369
                'Ö': 'O',
3370
                'ü': 'u',
3371
                'ö': 'o'
3372
            }
3373
        };
3374
3375
        /**
3376
         * symbolMap language specific symbol translations
3377
         * translations must be transliterated already
3378
         * @type   {Object}
3379
         */
3380
        var symbolMap = {
3381
3382
            'ar': {
3383
                '∆': 'delta',
3384
                '∞': 'la-nihaya',
3385
                '♥': 'hob',
3386
                '&': 'wa',
3387
                '|': 'aw',
3388
                '<': 'aqal-men',
3389
                '>': 'akbar-men',
3390
                '∑': 'majmou',
3391
                '¤': 'omla'
3392
            },
3393
3394
            'az': {},
3395
3396
            'ca': {
3397
                '∆': 'delta',
3398
                '∞': 'infinit',
3399
                '♥': 'amor',
3400
                '&': 'i',
3401
                '|': 'o',
3402
                '<': 'menys que',
3403
                '>': 'mes que',
3404
                '∑': 'suma dels',
3405
                '¤': 'moneda'
3406
            },
3407
3408
            'cz': {
3409
                '∆': 'delta',
3410
                '∞': 'nekonecno',
3411
                '♥': 'laska',
3412
                '&': 'a',
3413
                '|': 'nebo',
3414
                '<': 'mene jako',
3415
                '>': 'vice jako',
3416
                '∑': 'soucet',
3417
                '¤': 'mena'
3418
            },
3419
3420
            'de': {
3421
                '∆': 'delta',
3422
                '∞': 'unendlich',
3423
                '♥': 'Liebe',
3424
                '&': 'und',
3425
                '|': 'oder',
3426
                '<': 'kleiner als',
3427
                '>': 'groesser als',
3428
                '∑': 'Summe von',
3429
                '¤': 'Waehrung'
3430
            },
3431
3432
            'dv': {
3433
                '∆': 'delta',
3434
                '∞': 'kolunulaa',
3435
                '♥': 'loabi',
3436
                '&': 'aai',
3437
                '|': 'noonee',
3438
                '<': 'ah vure kuda',
3439
                '>': 'ah vure bodu',
3440
                '∑': 'jumula',
3441
                '¤': 'faisaa'
3442
            },
3443
3444
            'en': {
3445
                '∆': 'delta',
3446
                '∞': 'infinity',
3447
                '♥': 'love',
3448
                '&': 'and',
3449
                '|': 'or',
3450
                '<': 'less than',
3451
                '>': 'greater than',
3452
                '∑': 'sum',
3453
                '¤': 'currency'
3454
            },
3455
3456
            'es': {
3457
                '∆': 'delta',
3458
                '∞': 'infinito',
3459
                '♥': 'amor',
3460
                '&': 'y',
3461
                '|': 'u',
3462
                '<': 'menos que',
3463
                '>': 'mas que',
3464
                '∑': 'suma de los',
3465
                '¤': 'moneda'
3466
            },
3467
3468
            'fa': {
3469
                '∆': 'delta',
3470
                '∞': 'bi-nahayat',
3471
                '♥': 'eshgh',
3472
                '&': 'va',
3473
                '|': 'ya',
3474
                '<': 'kamtar-az',
3475
                '>': 'bishtar-az',
3476
                '∑': 'majmooe',
3477
                '¤': 'vahed'
3478
            },
3479
3480
            'fr': {
3481
                '∆': 'delta',
3482
                '∞': 'infiniment',
3483
                '♥': 'Amour',
3484
                '&': 'et',
3485
                '|': 'ou',
3486
                '<': 'moins que',
3487
                '>': 'superieure a',
3488
                '∑': 'somme des',
3489
                '¤': 'monnaie'
3490
            },
3491
3492
            'gr': {},
3493
3494
            'hu': {
3495
                '∆': 'delta',
3496
                '∞': 'vegtelen',
3497
                '♥': 'szerelem',
3498
                '&': 'es',
3499
                '|': 'vagy',
3500
                '<': 'kisebb mint',
3501
                '>': 'nagyobb mint',
3502
                '∑': 'szumma',
3503
                '¤': 'penznem'
3504
            },
3505
3506
            'it': {
3507
                '∆': 'delta',
3508
                '∞': 'infinito',
3509
                '♥': 'amore',
3510
                '&': 'e',
3511
                '|': 'o',
3512
                '<': 'minore di',
3513
                '>': 'maggiore di',
3514
                '∑': 'somma',
3515
                '¤': 'moneta'
3516
            },
3517
3518
            'lt': {},
3519
3520
            'lv': {
3521
                '∆': 'delta',
3522
                '∞': 'bezgaliba',
3523
                '♥': 'milestiba',
3524
                '&': 'un',
3525
                '|': 'vai',
3526
                '<': 'mazak neka',
3527
                '>': 'lielaks neka',
3528
                '∑': 'summa',
3529
                '¤': 'valuta'
3530
            },
3531
3532
            'my': {
3533
                '∆': 'kwahkhyaet',
3534
                '∞': 'asaonasme',
3535
                '♥': 'akhyait',
3536
                '&': 'nhin',
3537
                '|': 'tho',
3538
                '<': 'ngethaw',
3539
                '>': 'kyithaw',
3540
                '∑': 'paungld',
3541
                '¤': 'ngwekye'
3542
            },
3543
3544
            'mk': {},
3545
3546
            'nl': {
3547
                '∆': 'delta',
3548
                '∞': 'oneindig',
3549
                '♥': 'liefde',
3550
                '&': 'en',
3551
                '|': 'of',
3552
                '<': 'kleiner dan',
3553
                '>': 'groter dan',
3554
                '∑': 'som',
3555
                '¤': 'valuta'
3556
            },
3557
3558
            'pl': {
3559
                '∆': 'delta',
3560
                '∞': 'nieskonczonosc',
3561
                '♥': 'milosc',
3562
                '&': 'i',
3563
                '|': 'lub',
3564
                '<': 'mniejsze niz',
3565
                '>': 'wieksze niz',
3566
                '∑': 'suma',
3567
                '¤': 'waluta'
3568
            },
3569
3570
            'pt': {
3571
                '∆': 'delta',
3572
                '∞': 'infinito',
3573
                '♥': 'amor',
3574
                '&': 'e',
3575
                '|': 'ou',
3576
                '<': 'menor que',
3577
                '>': 'maior que',
3578
                '∑': 'soma',
3579
                '¤': 'moeda'
3580
            },
3581
3582
            'ro': {
3583
                '∆': 'delta',
3584
                '∞': 'infinit',
3585
                '♥': 'dragoste',
3586
                '&': 'si',
3587
                '|': 'sau',
3588
                '<': 'mai mic ca',
3589
                '>': 'mai mare ca',
3590
                '∑': 'suma',
3591
                '¤': 'valuta'
3592
            },
3593
3594
            'ru': {
3595
                '∆': 'delta',
3596
                '∞': 'beskonechno',
3597
                '♥': 'lubov',
3598
                '&': 'i',
3599
                '|': 'ili',
3600
                '<': 'menshe',
3601
                '>': 'bolshe',
3602
                '∑': 'summa',
3603
                '¤': 'valjuta'
3604
            },
3605
3606
            'sk': {
3607
                '∆': 'delta',
3608
                '∞': 'nekonecno',
3609
                '♥': 'laska',
3610
                '&': 'a',
3611
                '|': 'alebo',
3612
                '<': 'menej ako',
3613
                '>': 'viac ako',
3614
                '∑': 'sucet',
3615
                '¤': 'mena'
3616
            },
3617
3618
            'sr': {},
3619
3620
            'tr': {
3621
                '∆': 'delta',
3622
                '∞': 'sonsuzluk',
3623
                '♥': 'ask',
3624
                '&': 've',
3625
                '|': 'veya',
3626
                '<': 'kucuktur',
3627
                '>': 'buyuktur',
3628
                '∑': 'toplam',
3629
                '¤': 'para birimi'
3630
            },
3631
3632
            'uk': {
3633
                '∆': 'delta',
3634
                '∞': 'bezkinechnist',
3635
                '♥': 'lubov',
3636
                '&': 'i',
3637
                '|': 'abo',
3638
                '<': 'menshe',
3639
                '>': 'bilshe',
3640
                '∑': 'suma',
3641
                '¤': 'valjuta'
3642
            },
3643
3644
            'vn': {
3645
                '∆': 'delta',
3646
                '∞': 'vo cuc',
3647
                '♥': 'yeu',
3648
                '&': 'va',
3649
                '|': 'hoac',
3650
                '<': 'nho hon',
3651
                '>': 'lon hon',
3652
                '∑': 'tong',
3653
                '¤': 'tien te'
3654
            }
3655
        };
3656
3657
        if (typeof input !== 'string') {
3658
            return '';
3659
        }
3660
3661
        if (typeof opts === 'string') {
3662
            separator = opts;
3663
        }
3664
3665
        symbol = symbolMap.en;
3666
        langChar = langCharMap.en;
3667
3668
        if (typeof opts === 'object') {
3669
3670
            maintainCase = opts.maintainCase || false;
3671
            customReplacements = (opts.custom && typeof opts.custom === 'object') ? opts.custom : customReplacements;
3672
            truncate = (+opts.truncate > 1 && opts.truncate) || false;
3673
            uricFlag = opts.uric || false;
3674
            uricNoSlashFlag = opts.uricNoSlash || false;
3675
            markFlag = opts.mark || false;
3676
            convertSymbols = (opts.symbols === false || opts.lang === false) ? false : true;
3677
            separator = opts.separator || separator;
3678
3679
            if (uricFlag) {
3680
                allowedChars += uricChars.join('');
0 ignored issues
show
Bug introduced by
The variable allowedChars seems to be never initialized.
Loading history...
3681
            }
3682
3683
            if (uricNoSlashFlag) {
3684
                allowedChars += uricNoSlashChars.join('');
0 ignored issues
show
Bug introduced by
The variable allowedChars does not seem to be initialized in case uricFlag on line 3679 is false. Are you sure this can never be the case?
Loading history...
3685
            }
3686
3687
            if (markFlag) {
3688
                allowedChars += markChars.join('');
3689
            }
3690
3691
            symbol = (opts.lang && symbolMap[opts.lang] && convertSymbols) ?
3692
                symbolMap[opts.lang] : (convertSymbols ? symbolMap.en : {});
3693
3694
            langChar = (opts.lang && langCharMap[opts.lang]) ?
3695
                langCharMap[opts.lang] :
3696
                opts.lang === false || opts.lang === true ? {} : langCharMap.en;
3697
3698
            // if titleCase config is an Array, rewrite to object format
3699
            if (opts.titleCase && typeof opts.titleCase.length === "number" && Array.prototype.toString.call(opts.titleCase)) {
3700
3701
                opts.titleCase.forEach(function (v) {
3702
                    customReplacements[v + ""] = v + "";
3703
                });
3704
3705
                titleCase = true;
3706
            } else {
3707
                titleCase = !!opts.titleCase;
3708
            }
3709
3710
            // if custom config is an Array, rewrite to object format
3711
            if (opts.custom && typeof opts.custom.length === "number" && Array.prototype.toString.call(opts.custom)) {
3712
3713
                opts.custom.forEach(function (v) {
3714
                    customReplacements[v + ""] = v + "";
3715
                });
3716
            }
3717
3718
            // custom replacements
3719
            Object.keys(customReplacements).forEach(function (v) {
3720
3721
                var r;
3722
3723
                if (v.length > 1) {
3724
                    r = new RegExp('\\b' + escapeChars(v) + '\\b', 'gi');
3725
                } else {
3726
                    r = new RegExp(escapeChars(v), 'gi');
3727
                }
3728
3729
                input = input.replace(r, customReplacements[v]);
3730
            });
3731
3732
            // add all custom replacement to allowed charlist
3733
            for (ch in customReplacements) {
3734
                allowedChars += ch;
0 ignored issues
show
Bug introduced by
The variable allowedChars does not seem to be initialized in case uricFlag on line 3679 is false. Are you sure this can never be the case?
Loading history...
3735
            }
3736
3737
        }
3738
3739
        allowedChars += separator;
3740
3741
        // escape all necessary chars
3742
        allowedChars = escapeChars(allowedChars);
3743
3744
        // trim whitespaces
3745
        input = input.replace(/(^\s+|\s+$)/g, '');
3746
3747
        lastCharWasSymbol = false;
3748
        lastCharWasDiatric = false;
3749
3750
        for (i = 0, l = input.length; i < l; i++) {
3751
3752
            ch = input[i];
3753
3754
            if (isReplacedCustomChar(ch, customReplacements)) {
3755
                // don't convert a already converted char
3756
                lastCharWasSymbol = false;
3757
            } else if (langChar[ch]) {
3758
                // process language specific diactrics chars conversion
3759
                ch = lastCharWasSymbol && langChar[ch].match(/[A-Za-z0-9]/) ? ' ' + langChar[ch] : langChar[ch];
3760
3761
                lastCharWasSymbol = false;
3762
            } else if (ch in charMap) {
3763
                // the transliteration changes entirely when some special characters are added
3764
                if (i + 1 < l && lookAheadCharArray.indexOf(input[i + 1]) >= 0) {
3765
                    diatricString += ch;
3766
                    ch = '';
3767
                } else if (lastCharWasDiatric === true) {
3768
                    ch = diatricMap[diatricString] + charMap[ch];
3769
                    diatricString = '';
3770
                } else {
3771
                    // process diactrics chars
3772
                    ch = lastCharWasSymbol && charMap[ch].match(/[A-Za-z0-9]/) ? ' ' + charMap[ch] : charMap[ch];
3773
                }
3774
3775
                lastCharWasSymbol = false;
3776
                lastCharWasDiatric = false;
3777
            } else
3778
            if (ch in diatricMap) {
3779
                diatricString += ch;
3780
                ch = '';
3781
                // end of string, put the whole meaningful word
3782
                if (i === l - 1) {
3783
                    ch = diatricMap[diatricString];
3784
                }
3785
                lastCharWasDiatric = true;
3786
            } else if (
3787
                // process symbol chars
3788
                symbol[ch] && !(uricFlag && uricChars.join('')
3789
                    .indexOf(ch) !== -1) && !(uricNoSlashFlag && uricNoSlashChars.join('')
3790
                    //.indexOf(ch) !== -1) && !(markFlag && markChars.join('')
3791
                    .indexOf(ch) !== -1)) {
3792
3793
                ch = lastCharWasSymbol || result.substr(-1).match(/[A-Za-z0-9]/) ? separator + symbol[ch] : symbol[ch];
3794
                ch += input[i + 1] !== void 0 && input[i + 1].match(/[A-Za-z0-9]/) ? separator : '';
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
3795
3796
                lastCharWasSymbol = true;
3797
            } else {
3798
                if (lastCharWasDiatric === true) {
3799
                    ch = diatricMap[diatricString] + ch;
3800
                    diatricString = '';
3801
                    lastCharWasDiatric = false;
3802
                } else if (lastCharWasSymbol && (/[A-Za-z0-9]/.test(ch) || result.substr(-1).match(/A-Za-z0-9]/))) {
3803
                    // process latin chars
3804
                    ch = ' ' + ch;
3805
                }
3806
                lastCharWasSymbol = false;
3807
            }
3808
3809
            // add allowed chars
3810
            result += ch.replace(new RegExp('[^\\w\\s' + allowedChars + '_-]', 'g'), separator);
3811
        }
3812
3813
        if (titleCase) {
3814
            result = result.replace(/(\w)(\S*)/g, function (_, i, r) {
3815
                var j = i.toUpperCase() + (r !== null ? r : "");
3816
                return (Object.keys(customReplacements).indexOf(j.toLowerCase()) < 0) ? j : j.toLowerCase();
3817
            });
3818
        }
3819
3820
        // eliminate duplicate separators
3821
        // add separator
3822
        // trim separators from start and end
3823
        result = result.replace(/\s+/g, separator)
3824
            .replace(new RegExp('\\' + separator + '+', 'g'), separator)
3825
            .replace(new RegExp('(^\\' + separator + '+|\\' + separator + '+$)', 'g'), '');
3826
3827
        if (truncate && result.length > truncate) {
3828
3829
            lucky = result.charAt(truncate) === separator;
3830
            result = result.slice(0, truncate);
3831
3832
            if (!lucky) {
3833
                result = result.slice(0, result.lastIndexOf(separator));
3834
            }
3835
        }
3836
3837
        if (!maintainCase && !titleCase) {
3838
            result = result.toLowerCase();
3839
        }
3840
3841
        return result;
3842
    };
3843
3844
    /**
3845
     * createSlug curried(opts)(input)
3846
     * @param   {object|string} opts config object or input string
3847
     * @return  {Function} function getSlugWithConfig()
3848
     **/
3849
    var createSlug = function createSlug(opts) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable createSlug already seems to be declared on line 3849. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
3850
3851
        /**
3852
         * getSlugWithConfig
3853
         * @param   {string} input string
3854
         * @return  {string} slug string
3855
         */
3856
        return function getSlugWithConfig(input) {
3857
            return getSlug(input, opts);
3858
        };
3859
    };
3860
3861
    /**
3862
     * escape Chars
3863
     * @param   {string} input string
3864
     */
3865
    var escapeChars = function escapeChars(input) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable escapeChars already seems to be declared on line 3865. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
3866
3867
        return input.replace(/[-\\^$*+?.()|[\]{}\/]/g, '\\$&');
3868
    };
3869
3870
    /**
3871
     * check if the char is an already converted char from custom list
3872
     * @param   {char} ch character to check
3873
     * @param   {object} customReplacements custom translation map
3874
     */
3875
    var isReplacedCustomChar = function (ch, customReplacements) {
3876
3877
        for (var c in customReplacements) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
3878
            if (customReplacements[c] === ch) {
3879
                return true;
3880
            }
3881
        }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
3882
    };
3883
3884
    if (typeof module !== 'undefined' && module.exports) {
3885
3886
        // export functions for use in Node
3887
        module.exports = getSlug;
3888
        module.exports.createSlug = createSlug;
3889
3890
    } else if (typeof define !== 'undefined' && define.amd) {
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
3891
3892
        // export function for use in AMD
3893
        define([], function () {
3894
            return getSlug;
3895
        });
3896
3897
    } else {
3898
3899
        // don't overwrite global if exists
3900
        try {
3901
            if (root.getSlug || root.createSlug) {
3902
                throw 'speakingurl: globals exists /(getSlug|createSlug)/';
3903
            } else {
3904
                root.getSlug = getSlug;
3905
                root.createSlug = createSlug;
3906
            }
3907
        } catch (e) {}
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
3908
3909
    }
3910
})(this);
3911 View Code Duplication
},{}],11:[function(require,module,exports){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3912
(function (global){
3913
// Best place to find information on XHR features is:
3914
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
3915
3916
var reqfields = [
3917
  'responseType', 'withCredentials', 'timeout', 'onprogress'
3918
]
3919
3920
// Simple and small ajax function
3921
// Takes a parameters object and a callback function
3922
// Parameters:
3923
//  - url: string, required
3924
//  - headers: object of `{header_name: header_value, ...}`
3925
//  - body:
3926
//      + string (sets content type to 'application/x-www-form-urlencoded' if not set in headers)
3927
//      + FormData (doesn't set content type so that browser will set as appropriate)
3928
//  - method: 'GET', 'POST', etc. Defaults to 'GET' or 'POST' based on body
3929
//  - cors: If your using cross-origin, you will need this true for IE8-9
3930
//
3931
// The following parameters are passed onto the xhr object.
3932
// IMPORTANT NOTE: The caller is responsible for compatibility checking.
3933
//  - responseType: string, various compatability, see xhr docs for enum options
3934
//  - withCredentials: boolean, IE10+, CORS only
3935
//  - timeout: long, ms timeout, IE8+
3936
//  - onprogress: callback, IE10+
3937
//
3938
// Callback function prototype:
3939
//  - statusCode from request
3940
//  - response
3941
//    + if responseType set and supported by browser, this is an object of some type (see docs)
3942
//    + otherwise if request completed, this is the string text of the response
3943
//    + if request is aborted, this is "Abort"
3944
//    + if request times out, this is "Timeout"
3945
//    + if request errors before completing (probably a CORS issue), this is "Error"
3946
//  - request object
3947
//
3948
// Returns the request object. So you can call .abort() or other methods
3949
//
3950
// DEPRECATIONS:
3951
//  - Passing a string instead of the params object has been removed!
3952
//
3953
exports.ajax = function (params, callback) {
3954
  // Any variable used more than once is var'd here because
3955
  // minification will munge the variables whereas it can't munge
3956
  // the object access.
3957
  var headers = params.headers || {}
3958
    , body = params.body
3959
    , method = params.method || (body ? 'POST' : 'GET')
3960
    , called = false
3961
3962
  var req = getRequest(params.cors)
3963
3964
  function cb(statusCode, responseText) {
3965
    return function () {
3966
      if (!called) {
3967
        callback(req.status === undefined ? statusCode : req.status,
3968
                 req.status === 0 ? "Error" : (req.response || req.responseText || responseText),
3969
                 req)
3970
        called = true
3971
      }
3972
    }
3973
  }
3974
3975
  req.open(method, params.url, true)
3976
3977
  var success = req.onload = cb(200)
3978
  req.onreadystatechange = function () {
3979
    if (req.readyState === 4) success()
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
3980
  }
3981
  req.onerror = cb(null, 'Error')
3982
  req.ontimeout = cb(null, 'Timeout')
3983
  req.onabort = cb(null, 'Abort')
3984
3985
  if (body) {
3986
    setDefault(headers, 'X-Requested-With', 'XMLHttpRequest')
3987
3988
    if (!global.FormData || !(body instanceof global.FormData)) {
3989
      setDefault(headers, 'Content-Type', 'application/x-www-form-urlencoded')
3990
    }
3991
  }
3992
3993
  for (var i = 0, len = reqfields.length, field; i < len; i++) {
3994
    field = reqfields[i]
3995
    if (params[field] !== undefined)
3996
      req[field] = params[field]
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
3997
  }
3998
3999
  for (var field in headers)
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable field already seems to be declared on line 3993. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
4000
    req.setRequestHeader(field, headers[field])
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4001
4002
  req.send(body)
4003
4004
  return req
4005
}
4006
4007
function getRequest(cors) {
4008
  // XDomainRequest is only way to do CORS in IE 8 and 9
4009
  // But XDomainRequest isn't standards-compatible
4010
  // Notably, it doesn't allow cookies to be sent or set by servers
4011
  // IE 10+ is standards-compatible in its XMLHttpRequest
4012
  // but IE 10 can still have an XDomainRequest object, so we don't want to use it
4013
  if (cors && global.XDomainRequest && !/MSIE 1/.test(navigator.userAgent))
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
4014
    return new XDomainRequest
0 ignored issues
show
Bug introduced by
The variable XDomainRequest seems to be never declared. If this is a global, consider adding a /** global: XDomainRequest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4015
  if (global.XMLHttpRequest)
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if global.XMLHttpRequest is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
4016
    return new XMLHttpRequest
0 ignored issues
show
Bug introduced by
The variable XMLHttpRequest seems to be never declared. If this is a global, consider adding a /** global: XMLHttpRequest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4017
}
4018
4019
function setDefault(obj, key, value) {
4020
  obj[key] = obj[key] || value
4021
}
4022
4023
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
4024
},{}],12:[function(require,module,exports){
4025
'use strict';
4026
4027
var replace = String.prototype.replace;
4028
var percentTwenties = /%20/g;
4029
4030
module.exports = {
4031
    'default': 'RFC3986',
4032
    formatters: {
4033
        RFC1738: function (value) {
4034
            return replace.call(value, percentTwenties, '+');
4035
        },
4036
        RFC3986: function (value) {
4037
            return value;
4038
        }
4039
    },
4040
    RFC1738: 'RFC1738',
4041
    RFC3986: 'RFC3986'
4042
};
4043
4044
},{}],13:[function(require,module,exports){
4045
'use strict';
4046
4047
var stringify = require('./stringify');
4048
var parse = require('./parse');
4049
var formats = require('./formats');
4050
4051
module.exports = {
4052
    formats: formats,
4053
    parse: parse,
4054
    stringify: stringify
4055
};
4056
4057
},{"./formats":12,"./parse":14,"./stringify":15}],14:[function(require,module,exports){
4058
'use strict';
4059
4060
var utils = require('./utils');
4061
4062
var has = Object.prototype.hasOwnProperty;
4063
4064
var defaults = {
4065
    allowDots: false,
4066
    allowPrototypes: false,
4067
    arrayLimit: 20,
4068
    decoder: utils.decode,
4069
    delimiter: '&',
4070
    depth: 5,
4071
    parameterLimit: 1000,
4072
    plainObjects: false,
4073
    strictNullHandling: false
4074
};
4075
4076
var parseValues = function parseValues(str, options) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable parseValues already seems to be declared on line 4076. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
4077
    var obj = {};
4078
    var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
4079
4080
    for (var i = 0; i < parts.length; ++i) {
4081
        var part = parts[i];
4082
        var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
4083
4084
        var key, val;
4085
        if (pos === -1) {
4086
            key = options.decoder(part);
4087
            val = options.strictNullHandling ? null : '';
4088
        } else {
4089
            key = options.decoder(part.slice(0, pos));
4090
            val = options.decoder(part.slice(pos + 1));
4091
        }
4092
        if (has.call(obj, key)) {
4093
            obj[key] = [].concat(obj[key]).concat(val);
4094
        } else {
4095
            obj[key] = val;
4096
        }
4097
    }
4098
4099
    return obj;
4100
};
4101
4102
var parseObject = function parseObject(chain, val, options) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable parseObject already seems to be declared on line 4102. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
4103
    if (!chain.length) {
4104
        return val;
4105
    }
4106
4107
    var root = chain.shift();
4108
4109
    var obj;
4110
    if (root === '[]') {
4111
        obj = [];
4112
        obj = obj.concat(parseObject(chain, val, options));
4113
    } else {
4114
        obj = options.plainObjects ? Object.create(null) : {};
4115
        var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
4116
        var index = parseInt(cleanRoot, 10);
4117
        if (
4118
            !isNaN(index) &&
4119
            root !== cleanRoot &&
4120
            String(index) === cleanRoot &&
4121
            index >= 0 &&
4122
            (options.parseArrays && index <= options.arrayLimit)
4123
        ) {
4124
            obj = [];
4125
            obj[index] = parseObject(chain, val, options);
4126
        } else {
4127
            obj[cleanRoot] = parseObject(chain, val, options);
4128
        }
4129
    }
4130
4131
    return obj;
4132
};
4133
4134
var parseKeys = function parseKeys(givenKey, val, options) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable parseKeys already seems to be declared on line 4134. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
4135
    if (!givenKey) {
4136
        return;
4137
    }
4138
4139
    // Transform dot notation to bracket notation
4140
    var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
4141
4142
    // The regex chunks
4143
4144
    var parent = /^([^\[\]]*)/;
4145
    var child = /(\[[^\[\]]*\])/g;
4146
4147
    // Get the parent
4148
4149
    var segment = parent.exec(key);
4150
4151
    // Stash the parent if it exists
4152
4153
    var keys = [];
4154
    if (segment[1]) {
4155
        // If we aren't using plain objects, optionally prefix keys
4156
        // that would overwrite object prototype properties
4157
        if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
4158
            if (!options.allowPrototypes) {
4159
                return;
4160
            }
4161
        }
4162
4163
        keys.push(segment[1]);
4164
    }
4165
4166
    // Loop through children appending to the array until we hit depth
4167
4168
    var i = 0;
4169
    while ((segment = child.exec(key)) !== null && i < options.depth) {
4170
        i += 1;
4171
        if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) {
4172
            if (!options.allowPrototypes) {
4173
                continue;
4174
            }
4175
        }
4176
        keys.push(segment[1]);
4177
    }
4178
4179
    // If there's a remainder, just add whatever is left
4180
4181
    if (segment) {
4182
        keys.push('[' + key.slice(segment.index) + ']');
4183
    }
4184
4185
    return parseObject(keys, val, options);
4186
};
4187
4188
module.exports = function (str, opts) {
4189
    var options = opts || {};
4190
4191
    if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
4192
        throw new TypeError('Decoder has to be a function.');
4193
    }
4194
4195
    options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
4196
    options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
4197
    options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
4198
    options.parseArrays = options.parseArrays !== false;
4199
    options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
4200
    options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
4201
    options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
4202
    options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
4203
    options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
4204
    options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
4205
4206
    if (str === '' || str === null || typeof str === 'undefined') {
4207
        return options.plainObjects ? Object.create(null) : {};
4208
    }
4209
4210
    var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
4211
    var obj = options.plainObjects ? Object.create(null) : {};
4212
4213
    // Iterate over the keys and setup the new object
4214
4215
    var keys = Object.keys(tempObj);
4216
    for (var i = 0; i < keys.length; ++i) {
4217
        var key = keys[i];
4218
        var newObj = parseKeys(key, tempObj[key], options);
4219
        obj = utils.merge(obj, newObj, options);
4220
    }
4221
4222
    return utils.compact(obj);
4223
};
4224
4225 View Code Duplication
},{"./utils":16}],15:[function(require,module,exports){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4226
'use strict';
4227
4228
var utils = require('./utils');
4229
var formats = require('./formats');
4230
4231
var arrayPrefixGenerators = {
4232
    brackets: function brackets(prefix) {
4233
        return prefix + '[]';
4234
    },
4235
    indices: function indices(prefix, key) {
4236
        return prefix + '[' + key + ']';
4237
    },
4238
    repeat: function repeat(prefix) {
4239
        return prefix;
4240
    }
4241
};
4242
4243
var toISO = Date.prototype.toISOString;
4244
4245
var defaults = {
4246
    delimiter: '&',
4247
    encode: true,
4248
    encoder: utils.encode,
4249
    serializeDate: function serializeDate(date) {
4250
        return toISO.call(date);
4251
    },
4252
    skipNulls: false,
4253
    strictNullHandling: false
4254
};
4255
4256
var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable stringify already seems to be declared on line 4256. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
4257
    var obj = object;
4258
    if (typeof filter === 'function') {
4259
        obj = filter(prefix, obj);
4260
    } else if (obj instanceof Date) {
4261
        obj = serializeDate(obj);
4262
    } else if (obj === null) {
4263
        if (strictNullHandling) {
4264
            return encoder ? encoder(prefix) : prefix;
4265
        }
4266
4267
        obj = '';
4268
    }
4269
4270
    if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
4271
        if (encoder) {
4272
            return [formatter(encoder(prefix)) + '=' + formatter(encoder(obj))];
4273
        }
4274
        return [formatter(prefix) + '=' + formatter(String(obj))];
4275
    }
4276
4277
    var values = [];
4278
4279
    if (typeof obj === 'undefined') {
4280
        return values;
4281
    }
4282
4283
    var objKeys;
4284
    if (Array.isArray(filter)) {
4285
        objKeys = filter;
4286
    } else {
4287
        var keys = Object.keys(obj);
4288
        objKeys = sort ? keys.sort(sort) : keys;
4289
    }
4290
4291
    for (var i = 0; i < objKeys.length; ++i) {
4292
        var key = objKeys[i];
4293
4294
        if (skipNulls && obj[key] === null) {
4295
            continue;
4296
        }
4297
4298
        if (Array.isArray(obj)) {
4299
            values = values.concat(stringify(
4300
                obj[key],
4301
                generateArrayPrefix(prefix, key),
4302
                generateArrayPrefix,
4303
                strictNullHandling,
4304
                skipNulls,
4305
                encoder,
4306
                filter,
4307
                sort,
4308
                allowDots,
4309
                serializeDate,
4310
                formatter
4311
            ));
4312
        } else {
4313
            values = values.concat(stringify(
4314
                obj[key],
4315
                prefix + (allowDots ? '.' + key : '[' + key + ']'),
4316
                generateArrayPrefix,
4317
                strictNullHandling,
4318
                skipNulls,
4319
                encoder,
4320
                filter,
4321
                sort,
4322
                allowDots,
4323
                serializeDate,
4324
                formatter
4325
            ));
4326
        }
4327
    }
4328
4329
    return values;
4330
};
4331
4332
module.exports = function (object, opts) {
4333
    var obj = object;
4334
    var options = opts || {};
4335
    var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
4336
    var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
4337
    var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
4338
    var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
4339
    var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null;
4340
    var sort = typeof options.sort === 'function' ? options.sort : null;
4341
    var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
4342
    var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
4343
    if (typeof options.format === 'undefined') {
4344
        options.format = formats.default;
4345
    } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
4346
        throw new TypeError('Unknown format option provided.');
4347
    }
4348
    var formatter = formats.formatters[options.format];
4349
    var objKeys;
4350
    var filter;
4351
4352
    if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
4353
        throw new TypeError('Encoder has to be a function.');
4354
    }
4355
4356
    if (typeof options.filter === 'function') {
4357
        filter = options.filter;
4358
        obj = filter('', obj);
4359
    } else if (Array.isArray(options.filter)) {
4360
        filter = options.filter;
4361
        objKeys = filter;
4362
    }
4363
4364
    var keys = [];
4365
4366
    if (typeof obj !== 'object' || obj === null) {
4367
        return '';
4368
    }
4369
4370
    var arrayFormat;
4371
    if (options.arrayFormat in arrayPrefixGenerators) {
4372
        arrayFormat = options.arrayFormat;
4373
    } else if ('indices' in options) {
4374
        arrayFormat = options.indices ? 'indices' : 'repeat';
4375
    } else {
4376
        arrayFormat = 'indices';
4377
    }
4378
4379
    var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
4380
4381
    if (!objKeys) {
4382
        objKeys = Object.keys(obj);
4383
    }
4384
4385
    if (sort) {
4386
        objKeys.sort(sort);
4387
    }
4388
4389
    for (var i = 0; i < objKeys.length; ++i) {
4390
        var key = objKeys[i];
4391
4392
        if (skipNulls && obj[key] === null) {
4393
            continue;
4394
        }
4395
4396
        keys = keys.concat(stringify(
4397
            obj[key],
4398
            key,
4399
            generateArrayPrefix,
4400
            strictNullHandling,
4401
            skipNulls,
4402
            encoder,
4403
            filter,
0 ignored issues
show
Bug introduced by
The variable filter does not seem to be initialized in case Array.isArray(options.filter) on line 4359 is false. Are you sure the function stringify handles undefined variables?
Loading history...
4404
            sort,
4405
            allowDots,
4406
            serializeDate,
4407
            formatter
4408
        ));
4409
    }
4410
4411
    return keys.join(delimiter);
4412
};
4413
4414
},{"./formats":12,"./utils":16}],16:[function(require,module,exports){
4415
'use strict';
4416
4417
var has = Object.prototype.hasOwnProperty;
4418
4419
var hexTable = (function () {
4420
    var array = [];
4421
    for (var i = 0; i < 256; ++i) {
4422
        array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
4423
    }
4424
4425
    return array;
4426
}());
4427
4428
exports.arrayToObject = function (source, options) {
4429
    var obj = options && options.plainObjects ? Object.create(null) : {};
4430
    for (var i = 0; i < source.length; ++i) {
4431
        if (typeof source[i] !== 'undefined') {
4432
            obj[i] = source[i];
4433
        }
4434
    }
4435
4436
    return obj;
4437
};
4438
4439
exports.merge = function (target, source, options) {
4440
    if (!source) {
4441
        return target;
4442
    }
4443
4444
    if (typeof source !== 'object') {
4445
        if (Array.isArray(target)) {
4446
            target.push(source);
4447
        } else if (typeof target === 'object') {
4448
            target[source] = true;
4449
        } else {
4450
            return [target, source];
4451
        }
4452
4453
        return target;
4454
    }
4455
4456
    if (typeof target !== 'object') {
4457
        return [target].concat(source);
4458
    }
4459
4460
    var mergeTarget = target;
4461
    if (Array.isArray(target) && !Array.isArray(source)) {
4462
        mergeTarget = exports.arrayToObject(target, options);
4463
    }
4464
4465
    if (Array.isArray(target) && Array.isArray(source)) {
4466
        source.forEach(function (item, i) {
4467
            if (has.call(target, i)) {
4468
                if (target[i] && typeof target[i] === 'object') {
4469
                    target[i] = exports.merge(target[i], item, options);
4470
                } else {
4471
                    target.push(item);
4472
                }
4473
            } else {
4474
                target[i] = item;
4475
            }
4476
        });
4477
        return target;
4478
    }
4479
4480
    return Object.keys(source).reduce(function (acc, key) {
4481
        var value = source[key];
4482
4483
        if (Object.prototype.hasOwnProperty.call(acc, key)) {
4484
            acc[key] = exports.merge(acc[key], value, options);
4485
        } else {
4486
            acc[key] = value;
4487
        }
4488
        return acc;
4489
    }, mergeTarget);
4490
};
4491
4492
exports.decode = function (str) {
4493
    try {
4494
        return decodeURIComponent(str.replace(/\+/g, ' '));
4495
    } catch (e) {
4496
        return str;
4497
    }
4498
};
4499
4500
exports.encode = function (str) {
4501
    // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
4502
    // It has been adapted here for stricter adherence to RFC 3986
4503
    if (str.length === 0) {
4504
        return str;
4505
    }
4506
4507
    var string = typeof str === 'string' ? str : String(str);
4508
4509
    var out = '';
4510
    for (var i = 0; i < string.length; ++i) {
4511
        var c = string.charCodeAt(i);
4512
4513
        if (
4514
            c === 0x2D || // -
4515
            c === 0x2E || // .
4516
            c === 0x5F || // _
4517
            c === 0x7E || // ~
4518
            (c >= 0x30 && c <= 0x39) || // 0-9
4519
            (c >= 0x41 && c <= 0x5A) || // a-z
4520
            (c >= 0x61 && c <= 0x7A) // A-Z
4521
        ) {
4522
            out += string.charAt(i);
4523
            continue;
4524
        }
4525
4526
        if (c < 0x80) {
4527
            out = out + hexTable[c];
4528
            continue;
4529
        }
4530
4531
        if (c < 0x800) {
4532
            out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
4533
            continue;
4534
        }
4535
4536
        if (c < 0xD800 || c >= 0xE000) {
4537
            out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
4538
            continue;
4539
        }
4540
4541
        i += 1;
4542
        c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
4543
        out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)];
4544
    }
4545
4546
    return out;
4547
};
4548
4549
exports.compact = function (obj, references) {
4550
    if (typeof obj !== 'object' || obj === null) {
4551
        return obj;
4552
    }
4553
4554
    var refs = references || [];
4555
    var lookup = refs.indexOf(obj);
4556
    if (lookup !== -1) {
4557
        return refs[lookup];
4558
    }
4559
4560
    refs.push(obj);
4561
4562
    if (Array.isArray(obj)) {
4563
        var compacted = [];
4564
4565
        for (var i = 0; i < obj.length; ++i) {
4566
            if (obj[i] && typeof obj[i] === 'object') {
4567
                compacted.push(exports.compact(obj[i], refs));
4568
            } else if (typeof obj[i] !== 'undefined') {
4569
                compacted.push(obj[i]);
4570
            }
4571
        }
4572
4573
        return compacted;
4574
    }
4575
4576
    var keys = Object.keys(obj);
4577
    keys.forEach(function (key) {
4578
        obj[key] = exports.compact(obj[key], refs);
4579
    });
4580
4581
    return obj;
4582
};
4583
4584
exports.isRegExp = function (obj) {
4585
    return Object.prototype.toString.call(obj) === '[object RegExp]';
4586
};
4587
4588
exports.isBuffer = function (obj) {
4589
    if (obj === null || typeof obj === 'undefined') {
4590
        return false;
4591
    }
4592
4593
    return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
4594
};
4595
4596
},{}],17:[function(require,module,exports){
0 ignored issues
show
Unused Code introduced by
The parameter exports is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter module is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
4597
'use strict';
4598
4599
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /*global document */
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4600
4601
var _FormCreate = require('./modules/FormCreate');
4602
4603
var _FormCreate2 = _interopRequireDefault(_FormCreate);
4604
4605
var _FormList = require('./modules/FormList');
4606
4607
var _FormList2 = _interopRequireDefault(_FormList);
4608
4609
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4610
4611
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4612
4613
var Admin = function () {
4614
  function Admin() {
4615
    _classCallCheck(this, Admin);
4616
4617
    this._page = document.querySelector('body').getAttribute('data-page');
4618
    // this._formCreate = document.querySelector('.form-create')
4619
    var forms = document.querySelectorAll('[data-form-abe-create]');
4620
    Array.prototype.forEach.call(forms, function (form) {
4621
      new _FormCreate2.default(form);
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new _FormCreate2.default(form) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
4622
    });
4623
4624
    this._bindEvents();
4625
  }
4626
4627
  /**
4628
   * _bindEvents for admin pages
4629
   * @return {null}
4630
   */
4631
4632
4633
  _createClass(Admin, [{
4634
    key: '_bindEvents',
4635
    value: function _bindEvents() {
4636
      if (typeof this._formCreate !== 'undefined' && this._formCreate !== null) {} else if (this._page === 'list') {
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
4637
        new _FormList2.default();
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new _FormList2.default() is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
4638
      }
4639
    }
4640
  }]);
4641
4642
  return Admin;
4643
}();
4644
4645
new Admin();
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new Admin() is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
4646
4647
},{"./modules/FormCreate":19,"./modules/FormList":20}],18:[function(require,module,exports){
4648
'use strict';
4649
4650
Object.defineProperty(exports, "__esModule", {
4651
  value: true
4652
});
4653
4654
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4655
4656
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4657
4658
var FolderSelect = function () {
4659
  function FolderSelect(form) {
4660
    _classCallCheck(this, FolderSelect);
4661
4662
    this._form = form;
4663
    // constante variable
4664
    this._selectTemplate = this._form.querySelector('#selectTemplate');
4665
    this._selectsWebsite = this._form.querySelector('#level-1');
4666
    this._selectsCreate = [].slice.call(this._form.querySelectorAll('select[id*="level-"]'));
4667
4668
    // constante methode
4669
    this._handleChangeSelectsCreate = this._changeSelectsCreate.bind(this);
4670
4671
    this._bindEvents();
4672
  }
4673
4674
  _createClass(FolderSelect, [{
4675
    key: '_bindEvents',
4676
    value: function _bindEvents() {
4677
      var _this = this;
4678
4679
      this._selectsCreate.forEach(function (select) {
4680
        select.addEventListener('change', _this._handleChangeSelectsCreate);
4681
      });
4682
    }
4683
4684
    /**
4685
     * bind event for select page create
4686
     * @param  {[type]} e [description]
4687
     * @return {[type]}   [description]
4688
     */
4689
4690
  }, {
4691
    key: '_changeSelectsCreate',
4692
    value: function _changeSelectsCreate(e) {
4693
      var selectedOption = e.currentTarget.querySelector('option:checked');
4694
4695
      var dataShow = selectedOption.getAttribute('data-show'),
4696
          levelShow = selectedOption.getAttribute('data-level-show'),
4697
          levelHide = selectedOption.getAttribute('data-level-hide');
4698
4699
      if (typeof levelShow !== 'undefined' && levelShow !== null && levelShow !== '') {
4700
        this._showSubLevels(levelShow, dataShow);
4701
      }
4702
      if (typeof levelHide !== 'undefined' && levelHide !== null && levelHide !== '') {
4703
        this._hideSubLevels(levelHide);
4704
      }
4705
    }
4706
  }, {
4707
    key: '_hideSubLevels',
4708
    value: function _hideSubLevels(i) {
4709
      var levels = [].slice.call(this._form.querySelectorAll('.level-' + i));
4710
      while (levels.length > 0) {
4711
        levels.forEach(function (level) {
4712
          var options = [].slice.call(level.querySelectorAll('option'));
4713
          Array.prototype.forEach.call(options, function (option) {
4714
            option.selected = null;
4715
            option.removeAttribute('selected');
4716
          });
4717
          level.classList.add('hidden');
4718
        });
4719
        levels = [].slice.call(this._form.querySelectorAll('.level-' + i++));
4720
      }
4721
    }
4722
  }, {
4723
    key: '_showSubLevels',
4724
    value: function _showSubLevels(i, dataShow) {
4725
      var _this2 = this;
4726
4727
      var levels = [].slice.call(this._form.querySelectorAll('.level-' + i));
4728
      levels.forEach(function (level) {
4729
        level.classList.add('hidden');
4730
4731
        var childs = [].slice.call(_this2._form.querySelectorAll('[data-shown=' + dataShow + ']'));
4732
        if (childs) {
4733
          childs.forEach(function (child) {
4734
            var options = [].slice.call(child.querySelectorAll('option'));
4735
            Array.prototype.forEach.call(options, function (option) {
4736
              option.selected = null;
4737
              option.removeAttribute('selected');
4738
            });
4739
4740
            child.classList.remove('hidden');
4741
          });
4742
        }
4743
      });
4744
    }
4745
  }]);
4746
4747
  return FolderSelect;
4748
}();
4749
4750
exports.default = FolderSelect;
4751
4752
},{}],19:[function(require,module,exports){
4753
'use strict';
4754
4755
Object.defineProperty(exports, "__esModule", {
4756
  value: true
4757
});
4758
4759
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /*global document, window, alert, slugs, CONFIG */
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4760
4761
var _limax = require('limax');
4762
4763
var _limax2 = _interopRequireDefault(_limax);
4764
4765
var _nanoajax = require('nanoajax');
4766
4767
var _nanoajax2 = _interopRequireDefault(_nanoajax);
4768
4769
var _qs = require('qs');
4770
4771
var _qs2 = _interopRequireDefault(_qs);
4772
4773
var _FolderSelect = require('./FolderSelect');
4774
4775
var _FolderSelect2 = _interopRequireDefault(_FolderSelect);
4776
4777
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4778
4779
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4780
4781
var FormCreate = function () {
4782
  function FormCreate(parentForm) {
4783
    _classCallCheck(this, FormCreate);
4784
4785
    this._form = parentForm;
4786
    if (typeof this._form !== 'undefined' && this._form !== null) {
4787
      this._isSaving = false;
4788
4789
      // constantes variables
4790
      this._ajax = _nanoajax2.default.ajax;
4791
4792
      // constantes variables DOM elements
4793
      this._previewPostPath = this._form.querySelector('[data-post-path-preview]');
4794
4795
      this._formInputs = [].slice.call(this._form.querySelectorAll('input, select'));
4796
      this._precontribTemplate = [].slice.call(this._form.querySelectorAll('[data-precontrib-templates]'));
4797
4798
      this._selectTemplate = this._form.querySelector('[data-id="selectTemplate"]');
4799
      this._showHideSelect(this._selectTemplate);
4800
      this._handleBtnSelectTemplate = this._btnSelectTemplate.bind(this);
4801
4802
      // // manager update btn
4803
      this._btnCreate = this._form.querySelector('[date-abe-create]');
4804
      this._btnUpdate = this._form.querySelector('[date-abe-update]');
4805
      this._btnDuplicate = this._form.querySelector('[date-abe-duplicate]');
4806
      this._handleBtnDuplicateManagerClick = this._btnDuplicateManagerClick.bind(this);
4807
      this._handleBtnUpdateManagerClick = this._btnUpdateManagerClick.bind(this);
4808
      this._handleBtnCreateManagerClick = this._btnCreateManagerClick.bind(this);
4809
      this._handleBlurEvent = this._blurEvent.bind(this);
4810
4811
      // // init modules
4812
      new _FolderSelect2.default(this._form);
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new _FolderSelect2.default(this._form) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
4813
4814
      this._bindEvents();
4815
4816
      this._setSlug(false);
4817
    }
4818
  }
4819
4820
  _createClass(FormCreate, [{
4821
    key: '_bindEvents',
4822
    value: function _bindEvents() {
4823
      if (typeof this._btnUpdate !== 'undefined' && this._btnUpdate !== null) {
4824
        this._btnUpdate.addEventListener('click', this._handleBtnUpdateManagerClick); // click update metadata
4825
      }
4826
      if (typeof this._btnCreate !== 'undefined' && this._btnCreate !== null) {
4827
        this._btnCreate.addEventListener('click', this._handleBtnCreateManagerClick); // click update metadata
4828
      }
4829
      if (typeof this._btnDuplicate !== 'undefined' && this._btnDuplicate !== null) {
4830
        this._btnDuplicate.addEventListener('click', this._handleBtnDuplicateManagerClick); // click duplicate content
4831
      }
4832
      if (typeof this._form !== 'undefined' && this._form !== null) {
4833
        this._form.addEventListener('submit', this._handleSubmit);
4834
      }
4835
      if (typeof this._selectTemplate !== 'undefined' && this._selectTemplate !== null) {
4836
        this._selectTemplate.addEventListener('change', this._handleBtnSelectTemplate);
4837
      }
4838
4839
      Array.prototype.forEach.call(this._formInputs, function (input) {
4840
        input.addEventListener('blur', this._handleBlurEvent);
4841
      }.bind(this));
4842
    }
4843
  }, {
4844
    key: '_blurEvent',
4845
    value: function _blurEvent() {
4846
      this._setSlug(false);
4847
    }
4848
  }, {
4849
    key: '_showHideSelect',
4850
    value: function _showHideSelect(target) {
4851
      this._selectedTemplate = target.value;
4852
      Array.prototype.forEach.call(this._precontribTemplate, function (input) {
4853
        var linkedTpl = input.getAttribute('data-precontrib-templates').split(',');
4854
        var found = false;
4855
        Array.prototype.forEach.call(linkedTpl, function (tpl) {
4856
          if (tpl === this._selectedTemplate) {
4857
            found = true;
4858
          }
4859
        }.bind(this));
4860
4861
        if (found) {
4862
          input.style.display = 'block';
4863
        } else {
4864
          input.style.display = 'none';
4865
        }
4866
      }.bind(this));
4867
    }
4868
  }, {
4869
    key: '_btnSelectTemplate',
4870
    value: function _btnSelectTemplate(e) {
4871
      this._showHideSelect(e.currentTarget);
4872
    }
4873
  }, {
4874
    key: '_setSlug',
4875
    value: function _setSlug(showErrors) {
4876
      var values = {};
4877
      var postPath = '';
4878
      var isValid = true;
4879
      if (this._selectedTemplate != null && this._selectedTemplate != '') {
4880
4881
        Array.prototype.forEach.call(this._formInputs, function (input) {
4882
          if (input.getAttribute('data-slug-type') == 'path') {
4883
            if (input.parentNode.classList.contains('hidden')) {
4884
              return;
4885
            }
4886
          }
4887
4888
          var parentNode = input.parentNode;
4889
          if (parentNode.getAttribute('data-precontrib-templates') == null) {
4890
            parentNode = input.parentNode.parentNode;
4891
          }
4892
          parentNode.classList.remove('has-error');
4893
          var linkedTpl = parentNode.getAttribute('data-precontrib-templates');
4894
          input.parentNode.classList.remove('error');
4895
          if (linkedTpl == null || linkedTpl == this._selectedTemplate) {
4896
            var id = input.getAttribute('data-id');
4897
            var autocomplete = input.getAttribute('data-autocomplete') == 'true' ? true : false;
4898
            var required = input.getAttribute('data-required') == 'true' ? true : false;
4899
            var value = input.value;
4900
4901
            if (autocomplete) {
4902
              var results = input.parentNode.querySelectorAll('.autocomplete-result');
4903
              values[id] = [];
4904
              Array.prototype.forEach.call(results, function (result) {
4905
                var resultValue = result.getAttribute('value');
4906
                if (resultValue.indexOf('{') > -1) {
4907
                  try {
4908
                    var jsonValue = JSON.parse(resultValue);
4909
                    values[id].push(jsonValue);
4910
                  } catch (e) {
4911
                    // values[id].push(value)
4912
                  }
4913
                }
4914
              }.bind(this));
0 ignored issues
show
unused-code introduced by
The call to bind does not seem necessary since the function does not use this. Consider calling it directly.
Loading history...
4915
              if (required && values[id].length == 0) {
4916
                isValid = false;
4917
                if (showErrors) parentNode.classList.add('has-error');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4918
              }
4919
            } else {
4920
              if (value.indexOf('{') > -1) {
4921
                try {
4922
                  var jsonValue = JSON.parse(value);
4923
                  values[id] = [jsonValue];
4924
4925
                  if (required && values[id].length == 0) {
4926
                    isValid = false;
4927
                    if (showErrors) parentNode.classList.add('has-error');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4928
                  }
4929
                } catch (e) {
4930
                  // values[id].push(value)
4931
                }
4932
              } else {
4933
                values[id] = value;
4934
                if (required && values[id] == '') {
4935
                  isValid = false;
4936
                  if (showErrors) parentNode.classList.add('has-error');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
4937
                }
4938
              }
4939
            }
4940
          }
4941
        }.bind(this));
4942
4943
        var slug = slugs[this._selectedTemplate];
4944
        var slugMatches = slug.match(/{{.*?}}/g);
4945
        if (slugMatches !== null) {
4946
          Array.prototype.forEach.call(slugMatches, function (slugMatch) {
4947
            var cleanSlugMath = slugMatch.replace('{{', '').replace('}}', '');
4948
            try {
4949
              var valueSlug = eval('values.' + cleanSlugMath) + '';
0 ignored issues
show
Security Performance introduced by
Calls to eval are slow and potentially dangerous, especially on untrusted code. Please consider whether there is another way to achieve your goal.
Loading history...
4950
              valueSlug = (0, _limax2.default)(valueSlug, { separateNumbers: false });
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
4951
              slug = slug.replace(slugMatch, valueSlug);
4952
            } catch (e) {
4953
              slug = slug.replace(slugMatch, '');
4954
              isValid = false;
4955
              // console.error('error on create', e.stack)
4956
            }
4957
          }.bind(this));
0 ignored issues
show
unused-code introduced by
The call to bind does not seem necessary since the function does not use this. Consider calling it directly.
Loading history...
4958
        }
4959
4960
        var slugPaths = this._form.querySelectorAll('[data-slug-type=path]');
4961
        Array.prototype.forEach.call(slugPaths, function (slugPath) {
4962
          var isStructureFolder = slugPath.parentNode.getAttribute('data-shown') != null;
4963
          if (slugPath.value != null && slugPath.value != '' && isStructureFolder && !slugPath.parentNode.classList.contains('hidden')) {
4964
            postPath += slugPath.value + '/';
4965
          }
4966
        });
4967
        postPath += slug.replace(/^\//, '');
4968
      } else {
4969
        isValid = false;
4970
      }
4971
4972
      var breadcrumbs = postPath.split('/');
4973
      var breadcrumbsHtml = '';
4974
      Array.prototype.forEach.call(breadcrumbs, function (breadcrumb) {
4975
        var breadcrumbNames = breadcrumb.split('-');
4976
        breadcrumbsHtml += '<li>';
4977
        Array.prototype.forEach.call(breadcrumbNames, function (breadcrumbName) {
4978
          if (breadcrumbName == '' && showErrors) {
4979
            breadcrumbsHtml += '<span class="btn-danger">...</span>-';
4980
          } else {
4981
            breadcrumbsHtml += '<span>' + breadcrumbName + '</span>-';
4982
          }
4983
        }.bind(this));
0 ignored issues
show
unused-code introduced by
The call to bind does not seem necessary since the function does not use this. Consider calling it directly.
Loading history...
4984
        breadcrumbsHtml = breadcrumbsHtml.replace(/-$/, '');
4985
        breadcrumbsHtml += '</li>';
4986
      });
4987
      breadcrumbsHtml += '<span>.' + CONFIG.EXTENSION + '</span>';
4988
      this._previewPostPath.innerHTML = '<span>URL : </span>' + breadcrumbsHtml;
4989
4990
      return {
4991
        isValid: isValid,
4992
        postPath: postPath,
4993
        values: values
4994
      };
4995
    }
4996
  }, {
4997
    key: '_submit',
4998
    value: function _submit(type) {
4999
      var _this = this;
5000
5001
      var res = this._setSlug(true);
5002
      var toSave = _qs2.default.stringify(res.values);
5003
5004
      if (res.isValid && !this._isSaving) {
5005
        this._isSaving = true;
5006
        this._ajax({
5007
          url: document.location.origin + '/abe/' + type + '/' + res.postPath,
5008
          body: toSave,
5009
          headers: {},
5010
          method: 'post'
5011
        }, function (code, responseText) {
5012
          _this._isSaving = false;
5013
          var jsonRes = JSON.parse(responseText);
5014
          if (jsonRes.success == 1 && jsonRes.json != null && jsonRes.json.abe_meta != null) {
5015
            window.location.href = window.location.origin + '/abe/editor' + jsonRes.json.abe_meta.link;
5016
          } else {
5017
            console.log(responseText);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
5018
            alert('error');
5019
          }
5020
        });
5021
      }
5022
    }
5023
  }, {
5024
    key: '_btnDuplicateManagerClick',
5025
    value: function _btnDuplicateManagerClick(e) {
5026
      e.preventDefault();
5027
      this._submit('duplicate');
5028
    }
5029
  }, {
5030
    key: '_btnUpdateManagerClick',
5031
    value: function _btnUpdateManagerClick(e) {
5032
      e.preventDefault();
5033
      this._submit('update');
5034
    }
5035
  }, {
5036
    key: '_btnCreateManagerClick',
5037
    value: function _btnCreateManagerClick(e) {
5038
      e.preventDefault();
5039
      this._submit('create');
5040
    }
5041
  }]);
5042
5043
  return FormCreate;
5044
}();
5045
5046
exports.default = FormCreate;
5047
5048
},{"./FolderSelect":18,"limax":2,"nanoajax":11,"qs":13}],20:[function(require,module,exports){
5049
'use strict';
5050
5051
Object.defineProperty(exports, "__esModule", {
5052
  value: true
5053
});
5054
5055
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
5056
5057
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5058
5059
/*global document, $, top */
5060
5061
var FormList = function () {
5062
  function FormList() {
5063
    var _this = this;
5064
5065
    _classCallCheck(this, FormList);
5066
5067
    // bind button event click
5068
    this._btnValidates = [].slice.call(document.querySelectorAll('[data-validate-content]'));
5069
    this._handleBtnValidatesClick = this._btnValidatesClick.bind(this);
5070
5071
    this._btnValidates.forEach(function (input) {
5072
      input.addEventListener('click', _this._handleBtnValidatesClick);
5073
    });
5074
5075
    // bind button event click
5076
    this._btnSetRevisions = [].slice.call(document.querySelectorAll('[data-revisions]'));
5077
5078
    this._btnSetRevisions.forEach(function (input) {
5079
      input.addEventListener('click', _this._handleBtnValidatesClick);
5080
    });
5081
  }
5082
5083
  _createClass(FormList, [{
5084
    key: '_btnValidatesClick',
5085
    value: function _btnValidatesClick(e) {
5086
      var tplPath = e.currentTarget.getAttribute('data-template-path');
5087
      var filePath = e.currentTarget.getAttribute('data-file-path');
5088
      var type = e.currentTarget.getAttribute('data-type');
5089
5090
      var data = {
5091
        tplPath: tplPath,
5092
        filePath: filePath,
5093
        saveAction: type
5094
      };
5095
5096
      $.ajax({
5097
        url: document.location.origin + '/save',
5098
        data: data
5099
      }).done(function () {
5100
        top.location.href = top.location.href;
5101
      });
5102
    }
5103
  }]);
5104
5105
  return FormList;
5106
}();
5107
5108
exports.default = FormList;
5109
5110
},{}]},{},[17]);
5111