jekyll-theme-mdui 0.5.2.4 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -21
  3. data/README.md +88 -89
  4. data/_includes/analytics/google.html +7 -7
  5. data/_includes/comment/comment.html +2 -2
  6. data/_includes/comment/disqus.html +72 -75
  7. data/_includes/comment/gitment.html +16 -16
  8. data/_includes/comment/livere.html +42 -26
  9. data/_includes/comment/valine.html +37 -18
  10. data/_includes/component/customCssJS.html +7 -7
  11. data/_includes/component/nprogress.html +24 -24
  12. data/_includes/component/sw.html +6 -6
  13. data/_includes/component/totop.html +13 -13
  14. data/_includes/content/category_list.html +86 -86
  15. data/_includes/content/category_post_list.html +108 -100
  16. data/_includes/content/component/highlight.html +11 -11
  17. data/_includes/content/component/imgboxed.html +304 -304
  18. data/_includes/content/component/lastupdate.html +35 -35
  19. data/_includes/content/component/lazyload.html +6 -6
  20. data/_includes/content/component/page_tags.html +17 -17
  21. data/_includes/content/component/qrcode.html +26 -26
  22. data/_includes/content/component/readtime.html +27 -27
  23. data/_includes/content/component/sns_share.html +42 -42
  24. data/_includes/content/component/toc.html +84 -84
  25. data/_includes/content/editor.html +1058 -1058
  26. data/_includes/content/friends.html +23 -23
  27. data/_includes/content/love.html +123 -0
  28. data/_includes/content/page_content.html +92 -87
  29. data/_includes/content/page_content_no_toc.html +69 -64
  30. data/_includes/content/paginator_button.html +24 -24
  31. data/_includes/content/paginator_post_list.html +103 -95
  32. data/_includes/content/tags_list.html +99 -99
  33. data/_includes/footer/footer.html +30 -30
  34. data/_includes/head.html +90 -87
  35. data/_includes/header/header.html +174 -174
  36. data/_includes/meng/aplayer.html +100 -100
  37. data/_includes/meng/background.html +34 -34
  38. data/_includes/meng/card.html +13 -13
  39. data/_includes/meng/console.html +10 -10
  40. data/_includes/meng/cplayer.html +61 -61
  41. data/_includes/meng/cursor.html +8 -8
  42. data/_includes/meng/head_card.html +67 -67
  43. data/_includes/meng/live2d.html +60 -60
  44. data/_includes/meng/title.html +23 -23
  45. data/_includes/submission/baidu.html +13 -13
  46. data/_layouts/category_content.html +3 -3
  47. data/_layouts/category_list.html +3 -3
  48. data/_layouts/compress.html +9 -9
  49. data/_layouts/default.html +49 -49
  50. data/_layouts/editor.html +4 -4
  51. data/_layouts/friends.html +3 -3
  52. data/_layouts/home.html +20 -20
  53. data/_layouts/love.html +4 -0
  54. data/_layouts/page.html +12 -12
  55. data/_layouts/post.html +12 -12
  56. data/_layouts/tags.html +4 -4
  57. data/assets/css/global.css +181 -181
  58. metadata +7 -6
