PageSourceSearch

https://momentjs.com/static/js/core-home.js?v=33e61d307837

js momentjs.com collected 2026-10-01 06:57:20 UTC 2,606 bytes, 115 lines download raw bytes

1(function () {
2  var currentLang = "en",
3    snippets = [];
4
5  function createSnippets() {
6    var i;
7
8    moment.locale(currentLang);
9
10    for (i = 0; i < snippets.length; i++) {
11      snippets[i].render();
12    }
13  }
14
15  function updateSnippets() {
16    var i;
17
18    moment.locale(currentLang);
19
20    for (i = 0; i < snippets.length; i++) {
21      snippets[i].update();
22    }
23  }
24
25  function updateClock() {
26    var now = moment(),
27      second = now.seconds() * 6,
28      minute = now.minutes() * 6 + second / 60,
29      hour = ((now.hours() % 12) / 12) * 360 + 90 + minute / 12;
30
31    $("#hour").css("transform", "rotate(" + hour + "deg)");
32    $("#minute").css("transform", "rotate(" + minute + "deg)");
33    $("#second").css("transform", "rotate(" + second + "deg)");
34  }
35
36  function spaces(length) {
37    var out = "";
38    while (out.length < length) {
39      out += " ";
40    }
41    return out;
42  }
43
44  function Snippet(el) {
45    var longest = 0,
46      i,
47      text = (this.text = el.text().trim().split("\n")),
48      html = (this.html = el.html().trim().split("\n")),
49      evals = (this.evals = []);
50
51    this.el = el;
52
53    for (i = 0; i < text.length; i++) {
54      longest = Math.max(text[i].length, longest);
55      evals[i] = new Function("return " + text[i]);
56    }
57
58    for (i = 0; i < text.length; i++) {
59      html[i] += spaces(longest - text[i].length);
60    }
61  }
62
63  Snippet.prototype.render = function () {
64    var output = [],
65      i;
66
67    for (i = 0; i < this.html.length; i++) {
68      output[i] = this.html[i];
69      output[i] += '<span class="comment"> // ';
70      output[i] += this.evals[i]();
71      output[i] += "</span>";
72    }
73
74    this.el.html(output.join("\n"));
75  };
76
77  Snippet.prototype.update = function () {
78    var i,
79      comments = [];
80
81    if (!this.comments) {
82      for (i = 0; i < this.el[0].childNodes.length; i++) {
83        if ("comment" === this.el[0].childNodes[i].className) {
84          comments.push($(this.el[0].childNodes[i]));
85        }
86      }
87      this.comments = comments;
88    }
89
90    for (i = 0; i < this.comments.length; i++) {
91      this.comments[i].text(" // " + this.evals[i]());
92    }
93  };
94
95  function timedUpdate() {
96    updateClock();
97    updateSnippets();
98    setTimeout(timedUpdate, 1000);
99  }
100
101  $(".page-moment-index code").each(function () {
102    snippets.push(new Snippet($(this)));
103  });
104
105  createSnippets();
106  timedUpdate();
107
108  $(document).on("click", "[data-locale]", function () {
109    var dom = $(this);
110    currentLang = dom.data("locale");
111    $("[data-locale]").removeClass("active");
112    dom.addClass("active");
113    updateSnippets();
114  });
115})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.