##// END OF EJS Templates
More 'proper' way to compare with null
neko259 -
r1019:67e2bbf8 default
parent child Browse files
Show More
@@ -1,93 +1,93 b''
1 /*
1 /*
2 @licstart The following is the entire license notice for the
2 @licstart The following is the entire license notice for the
3 JavaScript code in this page.
3 JavaScript code in this page.
4
4
5
5
6 Copyright (C) 2013 neko259
6 Copyright (C) 2013 neko259
7
7
8 The JavaScript code in this page is free software: you can
8 The JavaScript code in this page is free software: you can
9 redistribute it and/or modify it under the terms of the GNU
9 redistribute it and/or modify it under the terms of the GNU
10 General Public License (GNU GPL) as published by the Free Software
10 General Public License (GNU GPL) as published by the Free Software
11 Foundation, either version 3 of the License, or (at your option)
11 Foundation, either version 3 of the License, or (at your option)
12 any later version. The code is distributed WITHOUT ANY WARRANTY;
12 any later version. The code is distributed WITHOUT ANY WARRANTY;
13 without even the implied warranty of MERCHANTABILITY or FITNESS
13 without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
14 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
15
15
16 As additional permission under GNU GPL version 3 section 7, you
16 As additional permission under GNU GPL version 3 section 7, you
17 may distribute non-source (e.g., minimized or compacted) forms of
17 may distribute non-source (e.g., minimized or compacted) forms of
18 that code without the copy of the GNU GPL normally required by
18 that code without the copy of the GNU GPL normally required by
19 section 4, provided you include this license notice and a URL
19 section 4, provided you include this license notice and a URL
20 through which recipients can access the Corresponding Source.
20 through which recipients can access the Corresponding Source.
21
21
22 @licend The above is the entire license notice
22 @licend The above is the entire license notice
23 for the JavaScript code in this page.
23 for the JavaScript code in this page.
24 */
24 */
25
25
26 var LOCALE = window.navigator.language;
26 var LOCALE = window.navigator.language;
27 var FORMATTER = new Intl.DateTimeFormat(
27 var FORMATTER = new Intl.DateTimeFormat(
28 LOCALE,
28 LOCALE,
29 {
29 {
30 weekday: 'short', year: 'numeric', month: 'short', day: 'numeric',
30 weekday: 'short', year: 'numeric', month: 'short', day: 'numeric',
31 hour: 'numeric', minute: '2-digit', second: '2-digit'
31 hour: 'numeric', minute: '2-digit', second: '2-digit'
32 }
32 }
33 );
33 );
34
34
35 /**
35 /**
36 * An email is a hidden file to prevent spam bots from posting. It has to be
36 * An email is a hidden file to prevent spam bots from posting. It has to be
37 * hidden.
37 * hidden.
38 */
38 */
39 function hideEmailFromForm() {
39 function hideEmailFromForm() {
40 $('.form-email').parent().parent().hide();
40 $('.form-email').parent().parent().hide();
41 }
41 }
42
42
43 /**
43 /**
44 * Highlight code blocks with code highlighter
44 * Highlight code blocks with code highlighter
45 */
45 */
46 function highlightCode(node) {
46 function highlightCode(node) {
47 node.find('pre code').each(function(i, e) {
47 node.find('pre code').each(function(i, e) {
48 hljs.highlightBlock(e);
48 hljs.highlightBlock(e);
49 });
49 });
50 }
50 }
51
51
52 /**
52 /**
53 * Translate timestamps to local ones for all <time> tags inside node.
53 * Translate timestamps to local ones for all <time> tags inside node.
54 */
54 */
55 function translate_time(node) {
55 function translate_time(node) {
56 var elements;
56 var elements;
57
57
58 if (node == null) {
58 if (node === null) {
59 elements = $('time');
59 elements = $('time');
60 } else {
60 } else {
61 elements = node.find('time');
61 elements = node.find('time');
62 }
62 }
63
63
64 if (!elements.length) {
64 if (!elements.length) {
65 return;
65 return;
66 }
66 }
67
67
68 elements.each(function() {
68 elements.each(function() {
69 var element = $(this);
69 var element = $(this);
70 var dateAttr = element.attr('datetime');
70 var dateAttr = element.attr('datetime');
71 if (dateAttr) {
71 if (dateAttr) {
72 var date = new Date(dateAttr);
72 var date = new Date(dateAttr);
73 element.text(FORMATTER.format(date));
73 element.text(FORMATTER.format(date));
74 }
74 }
75 });
75 });
76 }
76 }
77
77
78 $( document ).ready(function() {
78 $( document ).ready(function() {
79 hideEmailFromForm();
79 hideEmailFromForm();
80
80
81 $("a[href='#top']").click(function() {
81 $("a[href='#top']").click(function() {
82 $("html, body").animate({ scrollTop: 0 }, "slow");
82 $("html, body").animate({ scrollTop: 0 }, "slow");
83 return false;
83 return false;
84 });
84 });
85
85
86 addImgPreview();
86 addImgPreview();
87
87
88 addRefLinkPreview();
88 addRefLinkPreview();
89
89
90 highlightCode($(document));
90 highlightCode($(document));
91
91
92 translate_time(null);
92 translate_time(null);
93 });
93 });
General Comments 0
You need to be logged in to leave comments. Login now