@@ -1,1059 +1,1059 @@
1
- {% if site.data.site.lang == null or site.data.site.lang == "" %}
2
- {% assign lang = site.data.lang.en-US %}
3
- {% else %}
4
- {% assign lang = site.data.lang[site.data.site.lang] %}
5
- {% endif %}
6
- {% capture categories %}
7
- {% for c in site.categories %}
8
- {{c[0]}}
9
- {% endfor %}
10
- {% endcapture %}
11
- {% assign sortedcategories = categories | split:' ' | sort %}
12
- <style>
13
- .textarea-wrap{
14
- height: 100%;
15
- }
16
- #preview{
17
- max-width: 904px;
18
- }
19
- .k-post-media {
20
- display:block
21
- cursor: pointer;
22
- max-height: 245px;
23
- min-height: 245px;
24
- background-position: 50% 50%;
25
- background-size: cover;
26
- background-color: white;
27
- }
28
- .k-post-media .mdui-card-primary-title a {
29
- text-decoration: none;
30
- }
31
- </style>
32
- <div class="k-posts-list"></div>
33
- <div class="k-container">
34
- <div class="mdui-dialog" id="frontMatter">
35
- <div class="mdui-dialog-content">
36
- <div class="mdui-dialog-title">{{lang.editor.frontmatter.name}}</div>
37
- <h3>{{lang.editor.frontmatter.title}}</h3>
38
- <div class="mdui-textfield">
39
- <input id="editorTitle" class="mdui-textfield-input" type="text"/>
40
- </div>
41
- <h3>{{lang.editor.frontmatter.date}}</h3>
42
- <div class="mdui-textfield">
43
- <input id="editorDate" class="mdui-textfield-input datepicker" type="date"/>
44
- </div>
45
- <h3>{{lang.editor.frontmatter.categories}}</h3>
46
- <div class="mdui-row-md-4 mdui-row-sm-3">
47
- {% for c in sortedcategories %}
48
- <div class="mdui-col">
49
- <label class="mdui-radio">
50
- <input type="radio" value="{{c}}" name="categories">
51
- <i class="mdui-radio-icon"></i>
52
- {{c}}
53
- </label>
54
- </div>
55
- {% endfor %}
56
- <div class="mdui-col">
57
- <label id="radio_custom" class="mdui-radio mdui-float-left">
58
- <input type="radio" value="radio_custom" name="categories">
59
- <i class="mdui-radio-icon"></i>
60
- </label>
61
- <div style="padding-top: 0px;" class="mdui-textfield">
62
- <input id="editorCategories" class="mdui-textfield-input" name="radio_custom" type="text" placeholder="categories">
63
- </div>
64
- </div>
65
- </div>
66
- <h3>{{lang.editor.frontmatter.tags}}</h3>
67
- <div class="chips chips-initial"></div>
68
- <h3>{{lang.editor.frontmatter.image}}</h3>
69
- <div class="mdui-textfield">
70
- <input id="imgurl" class="mdui-textfield-input" type="text" placeholder="imgUrl">
71
- </div>
72
- </div>
73
- </div>
74
-
75
- <div class="mdui-dialog" id="preview">
76
- <div class="mdui-dialog-content">
77
- <div class="mdui-dialog-title">{{lang.editor.preview}}</div>
78
- <div class="mdui-card k-postcontent">
79
- <div class="mdui-card-media k-post-media">
80
- <div class="mdui-card-media-covered mdui-card-media-covered-gradient">
81
- <div class="mdui-card-primary">
82
- <div class="mdui-card-primary-title">
83
-
84
- </div>
85
- </div>
86
- </div>
87
- </div>
88
- <div class="mdui-card-header">
89
- <img class="mdui-card-header-avatar" src="{{site.data.site.img.avatar}}">
90
- <div class="mdui-card-header-title">{{site.author}}</div>
91
- <div class="mdui-card-header-subtitle k-data"></div>
92
- </div>
93
- <div class="mdui-card-content mdui-typo" id="previewContent"></div>
94
- </div>
95
- </div>
96
- </div>
97
-
98
- <div class="mdui-card">
99
- <div class="mdui-card-content">
100
- <h3>{{lang.editor.content}}</h3>
101
- <div class="mdui-textfield">
102
- <textarea id="editorContent" class="mdui-textfield-input" placeholder="Description"></textarea>
103
- </div>
104
- </div>
105
- <div class="mdui-card-actions">
106
- <a class="mdui-btn mdui-ripple" mdui-dialog="{target: '#frontMatter'}">{{lang.editor.frontmatter.name}}</a>
107
- <a id="previewBtn" class="mdui-btn mdui-ripple" mdui-dialog="{target: '#preview'}">{{lang.editor.preview}}</a>
108
- <a id="download" class="mdui-btn mdui-ripple mdui-float-right">{{lang.editor.download}}</a>
109
- </div>
110
- </div>
111
- </div>
112
-
113
- <!--marked-->
114
- <script>
115
- (function () {
116
- var block = {
117
- newline: /^\n+/,
118
- code: /^( {4}[^\n]+\n*)+/,
119
- fences: noop,
120
- hr: /^( *[-*_]){3,} *(?:\n+|$)/,
121
- heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
122
- nptable: noop,
123
- lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
124
- blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
125
- list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
126
- html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
127
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
128
- table: noop,
129
- paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
130
- text: /^[^\n]+/
131
- };
132
- block.bullet = /(?:[*+-]|\d+\.)/;
133
- block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
134
- block.item = replace(block.item, "gm")(/bull/g, block.bullet)();
135
- block.list = replace(block.list)(/bull/g, block.bullet)("hr", "\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def", "\\n+(?=" + block.def.source + ")")();
136
- block.blockquote = replace(block.blockquote)("def", block.def)();
137
- block._tag = "(?!(?:" + "a|em|strong|small|s|cite|q|dfn|abbr|data|time|code" + "|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo" + "|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";
138
- block.html = replace(block.html)("comment", /<!--[\s\S]*?-->/)("closed", /<(tag)[\s\S]+?<\/\1>/)("closing", /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g, block._tag)();
139
- block.paragraph = replace(block.paragraph)("hr", block.hr)("heading", block.heading)("lheading", block.lheading)("blockquote", block.blockquote)("tag", "<" + block._tag)("def", block.def)();
140
- block.normal = merge({}, block);
141
- block.gfm = merge({}, block.normal, {
142
- fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
143
- paragraph: /^/,
144
- heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
145
- });
146
- block.gfm.paragraph = replace(block.paragraph)("(?!", "(?!" + block.gfm.fences.source.replace("\\1", "\\2") + "|" + block.list.source.replace("\\1", "\\3") + "|")();
147
- block.tables = merge({}, block.gfm, {
148
- nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
149
- table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
150
- });
151
-
152
- function Lexer(options) {
153
- this.tokens = [];
154
- this.tokens.links = {};
155
- this.options = options || marked.defaults;
156
- this.rules = block.normal;
157
- if (this.options.gfm) {
158
- if (this.options.tables) {
159
- this.rules = block.tables
160
- } else {
161
- this.rules = block.gfm
162
- }
163
- }
164
- }
165
- Lexer.rules = block;
166
- Lexer.lex = function (src, options) {
167
- var lexer = new Lexer(options);
168
- return lexer.lex(src)
169
- };
170
- Lexer.prototype.lex = function (src) {
171
- src = src.replace(/\r\n|\r/g, "\n").replace(/\t/g, " ").replace(/\u00a0/g, " ").replace(/\u2424/g, "\n");
172
- return this.token(src, true)
173
- };
174
- Lexer.prototype.token = function (src, top, bq) {
175
- var src = src.replace(/^ +$/gm, ""),
176
- next, loose, cap, bull, b, item, space, i, l;
177
- while (src) {
178
- if (cap = this.rules.newline.exec(src)) {
179
- src = src.substring(cap[0].length);
180
- if (cap[0].length > 1) {
181
- this.tokens.push({
182
- type: "space"
183
- })
184
- }
185
- }
186
- if (cap = this.rules.code.exec(src)) {
187
- src = src.substring(cap[0].length);
188
- cap = cap[0].replace(/^ {4}/gm, "");
189
- this.tokens.push({
190
- type: "code",
191
- text: !this.options.pedantic ? cap.replace(/\n+$/, "") : cap
192
- });
193
- continue
194
- }
195
- if (cap = this.rules.fences.exec(src)) {
196
- src = src.substring(cap[0].length);
197
- this.tokens.push({
198
- type: "code",
199
- lang: cap[2],
200
- text: cap[3] || ""
201
- });
202
- continue
203
- }
204
- if (cap = this.rules.heading.exec(src)) {
205
- src = src.substring(cap[0].length);
206
- this.tokens.push({
207
- type: "heading",
208
- depth: cap[1].length,
209
- text: cap[2]
210
- });
211
- continue
212
- }
213
- if (top && (cap = this.rules.nptable.exec(src))) {
214
- src = src.substring(cap[0].length);
215
- item = {
216
- type: "table",
217
- header: cap[1].replace(/^ *| *\| *$/g, "").split(/ *\| */),
218
- align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
219
- cells: cap[3].replace(/\n$/, "").split("\n")
220
- };
221
- for (i = 0; i < item.align.length; i++) {
222
- if (/^ *-+: *$/.test(item.align[i])) {
223
- item.align[i] = "right"
224
- } else {
225
- if (/^ *:-+: *$/.test(item.align[i])) {
226
- item.align[i] = "center"
227
- } else {
228
- if (/^ *:-+ *$/.test(item.align[i])) {
229
- item.align[i] = "left"
230
- } else {
231
- item.align[i] = null
232
- }
233
- }
234
- }
235
- }
236
- for (i = 0; i < item.cells.length; i++) {
237
- item.cells[i] = item.cells[i].split(/ *\| */)
238
- }
239
- this.tokens.push(item);
240
- continue
241
- }
242
- if (cap = this.rules.lheading.exec(src)) {
243
- src = src.substring(cap[0].length);
244
- this.tokens.push({
245
- type: "heading",
246
- depth: cap[2] === "=" ? 1 : 2,
247
- text: cap[1]
248
- });
249
- continue
250
- }
251
- if (cap = this.rules.hr.exec(src)) {
252
- src = src.substring(cap[0].length);
253
- this.tokens.push({
254
- type: "hr"
255
- });
256
- continue
257
- }
258
- if (cap = this.rules.blockquote.exec(src)) {
259
- src = src.substring(cap[0].length);
260
- this.tokens.push({
261
- type: "blockquote_start"
262
- });
263
- cap = cap[0].replace(/^ *> ?/gm, "");
264
- this.token(cap, top, true);
265
- this.tokens.push({
266
- type: "blockquote_end"
267
- });
268
- continue
269
- }
270
- if (cap = this.rules.list.exec(src)) {
271
- src = src.substring(cap[0].length);
272
- bull = cap[2];
273
- this.tokens.push({
274
- type: "list_start",
275
- ordered: bull.length > 1
276
- });
277
- cap = cap[0].match(this.rules.item);
278
- next = false;
279
- l = cap.length;
280
- i = 0;
281
- for (; i < l; i++) {
282
- item = cap[i];
283
- space = item.length;
284
- item = item.replace(/^ *([*+-]|\d+\.) +/, "");
285
- if (~item.indexOf("\n ")) {
286
- space -= item.length;
287
- item = !this.options.pedantic ? item.replace(new RegExp("^ {1," + space + "}", "gm"), "") : item.replace(/^ {1,4}/gm, "")
288
- }
289
- if (this.options.smartLists && i !== l - 1) {
290
- b = block.bullet.exec(cap[i + 1])[0];
291
- if (bull !== b && !(bull.length > 1 && b.length > 1)) {
292
- src = cap.slice(i + 1).join("\n") + src;
293
- i = l - 1
294
- }
295
- }
296
- loose = next || /\n\n(?!\s*$)/.test(item);
297
- if (i !== l - 1) {
298
- next = item.charAt(item.length - 1) === "\n";
299
- if (!loose) {
300
- loose = next
301
- }
302
- }
303
- this.tokens.push({
304
- type: loose ? "loose_item_start" : "list_item_start"
305
- });
306
- this.token(item, false, bq);
307
- this.tokens.push({
308
- type: "list_item_end"
309
- })
310
- }
311
- this.tokens.push({
312
- type: "list_end"
313
- });
314
- continue
315
- }
316
- if (cap = this.rules.html.exec(src)) {
317
- src = src.substring(cap[0].length);
318
- this.tokens.push({
319
- type: this.options.sanitize ? "paragraph" : "html",
320
- pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
321
- text: cap[0]
322
- });
323
- continue
324
- }
325
- if ((!bq && top) && (cap = this.rules.def.exec(src))) {
326
- src = src.substring(cap[0].length);
327
- this.tokens.links[cap[1].toLowerCase()] = {
328
- href: cap[2],
329
- title: cap[3]
330
- };
331
- continue
332
- }
333
- if (top && (cap = this.rules.table.exec(src))) {
334
- src = src.substring(cap[0].length);
335
- item = {
336
- type: "table",
337
- header: cap[1].replace(/^ *| *\| *$/g, "").split(/ *\| */),
338
- align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
339
- cells: cap[3].replace(/(?: *\| *)?\n$/, "").split("\n")
340
- };
341
- for (i = 0; i < item.align.length; i++) {
342
- if (/^ *-+: *$/.test(item.align[i])) {
343
- item.align[i] = "right"
344
- } else {
345
- if (/^ *:-+: *$/.test(item.align[i])) {
346
- item.align[i] = "center"
347
- } else {
348
- if (/^ *:-+ *$/.test(item.align[i])) {
349
- item.align[i] = "left"
350
- } else {
351
- item.align[i] = null
352
- }
353
- }
354
- }
355
- }
356
- for (i = 0; i < item.cells.length; i++) {
357
- item.cells[i] = item.cells[i].replace(/^ *\| *| *\| *$/g, "").split(/ *\| */)
358
- }
359
- this.tokens.push(item);
360
- continue
361
- }
362
- if (top && (cap = this.rules.paragraph.exec(src))) {
363
- src = src.substring(cap[0].length);
364
- this.tokens.push({
365
- type: "paragraph",
366
- text: cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1]
367
- });
368
- continue
369
- }
370
- if (cap = this.rules.text.exec(src)) {
371
- src = src.substring(cap[0].length);
372
- this.tokens.push({
373
- type: "text",
374
- text: cap[0]
375
- });
376
- continue
377
- }
378
- if (src) {
379
- throw new Error("Infinite loop on byte: " + src.charCodeAt(0))
380
- }
381
- }
382
- return this.tokens
383
- };
384
- var inline = {
385
- escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
386
- autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
387
- url: noop,
388
- tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
389
- link: /^!?\[(inside)\]\(href\)/,
390
- reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
391
- nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
392
- strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
393
- em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
394
- code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
395
- br: /^ {2,}\n(?!\s*$)/,
396
- del: noop,
397
- text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
398
- };
399
- inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
400
- inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
401
- inline.link = replace(inline.link)("inside", inline._inside)("href", inline._href)();
402
- inline.reflink = replace(inline.reflink)("inside", inline._inside)();
403
- inline.normal = merge({}, inline);
404
- inline.pedantic = merge({}, inline.normal, {
405
- strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
406
- em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
407
- });
408
- inline.gfm = merge({}, inline.normal, {
409
- escape: replace(inline.escape)("])", "~|])")(),
410
- url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
411
- del: /^~~(?=\S)([\s\S]*?\S)~~/,
412
- text: replace(inline.text)("]|", "~]|")("|", "|https?://|")()
413
- });
414
- inline.breaks = merge({}, inline.gfm, {
415
- br: replace(inline.br)("{2,}", "*")(),
416
- text: replace(inline.gfm.text)("{2,}", "*")()
417
- });
418
-
419
- function InlineLexer(links, options) {
420
- this.options = options || marked.defaults;
421
- this.links = links;
422
- this.rules = inline.normal;
423
- this.renderer = this.options.renderer || new Renderer;
424
- this.renderer.options = this.options;
425
- if (!this.links) {
426
- throw new Error("Tokens array requires a `links` property.")
427
- }
428
- if (this.options.gfm) {
429
- if (this.options.breaks) {
430
- this.rules = inline.breaks
431
- } else {
432
- this.rules = inline.gfm
433
- }
434
- } else {
435
- if (this.options.pedantic) {
436
- this.rules = inline.pedantic
437
- }
438
- }
439
- }
440
- InlineLexer.rules = inline;
441
- InlineLexer.output = function (src, links, options) {
442
- var inline = new InlineLexer(links, options);
443
- return inline.output(src)
444
- };
445
- InlineLexer.prototype.output = function (src) {
446
- var out = "",
447
- link, text, href, cap;
448
- while (src) {
449
- if (cap = this.rules.escape.exec(src)) {
450
- src = src.substring(cap[0].length);
451
- out += cap[1];
452
- continue
453
- }
454
- if (cap = this.rules.autolink.exec(src)) {
455
- src = src.substring(cap[0].length);
456
- if (cap[2] === "@") {
457
- text = cap[1].charAt(6) === ":" ? this.mangle(cap[1].substring(7)) : this.mangle(cap[1]);
458
- href = this.mangle("mailto:") + text
459
- } else {
460
- text = escape(cap[1]);
461
- href = text
462
- }
463
- out += this.renderer.link(href, null, text);
464
- continue
465
- }
466
- if (!this.inLink && (cap = this.rules.url.exec(src))) {
467
- src = src.substring(cap[0].length);
468
- text = escape(cap[1]);
469
- href = text;
470
- out += this.renderer.link(href, null, text);
471
- continue
472
- }
473
- if (cap = this.rules.tag.exec(src)) {
474
- if (!this.inLink && /^<a /i.test(cap[0])) {
475
- this.inLink = true
476
- } else {
477
- if (this.inLink && /^<\/a>/i.test(cap[0])) {
478
- this.inLink = false
479
- }
480
- }
481
- src = src.substring(cap[0].length);
482
- out += this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
483
- continue
484
- }
485
- if (cap = this.rules.link.exec(src)) {
486
- src = src.substring(cap[0].length);
487
- this.inLink = true;
488
- out += this.outputLink(cap, {
489
- href: cap[2],
490
- title: cap[3]
491
- });
492
- this.inLink = false;
493
- continue
494
- }
495
- if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
496
- src = src.substring(cap[0].length);
497
- link = (cap[2] || cap[1]).replace(/\s+/g, " ");
498
- link = this.links[link.toLowerCase()];
499
- if (!link || !link.href) {
500
- out += cap[0].charAt(0);
501
- src = cap[0].substring(1) + src;
502
- continue
503
- }
504
- this.inLink = true;
505
- out += this.outputLink(cap, link);
506
- this.inLink = false;
507
- continue
508
- }
509
- if (cap = this.rules.strong.exec(src)) {
510
- src = src.substring(cap[0].length);
511
- out += this.renderer.strong(this.output(cap[2] || cap[1]));
512
- continue
513
- }
514
- if (cap = this.rules.em.exec(src)) {
515
- src = src.substring(cap[0].length);
516
- out += this.renderer.em(this.output(cap[2] || cap[1]));
517
- continue
518
- }
519
- if (cap = this.rules.code.exec(src)) {
520
- src = src.substring(cap[0].length);
521
- out += this.renderer.codespan(escape(cap[2], true));
522
- continue
523
- }
524
- if (cap = this.rules.br.exec(src)) {
525
- src = src.substring(cap[0].length);
526
- out += this.renderer.br();
527
- continue
528
- }
529
- if (cap = this.rules.del.exec(src)) {
530
- src = src.substring(cap[0].length);
531
- out += this.renderer.del(this.output(cap[1]));
532
- continue
533
- }
534
- if (cap = this.rules.text.exec(src)) {
535
- src = src.substring(cap[0].length);
536
- out += this.renderer.text(escape(this.smartypants(cap[0])));
537
- continue
538
- }
539
- if (src) {
540
- throw new Error("Infinite loop on byte: " + src.charCodeAt(0))
541
- }
542
- }
543
- return out
544
- };
545
- InlineLexer.prototype.outputLink = function (cap, link) {
546
- var href = escape(link.href),
547
- title = link.title ? escape(link.title) : null;
548
- return cap[0].charAt(0) !== "!" ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape(cap[1]))
549
- };
550
- InlineLexer.prototype.smartypants = function (text) {
551
- if (!this.options.smartypants) {
552
- return text
553
- }
554
- return text.replace(/---/g, "\u2014").replace(/--/g, "\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018").replace(/'/g, "\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c").replace(/"/g, "\u201d").replace(/\.{3}/g, "\u2026")
555
- };
556
- InlineLexer.prototype.mangle = function (text) {
557
- if (!this.options.mangle) {
558
- return text
559
- }
560
- var out = "",
561
- l = text.length,
562
- i = 0,
563
- ch;
564
- for (; i < l; i++) {
565
- ch = text.charCodeAt(i);
566
- if (Math.random() > 0.5) {
567
- ch = "x" + ch.toString(16)
568
- }
569
- out += "&#" + ch + ";"
570
- }
571
- return out
572
- };
573
-
574
- function Renderer(options) {
575
- this.options = options || {}
576
- }
577
- Renderer.prototype.code = function (code, lang, escaped) {
578
- if (this.options.highlight) {
579
- var out = this.options.highlight(code, lang);
580
- if (out != null && out !== code) {
581
- escaped = true;
582
- code = out
583
- }
584
- }
585
- if (!lang) {
586
- return "<pre><code>" + (escaped ? code : escape(code, true)) + "\n</code></pre>"
587
- }
588
- return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + "\n</code></pre>\n"
589
- };
590
- Renderer.prototype.blockquote = function (quote) {
591
- return "<blockquote>\n" + quote + "</blockquote>\n"
592
- };
593
- Renderer.prototype.html = function (html) {
594
- return html
595
- };
596
- Renderer.prototype.heading = function (text, level, raw) {
597
- return "<h" + level + ' id="' + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, "-") + '">' + text + "</h" + level + ">\n"
598
- };
599
- Renderer.prototype.hr = function () {
600
- return this.options.xhtml ? "<hr/>\n" : "<hr>\n"
601
- };
602
- Renderer.prototype.list = function (body, ordered) {
603
- var type = ordered ? "ol" : "ul";
604
- return "<" + type + ">\n" + body + "</" + type + ">\n"
605
- };
606
- Renderer.prototype.listitem = function (text) {
607
- return "<li>" + text + "</li>\n"
608
- };
609
- Renderer.prototype.paragraph = function (text) {
610
- return "<p>" + text + "</p>\n"
611
- };
612
- Renderer.prototype.table = function (header, body) {
613
- return "<table>\n" + "<thead>\n" + header + "</thead>\n" + "<tbody>\n" + body + "</tbody>\n" + "</table>\n"
614
- };
615
- Renderer.prototype.tablerow = function (content) {
616
- return "<tr>\n" + content + "</tr>\n"
617
- };
618
- Renderer.prototype.tablecell = function (content, flags) {
619
- var type = flags.header ? "th" : "td";
620
- var tag = flags.align ? "<" + type + ' style="text-align:' + flags.align + '">' : "<" + type + ">";
621
- return tag + content + "</" + type + ">\n"
622
- };
623
- Renderer.prototype.strong = function (text) {
624
- return "<strong>" + text + "</strong>"
625
- };
626
- Renderer.prototype.em = function (text) {
627
- return "<em>" + text + "</em>"
628
- };
629
- Renderer.prototype.codespan = function (text) {
630
- return "<code>" + text + "</code>"
631
- };
632
- Renderer.prototype.br = function () {
633
- return this.options.xhtml ? "<br/>" : "<br>"
634
- };
635
- Renderer.prototype.del = function (text) {
636
- return "<del>" + text + "</del>"
637
- };
638
- Renderer.prototype.link = function (href, title, text) {
639
- if (this.options.sanitize) {
640
- try {
641
- var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, "").toLowerCase()
642
- } catch (e) {
643
- return ""
644
- }
645
- if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf("data:") === 0) {
646
- return ""
647
- }
648
- }
649
- var out = '<a href="' + href + '"';
650
- if (title) {
651
- out += ' title="' + title + '"'
652
- }
653
- out += ">" + text + "</a>";
654
- return out
655
- };
656
- Renderer.prototype.image = function (href, title, text) {
657
- var out = '<img src="' + href + '" alt="' + text + '"';
658
- if (title) {
659
- out += ' title="' + title + '"'
660
- }
661
- out += this.options.xhtml ? "/>" : ">";
662
- return out
663
- };
664
- Renderer.prototype.text = function (text) {
665
- return text
666
- };
667
-
668
- function Parser(options) {
669
- this.tokens = [];
670
- this.token = null;
671
- this.options = options || marked.defaults;
672
- this.options.renderer = this.options.renderer || new Renderer;
673
- this.renderer = this.options.renderer;
674
- this.renderer.options = this.options
675
- }
676
- Parser.parse = function (src, options, renderer) {
677
- var parser = new Parser(options, renderer);
678
- return parser.parse(src)
679
- };
680
- Parser.prototype.parse = function (src) {
681
- this.inline = new InlineLexer(src.links, this.options, this.renderer);
682
- this.tokens = src.reverse();
683
- var out = "";
684
- while (this.next()) {
685
- out += this.tok()
686
- }
687
- return out
688
- };
689
- Parser.prototype.next = function () {
690
- return this.token = this.tokens.pop()
691
- };
692
- Parser.prototype.peek = function () {
693
- return this.tokens[this.tokens.length - 1] || 0
694
- };
695
- Parser.prototype.parseText = function () {
696
- var body = this.token.text;
697
- while (this.peek().type === "text") {
698
- body += "\n" + this.next().text
699
- }
700
- return this.inline.output(body)
701
- };
702
- Parser.prototype.tok = function () {
703
- switch (this.token.type) {
704
- case "space":
705
- return "";
706
- case "hr":
707
- return this.renderer.hr();
708
- case "heading":
709
- return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, this.token.text);
710
- case "code":
711
- return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
712
- case "table":
713
- var header = "",
714
- body = "",
715
- i, row, cell, flags, j;
716
- cell = "";
717
- for (i = 0; i < this.token.header.length; i++) {
718
- flags = {
719
- header: true,
720
- align: this.token.align[i]
721
- };
722
- cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), {
723
- header: true,
724
- align: this.token.align[i]
725
- })
726
- }
727
- header += this.renderer.tablerow(cell);
728
- for (i = 0; i < this.token.cells.length; i++) {
729
- row = this.token.cells[i];
730
- cell = "";
731
- for (j = 0; j < row.length; j++) {
732
- cell += this.renderer.tablecell(this.inline.output(row[j]), {
733
- header: false,
734
- align: this.token.align[j]
735
- })
736
- }
737
- body += this.renderer.tablerow(cell)
738
- }
739
- return this.renderer.table(header, body);
740
- case "blockquote_start":
741
- var body = "";
742
- while (this.next().type !== "blockquote_end") {
743
- body += this.tok()
744
- }
745
- return this.renderer.blockquote(body);
746
- case "list_start":
747
- var body = "",
748
- ordered = this.token.ordered;
749
- while (this.next().type !== "list_end") {
750
- body += this.tok()
751
- }
752
- return this.renderer.list(body, ordered);
753
- case "list_item_start":
754
- var body = "";
755
- while (this.next().type !== "list_item_end") {
756
- body += this.token.type === "text" ? this.parseText() : this.tok()
757
- }
758
- return this.renderer.listitem(body);
759
- case "loose_item_start":
760
- var body = "";
761
- while (this.next().type !== "list_item_end") {
762
- body += this.tok()
763
- }
764
- return this.renderer.listitem(body);
765
- case "html":
766
- var html = !this.token.pre && !this.options.pedantic ? this.inline.output(this.token.text) : this.token.text;
767
- return this.renderer.html(html);
768
- case "paragraph":
769
- return this.renderer.paragraph(this.inline.output(this.token.text));
770
- case "text":
771
- return this.renderer.paragraph(this.parseText())
772
- }
773
- };
774
-
775
- function escape(html, encode) {
776
- return html.replace(!encode ? /&(?!#?\w+;)/g : /&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;")
777
- }
778
-
779
- function unescape(html) {
780
- return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function (_, n) {
781
- n = n.toLowerCase();
782
- if (n === "colon") {
783
- return ":"
784
- }
785
- if (n.charAt(0) === "#") {
786
- return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1))
787
- }
788
- return ""
789
- })
790
- }
791
-
792
- function replace(regex, opt) {
793
- regex = regex.source;
794
- opt = opt || "";
795
- return function self(name, val) {
796
- if (!name) {
797
- return new RegExp(regex, opt)
798
- }
799
- val = val.source || val;
800
- val = val.replace(/(^|[^\[])\^/g, "$1");
801
- regex = regex.replace(name, val);
802
- return self
803
- }
804
- }
805
-
806
- function noop() {}
807
- noop.exec = noop;
808
-
809
- function merge(obj) {
810
- var i = 1,
811
- target, key;
812
- for (; i < arguments.length; i++) {
813
- target = arguments[i];
814
- for (key in target) {
815
- if (Object.prototype.hasOwnProperty.call(target, key)) {
816
- obj[key] = target[key]
817
- }
818
- }
819
- }
820
- return obj
821
- }
822
-
823
- function marked(src, opt, callback) {
824
- if (callback || typeof opt === "function") {
825
- if (!callback) {
826
- callback = opt;
827
- opt = null
828
- }
829
- opt = merge({}, marked.defaults, opt || {});
830
- var highlight = opt.highlight,
831
- tokens, pending, i = 0;
832
- try {
833
- tokens = Lexer.lex(src, opt)
834
- } catch (e) {
835
- return callback(e)
836
- }
837
- pending = tokens.length;
838
- var done = function (err) {
839
- if (err) {
840
- opt.highlight = highlight;
841
- return callback(err)
842
- }
843
- var out;
844
- try {
845
- out = Parser.parse(tokens, opt)
846
- } catch (e) {
847
- err = e
848
- }
849
- opt.highlight = highlight;
850
- return err ? callback(err) : callback(null, out)
851
- };
852
- if (!highlight || highlight.length < 3) {
853
- return done()
854
- }
855
- delete opt.highlight;
856
- if (!pending) {
857
- return done()
858
- }
859
- for (; i < tokens.length; i++) {
860
- (function (token) {
861
- if (token.type !== "code") {
862
- return --pending || done()
863
- }
864
- return highlight(token.text, token.lang, function (err, code) {
865
- if (err) {
866
- return done(err)
867
- }
868
- if (code == null || code === token.text) {
869
- return --pending || done()
870
- }
871
- token.text = code;
872
- token.escaped = true;
873
- --pending || done()
874
- })
875
- })(tokens[i])
876
- }
877
- return
878
- }
879
- try {
880
- if (opt) {
881
- opt = merge({}, marked.defaults, opt)
882
- }
883
- return Parser.parse(Lexer.lex(src, opt), opt)
884
- } catch (e) {
885
- e.message += "\nPlease report this to https://github.com/chjj/marked.";
886
- if ((opt || marked.defaults).silent) {
887
- return "<p>An error occured:</p><pre>" + escape(e.message + "", true) + "</pre>"
888
- }
889
- throw e
890
- }
891
- }
892
- marked.options = marked.setOptions = function (opt) {
893
- merge(marked.defaults, opt);
894
- return marked
895
- };
896
- marked.defaults = {
897
- gfm: true,
898
- tables: true,
899
- breaks: false,
900
- pedantic: false,
901
- sanitize: false,
902
- sanitizer: null,
903
- mangle: true,
904
- smartLists: false,
905
- silent: false,
906
- highlight: null,
907
- langPrefix: "lang-",
908
- smartypants: false,
909
- headerPrefix: "",
910
- renderer: new Renderer,
911
- xhtml: false
912
- };
913
- marked.Parser = Parser;
914
- marked.parser = Parser.parse;
915
- marked.Renderer = Renderer;
916
- marked.Lexer = Lexer;
917
- marked.lexer = Lexer.lex;
918
- marked.InlineLexer = InlineLexer;
919
- marked.inlineLexer = InlineLexer.output;
920
- marked.parse = marked;
921
- if (typeof module !== "undefined" && typeof exports === "object") {
922
- module.exports = marked
923
- } else {
924
- if (typeof define === "function" && define.amd) {
925
- define(function () {
926
- return marked
927
- })
928
- } else {
929
- this.marked = marked
930
- }
931
- }
932
- }).call(function () {
933
- return this || (typeof window !== "undefined" ? window : global)
934
- }());
935
- </script>
936
-
937
- <!--chips-->
938
-
939
- <script>
940
- Materialize={};Materialize.guid=(function(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return function(){return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}})();(function($){var materialChipsDefaults={data:[],placeholder:"",secondaryPlaceholder:"",autocompleteOptions:{},};$(document).ready(function(){$(document).on("click",".chip .close",function(e){var $chips=$(this).closest(".chips");if($chips.attr("data-initialized")){return}$(this).closest(".chip").remove()})});$.fn.material_chip=function(options){var self=this;this.$el=$(this);this.$document=$(document);this.SELS={CHIPS:".chips",CHIP:".chip",INPUT:"input",DELETE:".material-icons",SELECTED_CHIP:".selected",};if("data"===options){return this.$el.data("chips")}var curr_options=$.extend({},materialChipsDefaults,options);self.hasAutocomplete=!$.isEmptyObject(curr_options.autocompleteOptions.data);this.init=function(){var i=0;var chips;self.$el.each(function(){var $chips=$(this);var chipId=Materialize.guid();self.chipId=chipId;if(!curr_options.data||!(curr_options.data instanceof Array)){curr_options.data=[]}$chips.data("chips",curr_options.data);$chips.attr("data-index",i);$chips.attr("data-initialized",true);if(!$chips.hasClass(self.SELS.CHIPS)){$chips.addClass("chips")}self.chips($chips,chipId);i++})};this.handleEvents=function(){var SELS=self.SELS;self.$document.off("click.chips-focus",SELS.CHIPS).on("click.chips-focus",SELS.CHIPS,function(e){$(e.target).find(SELS.INPUT).focus()});self.$document.off("click.chips-select",SELS.CHIP).on("click.chips-select",SELS.CHIP,function(e){var $chip=$(e.target);if($chip.length){var wasSelected=$chip.hasClass("selected");var $chips=$chip.closest(SELS.CHIPS);$(SELS.CHIP).removeClass("selected");if(!wasSelected){self.selectChip($chip.index(),$chips)}}});self.$document.off("keydown.chips").on("keydown.chips",function(e){if($(e.target).is("input, textarea")){return}var $chip=self.$document.find(SELS.CHIP+SELS.SELECTED_CHIP);var $chips=$chip.closest(SELS.CHIPS);var length=$chip.siblings(SELS.CHIP).length;var index;if(!$chip.length){return}if(e.which===8||e.which===46){e.preventDefault();index=$chip.index();self.deleteChip(index,$chips);var selectIndex=null;if((index+1)<length){selectIndex=index}else{if(index===length||(index+1)===length){selectIndex=length-1}}if(selectIndex<0){selectIndex=null}if(null!==selectIndex){self.selectChip(selectIndex,$chips)}if(!length){$chips.find("input").focus()}}else{if(e.which===37){index=$chip.index()-1;if(index<0){return}$(SELS.CHIP).removeClass("selected");self.selectChip(index,$chips)}else{if(e.which===39){index=$chip.index()+1;$(SELS.CHIP).removeClass("selected");if(index>length){$chips.find("input").focus();return}self.selectChip(index,$chips)}}}});self.$document.off("focusin.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusin.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.addClass("focus");$currChips.siblings("label, .prefix").addClass("active");$(SELS.CHIP).removeClass("selected")});self.$document.off("focusout.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusout.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.removeClass("focus");if($currChips.data("chips")===undefined||!$currChips.data("chips").length){$currChips.siblings("label").removeClass("active")}$currChips.siblings(".prefix").removeClass("active")});self.$document.off("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT).on("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var chipsLength=$chips.children(SELS.CHIP).length;if(13===e.which){if(self.hasAutocomplete&&$chips.find(".autocomplete-content.dropdown-content").length&&$chips.find(".autocomplete-content.dropdown-content").children().length){return}e.preventDefault();self.addChip({tag:$target.val()},$chips);$target.val("");return}if((8===e.keyCode||37===e.keyCode)&&""===$target.val()&&chipsLength){e.preventDefault();self.selectChip(chipsLength-1,$chips);$target.blur();return}});self.$document.off("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE).on("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var $chip=$target.closest(SELS.CHIP);e.stopPropagation();self.deleteChip($chip.index(),$chips);$chips.find("input").focus()})};this.chips=function($chips,chipId){$chips.empty();$chips.data("chips").forEach(function(elem){$chips.append(self.renderChip(elem))});$chips.append($('<input id="'+chipId+'" class="input mdui-textfield-input" placeholder="">'));self.setPlaceholder($chips);var label=$chips.next("label");if(label.length){label.attr("for",chipId);if($chips.data("chips")!==undefined&&$chips.data("chips").length){label.addClass("active")}}var input=$("#"+chipId);if(self.hasAutocomplete){curr_options.autocompleteOptions.onAutocomplete=function(val){self.addChip({tag:val},$chips);input.val("");input.focus()
941
- };input.autocomplete(curr_options.autocompleteOptions)}};this.renderChip=function(elem){if(!elem.tag){return}var $renderedChip=$('<div class="mdui-chip chip mdui-chip-title"></div>');$renderedChip.text(elem.tag);if(elem.image){$renderedChip.prepend($("<img />").attr("src",elem.image))}$renderedChip.append($('<i class="material-icons mdui-icon close">close</i>'));return $renderedChip};this.setPlaceholder=function($chips){if($chips.data("chips")!==undefined&&$chips.data("chips").length&&curr_options.placeholder){$chips.find("input").prop("placeholder",curr_options.placeholder)}else{if(($chips.data("chips")===undefined||!$chips.data("chips").length)&&curr_options.secondaryPlaceholder){$chips.find("input").prop("placeholder",curr_options.secondaryPlaceholder)}}};this.isValid=function($chips,elem){var chips=$chips.data("chips");var exists=false;for(var i=0;i<chips.length;i++){if(chips[i].tag===elem.tag){exists=true;return}}return""!==elem.tag&&!exists};this.addChip=function(elem,$chips){if(!self.isValid($chips,elem)){return}var $renderedChip=self.renderChip(elem);var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){newData.push(oldData[i])}newData.push(elem);$chips.data("chips",newData);$renderedChip.insertBefore($chips.find("input"));$chips.trigger("chip.add",elem);self.setPlaceholder($chips)};this.deleteChip=function(chipIndex,$chips){var chip=$chips.data("chips")[chipIndex];$chips.find(".chip").eq(chipIndex).remove();var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){if(i!==chipIndex){newData.push(oldData[i])}}$chips.data("chips",newData);$chips.trigger("chip.delete",chip);self.setPlaceholder($chips)};this.selectChip=function(chipIndex,$chips){var $chip=$chips.find(".chip").eq(chipIndex);if($chip&&false===$chip.hasClass("selected")){$chip.addClass("selected");$chips.trigger("chip.select",$chips.data("chips")[chipIndex])}};this.getChipsElement=function(index,$chips){return $chips.eq(index)};this.init();this.handleEvents()}}(jQuery));
942
- </script>
943
- <script>
944
- $(function(){
945
- $('.chips-initial').material_chip({
946
- });
947
- $('.chips-placeholder').material_chip({
948
- placeholder: 'Enter a tag',
949
- secondaryPlaceholder: '+Tag',
950
- });
951
- /* save */
952
- function getTags(e){
953
- var tags = "";
954
- for (x in e){
955
- if (e[x] != ""){
956
- tags += e[x].tag+" ";
957
- }
958
- }
959
- return tags;
960
- }
961
- function setTags(e){
962
- var tags = [];
963
-
964
- for (x in e){
965
- if (e[x] != ''){
966
- tags[x]= {'tag':e[x]};
967
- }
968
- }
969
- return tags;
970
- }
971
- function getpost(){
972
- $('#editorContent').val(localStorage.previewContent);
973
- $('#editorTitle').val(localStorage.editorTitle);
974
- $('#editorDate').val(localStorage.editorDate);
975
- $('#imgurl').val(localStorage.imgurl);
976
- if (localStorage.categories){
977
- if (localStorage.categories.indexOf("radio_custom") == -1){
978
- $("input[value='"+ localStorage.categories +"']").attr('checked','');
979
- }else{
980
- $("input[value='radio_custom']").attr('checked','');
981
- $('#editorCategories').val(localStorage.categories.replace("radio_custom",''));
982
- }
983
- }
984
- if (localStorage.editorChips){
985
- var data = setTags(localStorage.editorChips.split(' '));
986
- $('.chips-initial').material_chip({
987
- data: data,
988
- });
989
- }
990
- }
991
- getpost();
992
- function setpost(){
993
- localStorage.previewContent = $('#editorContent').val();
994
- localStorage.editorTitle = $('#editorTitle').val();
995
- localStorage.editorDate = $('#editorDate').val();
996
- localStorage.imgurl = $('#imgurl').val();
997
- if ($("input[name='categories']:checked").val() == "radio_custom" ){
998
- localStorage.categories = $("input[name='categories']:checked").val() + $('#editorCategories').val();
999
- }else{
1000
- localStorage.categories = $("input[name='categories']:checked").val();
1001
- }
1002
- localStorage.editorChips = getTags($('.chips-initial').material_chip('data'));
1003
- }
1004
-
1005
- setInterval(function(){
1006
- setpost();
1007
- },5000);
1008
-
1009
- /*preview*/
1010
- $("#previewBtn").click(function(){
1011
- $('#previewContent').html(marked($('#editorContent').val()));
1012
- $('.mdui-card-primary-title').html($('#editorTitle').val());
1013
- $('.k-data').html($('#editorDate').val());
1014
- $('.k-post-media').css('background-image','url('+ $('#imgurl').val() +')');
1015
- });
1016
- /*download*/
1017
- var textFile = null;
1018
- function makeTextFile(text){
1019
- var data = new Blob([text], {
1020
- type: 'text/plain'
1021
- });
1022
- if (textFile !== null) {
1023
- window.URL.revokeObjectURL(textFile);
1024
- }
1025
- textFile = window.URL.createObjectURL(data);
1026
- return textFile;
1027
- }
1028
-
1029
- $('#download').click(function(){
1030
- var filename,filecontent;
1031
-
1032
- function k_getFiletitle(e){
1033
- var title = e.toLowerCase().split(" ");
1034
- var newtitle = "";
1035
- for (x in title){
1036
- if (parseInt(x)+1 == title.length){
1037
- newtitle += title[x];
1038
- }else{
1039
- newtitle += title[x]+"-";
1040
- }
1041
- }
1042
- return newtitle;
1043
- }
1044
-
1045
- function k_getCategories(e){
1046
- if (e == "radio_custom" ){
1047
- return $('#editorCategories').val();
1048
- }else{
1049
- return e;
1050
- }
1051
- }
1052
-
1053
- filename = new Date().toLocaleDateString('zh-CN', { hour12: false},'year,month').replace(/\//g,"-") + "-" + k_getFiletitle($('#editorTitle').val()) + ".markdown";
1054
- filecontent = "---\nlayout: post\ntitle: "+$('#editorTitle').val()+"\ndate: "+$('#editorDate').val()+" "+ new Date().toLocaleTimeString('en-US', { hour12: false }) +" +0800\ncategories: "+k_getCategories($("input[name='categories']:checked").val())+"\ntags: "+getTags($('.chips-initial').material_chip('data'))+"\nimg: "+$('#imgurl').val()+"\n---\n"+$('#editorContent').val();
1055
- $(this).attr("download",filename);
1056
- $(this).attr("href",makeTextFile(filecontent));
1057
- });
1058
- });
1
+ {% if site.data.site.lang == null or site.data.site.lang == "" %}
2
+ {% assign lang = site.data.lang.en-US %}
3
+ {% else %}
4
+ {% assign lang = site.data.lang[site.data.site.lang] %}
5
+ {% endif %}
6
+ {% capture categories %}
7
+ {% for c in site.categories %}
8
+ {{c[0]}}
9
+ {% endfor %}
10
+ {% endcapture %}
11
+ {% assign sortedcategories = categories | split:' ' | sort %}
12
+ <style>
13
+ .textarea-wrap{
14
+ height: 100%;
15
+ }
16
+ #preview{
17
+ max-width: 904px;
18
+ }
19
+ .k-post-media {
20
+ display:block
21
+ cursor: pointer;
22
+ max-height: 245px;
23
+ min-height: 245px;
24
+ background-position: 50% 50%;
25
+ background-size: cover;
26
+ background-color: white;
27
+ }
28
+ .k-post-media .mdui-card-primary-title a {
29
+ text-decoration: none;
30
+ }
31
+ </style>
32
+ <div class="k-posts-list"></div>
33
+ <div class="k-container">
34
+ <div class="mdui-dialog" id="frontMatter">
35
+ <div class="mdui-dialog-content">
36
+ <div class="mdui-dialog-title">{{lang.editor.frontmatter.name}}</div>
37
+ <h3>{{lang.editor.frontmatter.title}}</h3>
38
+ <div class="mdui-textfield">
39
+ <input id="editorTitle" class="mdui-textfield-input" type="text"/>
40
+ </div>
41
+ <h3>{{lang.editor.frontmatter.date}}</h3>
42
+ <div class="mdui-textfield">
43
+ <input id="editorDate" class="mdui-textfield-input datepicker" type="date"/>
44
+ </div>
45
+ <h3>{{lang.editor.frontmatter.categories}}</h3>
46
+ <div class="mdui-row-md-4 mdui-row-sm-3">
47
+ {% for c in sortedcategories %}
48
+ <div class="mdui-col">
49
+ <label class="mdui-radio">
50
+ <input type="radio" value="{{c}}" name="categories">
51
+ <i class="mdui-radio-icon"></i>
52
+ {{c}}
53
+ </label>
54
+ </div>
55
+ {% endfor %}
56
+ <div class="mdui-col">
57
+ <label id="radio_custom" class="mdui-radio mdui-float-left">
58
+ <input type="radio" value="radio_custom" name="categories">
59
+ <i class="mdui-radio-icon"></i>
60
+ </label>
61
+ <div style="padding-top: 0px;" class="mdui-textfield">
62
+ <input id="editorCategories" class="mdui-textfield-input" name="radio_custom" type="text" placeholder="categories">
63
+ </div>
64
+ </div>
65
+ </div>
66
+ <h3>{{lang.editor.frontmatter.tags}}</h3>
67
+ <div class="chips chips-initial"></div>
68
+ <h3>{{lang.editor.frontmatter.image}}</h3>
69
+ <div class="mdui-textfield">
70
+ <input id="imgurl" class="mdui-textfield-input" type="text" placeholder="imgUrl">
71
+ </div>
72
+ </div>
73
+ </div>
74
+
75
+ <div class="mdui-dialog" id="preview">
76
+ <div class="mdui-dialog-content">
77
+ <div class="mdui-dialog-title">{{lang.editor.preview}}</div>
78
+ <div class="mdui-card k-postcontent">
79
+ <div class="mdui-card-media k-post-media">
80
+ <div class="mdui-card-media-covered mdui-card-media-covered-gradient">
81
+ <div class="mdui-card-primary">
82
+ <div class="mdui-card-primary-title">
83
+
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ <div class="mdui-card-header">
89
+ <img class="mdui-card-header-avatar" src="{{site.data.site.img.avatar}}">
90
+ <div class="mdui-card-header-title">{{site.author}}</div>
91
+ <div class="mdui-card-header-subtitle k-data"></div>
92
+ </div>
93
+ <div class="mdui-card-content mdui-typo" id="previewContent"></div>
94
+ </div>
95
+ </div>
96
+ </div>
97
+
98
+ <div class="mdui-card">
99
+ <div class="mdui-card-content">
100
+ <h3>{{lang.editor.content}}</h3>
101
+ <div class="mdui-textfield">
102
+ <textarea id="editorContent" class="mdui-textfield-input" placeholder="Description"></textarea>
103
+ </div>
104
+ </div>
105
+ <div class="mdui-card-actions">
106
+ <a class="mdui-btn mdui-ripple" mdui-dialog="{target: '#frontMatter'}">{{lang.editor.frontmatter.name}}</a>
107
+ <a id="previewBtn" class="mdui-btn mdui-ripple" mdui-dialog="{target: '#preview'}">{{lang.editor.preview}}</a>
108
+ <a id="download" class="mdui-btn mdui-ripple mdui-float-right">{{lang.editor.download}}</a>
109
+ </div>
110
+ </div>
111
+ </div>
112
+
113
+ <!--marked-->
114
+ <script>
115
+ (function () {
116
+ var block = {
117
+ newline: /^\n+/,
118
+ code: /^( {4}[^\n]+\n*)+/,
119
+ fences: noop,
120
+ hr: /^( *[-*_]){3,} *(?:\n+|$)/,
121
+ heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
122
+ nptable: noop,
123
+ lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
124
+ blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
125
+ list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
126
+ html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
127
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
128
+ table: noop,
129
+ paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
130
+ text: /^[^\n]+/
131
+ };
132
+ block.bullet = /(?:[*+-]|\d+\.)/;
133
+ block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
134
+ block.item = replace(block.item, "gm")(/bull/g, block.bullet)();
135
+ block.list = replace(block.list)(/bull/g, block.bullet)("hr", "\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def", "\\n+(?=" + block.def.source + ")")();
136
+ block.blockquote = replace(block.blockquote)("def", block.def)();
137
+ block._tag = "(?!(?:" + "a|em|strong|small|s|cite|q|dfn|abbr|data|time|code" + "|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo" + "|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";
138
+ block.html = replace(block.html)("comment", /<!--[\s\S]*?-->/)("closed", /<(tag)[\s\S]+?<\/\1>/)("closing", /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g, block._tag)();
139
+ block.paragraph = replace(block.paragraph)("hr", block.hr)("heading", block.heading)("lheading", block.lheading)("blockquote", block.blockquote)("tag", "<" + block._tag)("def", block.def)();
140
+ block.normal = merge({}, block);
141
+ block.gfm = merge({}, block.normal, {
142
+ fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
143
+ paragraph: /^/,
144
+ heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
145
+ });
146
+ block.gfm.paragraph = replace(block.paragraph)("(?!", "(?!" + block.gfm.fences.source.replace("\\1", "\\2") + "|" + block.list.source.replace("\\1", "\\3") + "|")();
147
+ block.tables = merge({}, block.gfm, {
148
+ nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
149
+ table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
150
+ });
151
+
152
+ function Lexer(options) {
153
+ this.tokens = [];
154
+ this.tokens.links = {};
155
+ this.options = options || marked.defaults;
156
+ this.rules = block.normal;
157
+ if (this.options.gfm) {
158
+ if (this.options.tables) {
159
+ this.rules = block.tables
160
+ } else {
161
+ this.rules = block.gfm
162
+ }
163
+ }
164
+ }
165
+ Lexer.rules = block;
166
+ Lexer.lex = function (src, options) {
167
+ var lexer = new Lexer(options);
168
+ return lexer.lex(src)
169
+ };
170
+ Lexer.prototype.lex = function (src) {
171
+ src = src.replace(/\r\n|\r/g, "\n").replace(/\t/g, " ").replace(/\u00a0/g, " ").replace(/\u2424/g, "\n");
172
+ return this.token(src, true)
173
+ };
174
+ Lexer.prototype.token = function (src, top, bq) {
175
+ var src = src.replace(/^ +$/gm, ""),
176
+ next, loose, cap, bull, b, item, space, i, l;
177
+ while (src) {
178
+ if (cap = this.rules.newline.exec(src)) {
179
+ src = src.substring(cap[0].length);
180
+ if (cap[0].length > 1) {
181
+ this.tokens.push({
182
+ type: "space"
183
+ })
184
+ }
185
+ }
186
+ if (cap = this.rules.code.exec(src)) {
187
+ src = src.substring(cap[0].length);
188
+ cap = cap[0].replace(/^ {4}/gm, "");
189
+ this.tokens.push({
190
+ type: "code",
191
+ text: !this.options.pedantic ? cap.replace(/\n+$/, "") : cap
192
+ });
193
+ continue
194
+ }
195
+ if (cap = this.rules.fences.exec(src)) {
196
+ src = src.substring(cap[0].length);
197
+ this.tokens.push({
198
+ type: "code",
199
+ lang: cap[2],
200
+ text: cap[3] || ""
201
+ });
202
+ continue
203
+ }
204
+ if (cap = this.rules.heading.exec(src)) {
205
+ src = src.substring(cap[0].length);
206
+ this.tokens.push({
207
+ type: "heading",
208
+ depth: cap[1].length,
209
+ text: cap[2]
210
+ });
211
+ continue
212
+ }
213
+ if (top && (cap = this.rules.nptable.exec(src))) {
214
+ src = src.substring(cap[0].length);
215
+ item = {
216
+ type: "table",
217
+ header: cap[1].replace(/^ *| *\| *$/g, "").split(/ *\| */),
218
+ align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
219
+ cells: cap[3].replace(/\n$/, "").split("\n")
220
+ };
221
+ for (i = 0; i < item.align.length; i++) {
222
+ if (/^ *-+: *$/.test(item.align[i])) {
223
+ item.align[i] = "right"
224
+ } else {
225
+ if (/^ *:-+: *$/.test(item.align[i])) {
226
+ item.align[i] = "center"
227
+ } else {
228
+ if (/^ *:-+ *$/.test(item.align[i])) {
229
+ item.align[i] = "left"
230
+ } else {
231
+ item.align[i] = null
232
+ }
233
+ }
234
+ }
235
+ }
236
+ for (i = 0; i < item.cells.length; i++) {
237
+ item.cells[i] = item.cells[i].split(/ *\| */)
238
+ }
239
+ this.tokens.push(item);
240
+ continue
241
+ }
242
+ if (cap = this.rules.lheading.exec(src)) {
243
+ src = src.substring(cap[0].length);
244
+ this.tokens.push({
245
+ type: "heading",
246
+ depth: cap[2] === "=" ? 1 : 2,
247
+ text: cap[1]
248
+ });
249
+ continue
250
+ }
251
+ if (cap = this.rules.hr.exec(src)) {
252
+ src = src.substring(cap[0].length);
253
+ this.tokens.push({
254
+ type: "hr"
255
+ });
256
+ continue
257
+ }
258
+ if (cap = this.rules.blockquote.exec(src)) {
259
+ src = src.substring(cap[0].length);
260
+ this.tokens.push({
261
+ type: "blockquote_start"
262
+ });
263
+ cap = cap[0].replace(/^ *> ?/gm, "");
264
+ this.token(cap, top, true);
265
+ this.tokens.push({
266
+ type: "blockquote_end"
267
+ });
268
+ continue
269
+ }
270
+ if (cap = this.rules.list.exec(src)) {
271
+ src = src.substring(cap[0].length);
272
+ bull = cap[2];
273
+ this.tokens.push({
274
+ type: "list_start",
275
+ ordered: bull.length > 1
276
+ });
277
+ cap = cap[0].match(this.rules.item);
278
+ next = false;
279
+ l = cap.length;
280
+ i = 0;
281
+ for (; i < l; i++) {
282
+ item = cap[i];
283
+ space = item.length;
284
+ item = item.replace(/^ *([*+-]|\d+\.) +/, "");
285
+ if (~item.indexOf("\n ")) {
286
+ space -= item.length;
287
+ item = !this.options.pedantic ? item.replace(new RegExp("^ {1," + space + "}", "gm"), "") : item.replace(/^ {1,4}/gm, "")
288
+ }
289
+ if (this.options.smartLists && i !== l - 1) {
290
+ b = block.bullet.exec(cap[i + 1])[0];
291
+ if (bull !== b && !(bull.length > 1 && b.length > 1)) {
292
+ src = cap.slice(i + 1).join("\n") + src;
293
+ i = l - 1
294
+ }
295
+ }
296
+ loose = next || /\n\n(?!\s*$)/.test(item);
297
+ if (i !== l - 1) {
298
+ next = item.charAt(item.length - 1) === "\n";
299
+ if (!loose) {
300
+ loose = next
301
+ }
302
+ }
303
+ this.tokens.push({
304
+ type: loose ? "loose_item_start" : "list_item_start"
305
+ });
306
+ this.token(item, false, bq);
307
+ this.tokens.push({
308
+ type: "list_item_end"
309
+ })
310
+ }
311
+ this.tokens.push({
312
+ type: "list_end"
313
+ });
314
+ continue
315
+ }
316
+ if (cap = this.rules.html.exec(src)) {
317
+ src = src.substring(cap[0].length);
318
+ this.tokens.push({
319
+ type: this.options.sanitize ? "paragraph" : "html",
320
+ pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
321
+ text: cap[0]
322
+ });
323
+ continue
324
+ }
325
+ if ((!bq && top) && (cap = this.rules.def.exec(src))) {
326
+ src = src.substring(cap[0].length);
327
+ this.tokens.links[cap[1].toLowerCase()] = {
328
+ href: cap[2],
329
+ title: cap[3]
330
+ };
331
+ continue
332
+ }
333
+ if (top && (cap = this.rules.table.exec(src))) {
334
+ src = src.substring(cap[0].length);
335
+ item = {
336
+ type: "table",
337
+ header: cap[1].replace(/^ *| *\| *$/g, "").split(/ *\| */),
338
+ align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
339
+ cells: cap[3].replace(/(?: *\| *)?\n$/, "").split("\n")
340
+ };
341
+ for (i = 0; i < item.align.length; i++) {
342
+ if (/^ *-+: *$/.test(item.align[i])) {
343
+ item.align[i] = "right"
344
+ } else {
345
+ if (/^ *:-+: *$/.test(item.align[i])) {
346
+ item.align[i] = "center"
347
+ } else {
348
+ if (/^ *:-+ *$/.test(item.align[i])) {
349
+ item.align[i] = "left"
350
+ } else {
351
+ item.align[i] = null
352
+ }
353
+ }
354
+ }
355
+ }
356
+ for (i = 0; i < item.cells.length; i++) {
357
+ item.cells[i] = item.cells[i].replace(/^ *\| *| *\| *$/g, "").split(/ *\| */)
358
+ }
359
+ this.tokens.push(item);
360
+ continue
361
+ }
362
+ if (top && (cap = this.rules.paragraph.exec(src))) {
363
+ src = src.substring(cap[0].length);
364
+ this.tokens.push({
365
+ type: "paragraph",
366
+ text: cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1]
367
+ });
368
+ continue
369
+ }
370
+ if (cap = this.rules.text.exec(src)) {
371
+ src = src.substring(cap[0].length);
372
+ this.tokens.push({
373
+ type: "text",
374
+ text: cap[0]
375
+ });
376
+ continue
377
+ }
378
+ if (src) {
379
+ throw new Error("Infinite loop on byte: " + src.charCodeAt(0))
380
+ }
381
+ }
382
+ return this.tokens
383
+ };
384
+ var inline = {
385
+ escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
386
+ autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
387
+ url: noop,
388
+ tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
389
+ link: /^!?\[(inside)\]\(href\)/,
390
+ reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
391
+ nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
392
+ strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
393
+ em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
394
+ code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
395
+ br: /^ {2,}\n(?!\s*$)/,
396
+ del: noop,
397
+ text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
398
+ };
399
+ inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
400
+ inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
401
+ inline.link = replace(inline.link)("inside", inline._inside)("href", inline._href)();
402
+ inline.reflink = replace(inline.reflink)("inside", inline._inside)();
403
+ inline.normal = merge({}, inline);
404
+ inline.pedantic = merge({}, inline.normal, {
405
+ strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
406
+ em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
407
+ });
408
+ inline.gfm = merge({}, inline.normal, {
409
+ escape: replace(inline.escape)("])", "~|])")(),
410
+ url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
411
+ del: /^~~(?=\S)([\s\S]*?\S)~~/,
412
+ text: replace(inline.text)("]|", "~]|")("|", "|https?://|")()
413
+ });
414
+ inline.breaks = merge({}, inline.gfm, {
415
+ br: replace(inline.br)("{2,}", "*")(),
416
+ text: replace(inline.gfm.text)("{2,}", "*")()
417
+ });
418
+
419
+ function InlineLexer(links, options) {
420
+ this.options = options || marked.defaults;
421
+ this.links = links;
422
+ this.rules = inline.normal;
423
+ this.renderer = this.options.renderer || new Renderer;
424
+ this.renderer.options = this.options;
425
+ if (!this.links) {
426
+ throw new Error("Tokens array requires a `links` property.")
427
+ }
428
+ if (this.options.gfm) {
429
+ if (this.options.breaks) {
430
+ this.rules = inline.breaks
431
+ } else {
432
+ this.rules = inline.gfm
433
+ }
434
+ } else {
435
+ if (this.options.pedantic) {
436
+ this.rules = inline.pedantic
437
+ }
438
+ }
439
+ }
440
+ InlineLexer.rules = inline;
441
+ InlineLexer.output = function (src, links, options) {
442
+ var inline = new InlineLexer(links, options);
443
+ return inline.output(src)
444
+ };
445
+ InlineLexer.prototype.output = function (src) {
446
+ var out = "",
447
+ link, text, href, cap;
448
+ while (src) {
449
+ if (cap = this.rules.escape.exec(src)) {
450
+ src = src.substring(cap[0].length);
451
+ out += cap[1];
452
+ continue
453
+ }
454
+ if (cap = this.rules.autolink.exec(src)) {
455
+ src = src.substring(cap[0].length);
456
+ if (cap[2] === "@") {
457
+ text = cap[1].charAt(6) === ":" ? this.mangle(cap[1].substring(7)) : this.mangle(cap[1]);
458
+ href = this.mangle("mailto:") + text
459
+ } else {
460
+ text = escape(cap[1]);
461
+ href = text
462
+ }
463
+ out += this.renderer.link(href, null, text);
464
+ continue
465
+ }
466
+ if (!this.inLink && (cap = this.rules.url.exec(src))) {
467
+ src = src.substring(cap[0].length);
468
+ text = escape(cap[1]);
469
+ href = text;
470
+ out += this.renderer.link(href, null, text);
471
+ continue
472
+ }
473
+ if (cap = this.rules.tag.exec(src)) {
474
+ if (!this.inLink && /^<a /i.test(cap[0])) {
475
+ this.inLink = true
476
+ } else {
477
+ if (this.inLink && /^<\/a>/i.test(cap[0])) {
478
+ this.inLink = false
479
+ }
480
+ }
481
+ src = src.substring(cap[0].length);
482
+ out += this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
483
+ continue
484
+ }
485
+ if (cap = this.rules.link.exec(src)) {
486
+ src = src.substring(cap[0].length);
487
+ this.inLink = true;
488
+ out += this.outputLink(cap, {
489
+ href: cap[2],
490
+ title: cap[3]
491
+ });
492
+ this.inLink = false;
493
+ continue
494
+ }
495
+ if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
496
+ src = src.substring(cap[0].length);
497
+ link = (cap[2] || cap[1]).replace(/\s+/g, " ");
498
+ link = this.links[link.toLowerCase()];
499
+ if (!link || !link.href) {
500
+ out += cap[0].charAt(0);
501
+ src = cap[0].substring(1) + src;
502
+ continue
503
+ }
504
+ this.inLink = true;
505
+ out += this.outputLink(cap, link);
506
+ this.inLink = false;
507
+ continue
508
+ }
509
+ if (cap = this.rules.strong.exec(src)) {
510
+ src = src.substring(cap[0].length);
511
+ out += this.renderer.strong(this.output(cap[2] || cap[1]));
512
+ continue
513
+ }
514
+ if (cap = this.rules.em.exec(src)) {
515
+ src = src.substring(cap[0].length);
516
+ out += this.renderer.em(this.output(cap[2] || cap[1]));
517
+ continue
518
+ }
519
+ if (cap = this.rules.code.exec(src)) {
520
+ src = src.substring(cap[0].length);
521
+ out += this.renderer.codespan(escape(cap[2], true));
522
+ continue
523
+ }
524
+ if (cap = this.rules.br.exec(src)) {
525
+ src = src.substring(cap[0].length);
526
+ out += this.renderer.br();
527
+ continue
528
+ }
529
+ if (cap = this.rules.del.exec(src)) {
530
+ src = src.substring(cap[0].length);
531
+ out += this.renderer.del(this.output(cap[1]));
532
+ continue
533
+ }
534
+ if (cap = this.rules.text.exec(src)) {
535
+ src = src.substring(cap[0].length);
536
+ out += this.renderer.text(escape(this.smartypants(cap[0])));
537
+ continue
538
+ }
539
+ if (src) {
540
+ throw new Error("Infinite loop on byte: " + src.charCodeAt(0))
541
+ }
542
+ }
543
+ return out
544
+ };
545
+ InlineLexer.prototype.outputLink = function (cap, link) {
546
+ var href = escape(link.href),
547
+ title = link.title ? escape(link.title) : null;
548
+ return cap[0].charAt(0) !== "!" ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape(cap[1]))
549
+ };
550
+ InlineLexer.prototype.smartypants = function (text) {
551
+ if (!this.options.smartypants) {
552
+ return text
553
+ }
554
+ return text.replace(/---/g, "\u2014").replace(/--/g, "\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018").replace(/'/g, "\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c").replace(/"/g, "\u201d").replace(/\.{3}/g, "\u2026")
555
+ };
556
+ InlineLexer.prototype.mangle = function (text) {
557
+ if (!this.options.mangle) {
558
+ return text
559
+ }
560
+ var out = "",
561
+ l = text.length,
562
+ i = 0,
563
+ ch;
564
+ for (; i < l; i++) {
565
+ ch = text.charCodeAt(i);
566
+ if (Math.random() > 0.5) {
567
+ ch = "x" + ch.toString(16)
568
+ }
569
+ out += "&#" + ch + ";"
570
+ }
571
+ return out
572
+ };
573
+
574
+ function Renderer(options) {
575
+ this.options = options || {}
576
+ }
577
+ Renderer.prototype.code = function (code, lang, escaped) {
578
+ if (this.options.highlight) {
579
+ var out = this.options.highlight(code, lang);
580
+ if (out != null && out !== code) {
581
+ escaped = true;
582
+ code = out
583
+ }
584
+ }
585
+ if (!lang) {
586
+ return "<pre><code>" + (escaped ? code : escape(code, true)) + "\n</code></pre>"
587
+ }
588
+ return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + "\n</code></pre>\n"
589
+ };
590
+ Renderer.prototype.blockquote = function (quote) {
591
+ return "<blockquote>\n" + quote + "</blockquote>\n"
592
+ };
593
+ Renderer.prototype.html = function (html) {
594
+ return html
595
+ };
596
+ Renderer.prototype.heading = function (text, level, raw) {
597
+ return "<h" + level + ' id="' + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, "-") + '">' + text + "</h" + level + ">\n"
598
+ };
599
+ Renderer.prototype.hr = function () {
600
+ return this.options.xhtml ? "<hr/>\n" : "<hr>\n"
601
+ };
602
+ Renderer.prototype.list = function (body, ordered) {
603
+ var type = ordered ? "ol" : "ul";
604
+ return "<" + type + ">\n" + body + "</" + type + ">\n"
605
+ };
606
+ Renderer.prototype.listitem = function (text) {
607
+ return "<li>" + text + "</li>\n"
608
+ };
609
+ Renderer.prototype.paragraph = function (text) {
610
+ return "<p>" + text + "</p>\n"
611
+ };
612
+ Renderer.prototype.table = function (header, body) {
613
+ return "<table>\n" + "<thead>\n" + header + "</thead>\n" + "<tbody>\n" + body + "</tbody>\n" + "</table>\n"
614
+ };
615
+ Renderer.prototype.tablerow = function (content) {
616
+ return "<tr>\n" + content + "</tr>\n"
617
+ };
618
+ Renderer.prototype.tablecell = function (content, flags) {
619
+ var type = flags.header ? "th" : "td";
620
+ var tag = flags.align ? "<" + type + ' style="text-align:' + flags.align + '">' : "<" + type + ">";
621
+ return tag + content + "</" + type + ">\n"
622
+ };
623
+ Renderer.prototype.strong = function (text) {
624
+ return "<strong>" + text + "</strong>"
625
+ };
626
+ Renderer.prototype.em = function (text) {
627
+ return "<em>" + text + "</em>"
628
+ };
629
+ Renderer.prototype.codespan = function (text) {
630
+ return "<code>" + text + "</code>"
631
+ };
632
+ Renderer.prototype.br = function () {
633
+ return this.options.xhtml ? "<br/>" : "<br>"
634
+ };
635
+ Renderer.prototype.del = function (text) {
636
+ return "<del>" + text + "</del>"
637
+ };
638
+ Renderer.prototype.link = function (href, title, text) {
639
+ if (this.options.sanitize) {
640
+ try {
641
+ var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, "").toLowerCase()
642
+ } catch (e) {
643
+ return ""
644
+ }
645
+ if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf("data:") === 0) {
646
+ return ""
647
+ }
648
+ }
649
+ var out = '<a href="' + href + '"';
650
+ if (title) {
651
+ out += ' title="' + title + '"'
652
+ }
653
+ out += ">" + text + "</a>";
654
+ return out
655
+ };
656
+ Renderer.prototype.image = function (href, title, text) {
657
+ var out = '<img src="' + href + '" alt="' + text + '"';
658
+ if (title) {
659
+ out += ' title="' + title + '"'
660
+ }
661
+ out += this.options.xhtml ? "/>" : ">";
662
+ return out
663
+ };
664
+ Renderer.prototype.text = function (text) {
665
+ return text
666
+ };
667
+
668
+ function Parser(options) {
669
+ this.tokens = [];
670
+ this.token = null;
671
+ this.options = options || marked.defaults;
672
+ this.options.renderer = this.options.renderer || new Renderer;
673
+ this.renderer = this.options.renderer;
674
+ this.renderer.options = this.options
675
+ }
676
+ Parser.parse = function (src, options, renderer) {
677
+ var parser = new Parser(options, renderer);
678
+ return parser.parse(src)
679
+ };
680
+ Parser.prototype.parse = function (src) {
681
+ this.inline = new InlineLexer(src.links, this.options, this.renderer);
682
+ this.tokens = src.reverse();
683
+ var out = "";
684
+ while (this.next()) {
685
+ out += this.tok()
686
+ }
687
+ return out
688
+ };
689
+ Parser.prototype.next = function () {
690
+ return this.token = this.tokens.pop()
691
+ };
692
+ Parser.prototype.peek = function () {
693
+ return this.tokens[this.tokens.length - 1] || 0
694
+ };
695
+ Parser.prototype.parseText = function () {
696
+ var body = this.token.text;
697
+ while (this.peek().type === "text") {
698
+ body += "\n" + this.next().text
699
+ }
700
+ return this.inline.output(body)
701
+ };
702
+ Parser.prototype.tok = function () {
703
+ switch (this.token.type) {
704
+ case "space":
705
+ return "";
706
+ case "hr":
707
+ return this.renderer.hr();
708
+ case "heading":
709
+ return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, this.token.text);
710
+ case "code":
711
+ return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
712
+ case "table":
713
+ var header = "",
714
+ body = "",
715
+ i, row, cell, flags, j;
716
+ cell = "";
717
+ for (i = 0; i < this.token.header.length; i++) {
718
+ flags = {
719
+ header: true,
720
+ align: this.token.align[i]
721
+ };
722
+ cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), {
723
+ header: true,
724
+ align: this.token.align[i]
725
+ })
726
+ }
727
+ header += this.renderer.tablerow(cell);
728
+ for (i = 0; i < this.token.cells.length; i++) {
729
+ row = this.token.cells[i];
730
+ cell = "";
731
+ for (j = 0; j < row.length; j++) {
732
+ cell += this.renderer.tablecell(this.inline.output(row[j]), {
733
+ header: false,
734
+ align: this.token.align[j]
735
+ })
736
+ }
737
+ body += this.renderer.tablerow(cell)
738
+ }
739
+ return this.renderer.table(header, body);
740
+ case "blockquote_start":
741
+ var body = "";
742
+ while (this.next().type !== "blockquote_end") {
743
+ body += this.tok()
744
+ }
745
+ return this.renderer.blockquote(body);
746
+ case "list_start":
747
+ var body = "",
748
+ ordered = this.token.ordered;
749
+ while (this.next().type !== "list_end") {
750
+ body += this.tok()
751
+ }
752
+ return this.renderer.list(body, ordered);
753
+ case "list_item_start":
754
+ var body = "";
755
+ while (this.next().type !== "list_item_end") {
756
+ body += this.token.type === "text" ? this.parseText() : this.tok()
757
+ }
758
+ return this.renderer.listitem(body);
759
+ case "loose_item_start":
760
+ var body = "";
761
+ while (this.next().type !== "list_item_end") {
762
+ body += this.tok()
763
+ }
764
+ return this.renderer.listitem(body);
765
+ case "html":
766
+ var html = !this.token.pre && !this.options.pedantic ? this.inline.output(this.token.text) : this.token.text;
767
+ return this.renderer.html(html);
768
+ case "paragraph":
769
+ return this.renderer.paragraph(this.inline.output(this.token.text));
770
+ case "text":
771
+ return this.renderer.paragraph(this.parseText())
772
+ }
773
+ };
774
+
775
+ function escape(html, encode) {
776
+ return html.replace(!encode ? /&(?!#?\w+;)/g : /&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;")
777
+ }
778
+
779
+ function unescape(html) {
780
+ return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function (_, n) {
781
+ n = n.toLowerCase();
782
+ if (n === "colon") {
783
+ return ":"
784
+ }
785
+ if (n.charAt(0) === "#") {
786
+ return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1))
787
+ }
788
+ return ""
789
+ })
790
+ }
791
+
792
+ function replace(regex, opt) {
793
+ regex = regex.source;
794
+ opt = opt || "";
795
+ return function self(name, val) {
796
+ if (!name) {
797
+ return new RegExp(regex, opt)
798
+ }
799
+ val = val.source || val;
800
+ val = val.replace(/(^|[^\[])\^/g, "$1");
801
+ regex = regex.replace(name, val);
802
+ return self
803
+ }
804
+ }
805
+
806
+ function noop() {}
807
+ noop.exec = noop;
808
+
809
+ function merge(obj) {
810
+ var i = 1,
811
+ target, key;
812
+ for (; i < arguments.length; i++) {
813
+ target = arguments[i];
814
+ for (key in target) {
815
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
816
+ obj[key] = target[key]
817
+ }
818
+ }
819
+ }
820
+ return obj
821
+ }
822
+
823
+ function marked(src, opt, callback) {
824
+ if (callback || typeof opt === "function") {
825
+ if (!callback) {
826
+ callback = opt;
827
+ opt = null
828
+ }
829
+ opt = merge({}, marked.defaults, opt || {});
830
+ var highlight = opt.highlight,
831
+ tokens, pending, i = 0;
832
+ try {
833
+ tokens = Lexer.lex(src, opt)
834
+ } catch (e) {
835
+ return callback(e)
836
+ }
837
+ pending = tokens.length;
838
+ var done = function (err) {
839
+ if (err) {
840
+ opt.highlight = highlight;
841
+ return callback(err)
842
+ }
843
+ var out;
844
+ try {
845
+ out = Parser.parse(tokens, opt)
846
+ } catch (e) {
847
+ err = e
848
+ }
849
+ opt.highlight = highlight;
850
+ return err ? callback(err) : callback(null, out)
851
+ };
852
+ if (!highlight || highlight.length < 3) {
853
+ return done()
854
+ }
855
+ delete opt.highlight;
856
+ if (!pending) {
857
+ return done()
858
+ }
859
+ for (; i < tokens.length; i++) {
860
+ (function (token) {
861
+ if (token.type !== "code") {
862
+ return --pending || done()
863
+ }
864
+ return highlight(token.text, token.lang, function (err, code) {
865
+ if (err) {
866
+ return done(err)
867
+ }
868
+ if (code == null || code === token.text) {
869
+ return --pending || done()
870
+ }
871
+ token.text = code;
872
+ token.escaped = true;
873
+ --pending || done()
874
+ })
875
+ })(tokens[i])
876
+ }
877
+ return
878
+ }
879
+ try {
880
+ if (opt) {
881
+ opt = merge({}, marked.defaults, opt)
882
+ }
883
+ return Parser.parse(Lexer.lex(src, opt), opt)
884
+ } catch (e) {
885
+ e.message += "\nPlease report this to https://github.com/chjj/marked.";
886
+ if ((opt || marked.defaults).silent) {
887
+ return "<p>An error occured:</p><pre>" + escape(e.message + "", true) + "</pre>"
888
+ }
889
+ throw e
890
+ }
891
+ }
892
+ marked.options = marked.setOptions = function (opt) {
893
+ merge(marked.defaults, opt);
894
+ return marked
895
+ };
896
+ marked.defaults = {
897
+ gfm: true,
898
+ tables: true,
899
+ breaks: false,
900
+ pedantic: false,
901
+ sanitize: false,
902
+ sanitizer: null,
903
+ mangle: true,
904
+ smartLists: false,
905
+ silent: false,
906
+ highlight: null,
907
+ langPrefix: "lang-",
908
+ smartypants: false,
909
+ headerPrefix: "",
910
+ renderer: new Renderer,
911
+ xhtml: false
912
+ };
913
+ marked.Parser = Parser;
914
+ marked.parser = Parser.parse;
915
+ marked.Renderer = Renderer;
916
+ marked.Lexer = Lexer;
917
+ marked.lexer = Lexer.lex;
918
+ marked.InlineLexer = InlineLexer;
919
+ marked.inlineLexer = InlineLexer.output;
920
+ marked.parse = marked;
921
+ if (typeof module !== "undefined" && typeof exports === "object") {
922
+ module.exports = marked
923
+ } else {
924
+ if (typeof define === "function" && define.amd) {
925
+ define(function () {
926
+ return marked
927
+ })
928
+ } else {
929
+ this.marked = marked
930
+ }
931
+ }
932
+ }).call(function () {
933
+ return this || (typeof window !== "undefined" ? window : global)
934
+ }());
935
+ </script>
936
+
937
+ <!--chips-->
938
+
939
+ <script>
940
+ Materialize={};Materialize.guid=(function(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return function(){return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}})();(function($){var materialChipsDefaults={data:[],placeholder:"",secondaryPlaceholder:"",autocompleteOptions:{},};$(document).ready(function(){$(document).on("click",".chip .close",function(e){var $chips=$(this).closest(".chips");if($chips.attr("data-initialized")){return}$(this).closest(".chip").remove()})});$.fn.material_chip=function(options){var self=this;this.$el=$(this);this.$document=$(document);this.SELS={CHIPS:".chips",CHIP:".chip",INPUT:"input",DELETE:".material-icons",SELECTED_CHIP:".selected",};if("data"===options){return this.$el.data("chips")}var curr_options=$.extend({},materialChipsDefaults,options);self.hasAutocomplete=!$.isEmptyObject(curr_options.autocompleteOptions.data);this.init=function(){var i=0;var chips;self.$el.each(function(){var $chips=$(this);var chipId=Materialize.guid();self.chipId=chipId;if(!curr_options.data||!(curr_options.data instanceof Array)){curr_options.data=[]}$chips.data("chips",curr_options.data);$chips.attr("data-index",i);$chips.attr("data-initialized",true);if(!$chips.hasClass(self.SELS.CHIPS)){$chips.addClass("chips")}self.chips($chips,chipId);i++})};this.handleEvents=function(){var SELS=self.SELS;self.$document.off("click.chips-focus",SELS.CHIPS).on("click.chips-focus",SELS.CHIPS,function(e){$(e.target).find(SELS.INPUT).focus()});self.$document.off("click.chips-select",SELS.CHIP).on("click.chips-select",SELS.CHIP,function(e){var $chip=$(e.target);if($chip.length){var wasSelected=$chip.hasClass("selected");var $chips=$chip.closest(SELS.CHIPS);$(SELS.CHIP).removeClass("selected");if(!wasSelected){self.selectChip($chip.index(),$chips)}}});self.$document.off("keydown.chips").on("keydown.chips",function(e){if($(e.target).is("input, textarea")){return}var $chip=self.$document.find(SELS.CHIP+SELS.SELECTED_CHIP);var $chips=$chip.closest(SELS.CHIPS);var length=$chip.siblings(SELS.CHIP).length;var index;if(!$chip.length){return}if(e.which===8||e.which===46){e.preventDefault();index=$chip.index();self.deleteChip(index,$chips);var selectIndex=null;if((index+1)<length){selectIndex=index}else{if(index===length||(index+1)===length){selectIndex=length-1}}if(selectIndex<0){selectIndex=null}if(null!==selectIndex){self.selectChip(selectIndex,$chips)}if(!length){$chips.find("input").focus()}}else{if(e.which===37){index=$chip.index()-1;if(index<0){return}$(SELS.CHIP).removeClass("selected");self.selectChip(index,$chips)}else{if(e.which===39){index=$chip.index()+1;$(SELS.CHIP).removeClass("selected");if(index>length){$chips.find("input").focus();return}self.selectChip(index,$chips)}}}});self.$document.off("focusin.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusin.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.addClass("focus");$currChips.siblings("label, .prefix").addClass("active");$(SELS.CHIP).removeClass("selected")});self.$document.off("focusout.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusout.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.removeClass("focus");if($currChips.data("chips")===undefined||!$currChips.data("chips").length){$currChips.siblings("label").removeClass("active")}$currChips.siblings(".prefix").removeClass("active")});self.$document.off("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT).on("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var chipsLength=$chips.children(SELS.CHIP).length;if(13===e.which){if(self.hasAutocomplete&&$chips.find(".autocomplete-content.dropdown-content").length&&$chips.find(".autocomplete-content.dropdown-content").children().length){return}e.preventDefault();self.addChip({tag:$target.val()},$chips);$target.val("");return}if((8===e.keyCode||37===e.keyCode)&&""===$target.val()&&chipsLength){e.preventDefault();self.selectChip(chipsLength-1,$chips);$target.blur();return}});self.$document.off("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE).on("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var $chip=$target.closest(SELS.CHIP);e.stopPropagation();self.deleteChip($chip.index(),$chips);$chips.find("input").focus()})};this.chips=function($chips,chipId){$chips.empty();$chips.data("chips").forEach(function(elem){$chips.append(self.renderChip(elem))});$chips.append($('<input id="'+chipId+'" class="input mdui-textfield-input" placeholder="">'));self.setPlaceholder($chips);var label=$chips.next("label");if(label.length){label.attr("for",chipId);if($chips.data("chips")!==undefined&&$chips.data("chips").length){label.addClass("active")}}var input=$("#"+chipId);if(self.hasAutocomplete){curr_options.autocompleteOptions.onAutocomplete=function(val){self.addChip({tag:val},$chips);input.val("");input.focus()
941
+ };input.autocomplete(curr_options.autocompleteOptions)}};this.renderChip=function(elem){if(!elem.tag){return}var $renderedChip=$('<div class="mdui-chip chip mdui-chip-title"></div>');$renderedChip.text(elem.tag);if(elem.image){$renderedChip.prepend($("<img />").attr("src",elem.image))}$renderedChip.append($('<i class="material-icons mdui-icon close">close</i>'));return $renderedChip};this.setPlaceholder=function($chips){if($chips.data("chips")!==undefined&&$chips.data("chips").length&&curr_options.placeholder){$chips.find("input").prop("placeholder",curr_options.placeholder)}else{if(($chips.data("chips")===undefined||!$chips.data("chips").length)&&curr_options.secondaryPlaceholder){$chips.find("input").prop("placeholder",curr_options.secondaryPlaceholder)}}};this.isValid=function($chips,elem){var chips=$chips.data("chips");var exists=false;for(var i=0;i<chips.length;i++){if(chips[i].tag===elem.tag){exists=true;return}}return""!==elem.tag&&!exists};this.addChip=function(elem,$chips){if(!self.isValid($chips,elem)){return}var $renderedChip=self.renderChip(elem);var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){newData.push(oldData[i])}newData.push(elem);$chips.data("chips",newData);$renderedChip.insertBefore($chips.find("input"));$chips.trigger("chip.add",elem);self.setPlaceholder($chips)};this.deleteChip=function(chipIndex,$chips){var chip=$chips.data("chips")[chipIndex];$chips.find(".chip").eq(chipIndex).remove();var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){if(i!==chipIndex){newData.push(oldData[i])}}$chips.data("chips",newData);$chips.trigger("chip.delete",chip);self.setPlaceholder($chips)};this.selectChip=function(chipIndex,$chips){var $chip=$chips.find(".chip").eq(chipIndex);if($chip&&false===$chip.hasClass("selected")){$chip.addClass("selected");$chips.trigger("chip.select",$chips.data("chips")[chipIndex])}};this.getChipsElement=function(index,$chips){return $chips.eq(index)};this.init();this.handleEvents()}}(jQuery));
942
+ </script>
943
+ <script>
944
+ $(function(){
945
+ $('.chips-initial').material_chip({
946
+ });
947
+ $('.chips-placeholder').material_chip({
948
+ placeholder: 'Enter a tag',
949
+ secondaryPlaceholder: '+Tag',
950
+ });
951
+ /* save */
952
+ function getTags(e){
953
+ var tags = "";
954
+ for (x in e){
955
+ if (e[x] != ""){
956
+ tags += e[x].tag+" ";
957
+ }
958
+ }
959
+ return tags;
960
+ }
961
+ function setTags(e){
962
+ var tags = [];
963
+
964
+ for (x in e){
965
+ if (e[x] != ''){
966
+ tags[x]= {'tag':e[x]};
967
+ }
968
+ }
969
+ return tags;
970
+ }
971
+ function getpost(){
972
+ $('#editorContent').val(localStorage.previewContent);
973
+ $('#editorTitle').val(localStorage.editorTitle);
974
+ $('#editorDate').val(localStorage.editorDate);
975
+ $('#imgurl').val(localStorage.imgurl);
976
+ if (localStorage.categories){
977
+ if (localStorage.categories.indexOf("radio_custom") == -1){
978
+ $("input[value='"+ localStorage.categories +"']").attr('checked','');
979
+ }else{
980
+ $("input[value='radio_custom']").attr('checked','');
981
+ $('#editorCategories').val(localStorage.categories.replace("radio_custom",''));
982
+ }
983
+ }
984
+ if (localStorage.editorChips){
985
+ var data = setTags(localStorage.editorChips.split(' '));
986
+ $('.chips-initial').material_chip({
987
+ data: data,
988
+ });
989
+ }
990
+ }
991
+ getpost();
992
+ function setpost(){
993
+ localStorage.previewContent = $('#editorContent').val();
994
+ localStorage.editorTitle = $('#editorTitle').val();
995
+ localStorage.editorDate = $('#editorDate').val();
996
+ localStorage.imgurl = $('#imgurl').val();
997
+ if ($("input[name='categories']:checked").val() == "radio_custom" ){
998
+ localStorage.categories = $("input[name='categories']:checked").val() + $('#editorCategories').val();
999
+ }else{
1000
+ localStorage.categories = $("input[name='categories']:checked").val();
1001
+ }
1002
+ localStorage.editorChips = getTags($('.chips-initial').material_chip('data'));
1003
+ }
1004
+
1005
+ setInterval(function(){
1006
+ setpost();
1007
+ },5000);
1008
+
1009
+ /*preview*/
1010
+ $("#previewBtn").click(function(){
1011
+ $('#previewContent').html(marked($('#editorContent').val()));
1012
+ $('.mdui-card-primary-title').html($('#editorTitle').val());
1013
+ $('.k-data').html($('#editorDate').val());
1014
+ $('.k-post-media').css('background-image','url('+ $('#imgurl').val() +')');
1015
+ });
1016
+ /*download*/
1017
+ var textFile = null;
1018
+ function makeTextFile(text){
1019
+ var data = new Blob([text], {
1020
+ type: 'text/plain'
1021
+ });
1022
+ if (textFile !== null) {
1023
+ window.URL.revokeObjectURL(textFile);
1024
+ }
1025
+ textFile = window.URL.createObjectURL(data);
1026
+ return textFile;
1027
+ }
1028
+
1029
+ $('#download').click(function(){
1030
+ var filename,filecontent;
1031
+
1032
+ function k_getFiletitle(e){
1033
+ var title = e.toLowerCase().split(" ");
1034
+ var newtitle = "";
1035
+ for (x in title){
1036
+ if (parseInt(x)+1 == title.length){
1037
+ newtitle += title[x];
1038
+ }else{
1039
+ newtitle += title[x]+"-";
1040
+ }
1041
+ }
1042
+ return newtitle;
1043
+ }
1044
+
1045
+ function k_getCategories(e){
1046
+ if (e == "radio_custom" ){
1047
+ return $('#editorCategories').val();
1048
+ }else{
1049
+ return e;
1050
+ }
1051
+ }
1052
+
1053
+ filename = new Date().toLocaleDateString('zh-CN', { hour12: false},'year,month').replace(/\//g,"-") + "-" + k_getFiletitle($('#editorTitle').val()) + ".markdown";
1054
+ filecontent = "---\nlayout: post\ntitle: "+$('#editorTitle').val()+"\ndate: "+$('#editorDate').val()+" "+ new Date().toLocaleTimeString('en-US', { hour12: false }) +" +0800\ncategories: "+k_getCategories($("input[name='categories']:checked").val())+"\ntags: "+getTags($('.chips-initial').material_chip('data'))+"\nimg: "+$('#imgurl').val()+"\n---\n"+$('#editorContent').val();
1055
+ $(this).attr("download",filename);
1056
+ $(this).attr("href",makeTextFile(filecontent));
1057
+ });
1058
+ });
1059
1059
  </script>