PageSourceSearch

https://www.scientology.cc/plugins/calendar-widget.js?_=

js scientology.cc collected 2026-09-24 23:37:31 UTC 9,792 bytes, 338 lines download raw bytes

1!function() {
2
3  var today = moment();
4
5  function Calendar(selector, events) {
6    this.el = document.querySelector(selector);
7    this.events = events;
8    this.current = moment().date(1);
9    this.draw();
10    var current = document.querySelector('.today');
11    if(current) {
12      var self = this;
13      window.setTimeout(function() {
14        self.openDay(current);
15      }, 500);
16    }
17  }
18
19  Calendar.prototype.draw = function() {
20    //Create Header
21    this.drawHeader();
22
23    //Draw Month
24    this.drawMonth();
25
26    // this.drawLegend();
27  }
28
29  Calendar.prototype.drawHeader = function() {
30    var self = this;
31    if(!this.header) {
32      //Create the header elements
33      this.header = createElement('div', 'header');
34      this.header.className = 'header';
35
36      this.title = createElement('div');
37      this.title.className = 'calendar-widget--title';
38
39      this.headerArrows = createElement('div', 'calendar-widget--header-arrows');
40
41      var right = createElement('div', 'right');
42      right.addEventListener('click', function() { self.nextMonth(); });
43
44      var left = createElement('div', 'left');
45      left.addEventListener('click', function() { self.prevMonth(); });
46
47      //Append the Elements
48      this.header.appendChild(this.title); 
49      this.headerArrows.appendChild(left);
50      this.headerArrows.appendChild(right);
51      this.header.appendChild(this.headerArrows);
52      this.el.appendChild(this.header);
53    }
54
55    this.title.innerHTML = this.current.format('MMMM YYYY');
56  }
57
58  Calendar.prototype.drawMonth = function() {
59    var self = this;
60    self.daysDraws = 0;
61    
62    this.events.forEach(function(ev) {
63      if(!ev.date) {
64        ev.date = self.current.clone().date(Math.random() * (29 - 1) + 1);
65      }
66    });
67    
68    
69    if(this.month) {
70      this.oldMonth = this.month;
71      this.oldMonth.className = 'month out ' + (self.next ? 'next' : 'prev');
72      this.oldMonth.addEventListener('webkitAnimationEnd', function() {
73        self.oldMonth.parentNode.removeChild(self.oldMonth);
74        self.month = createElement('div', 'month');
75        self.backFill();
76        self.currentMonth();
77        self.fowardFill();
78        self.el.appendChild(self.month);
79        window.setTimeout(function() {
80          self.month.className = 'month in ' + (self.next ? 'next' : 'prev');
81        }, 16);
82      });
83    } else {
84        this.month = createElement('div', 'month');
85        this.el.appendChild(this.month);
86        this.backFill();
87        this.currentMonth();
88        this.fowardFill();
89        this.month.className = 'month new';
90    }
91  }
92
93  Calendar.prototype.backFill = function() {
94    var clone = this.current.clone();
95    var dayOfWeek = clone.day();
96
97    if(!dayOfWeek) { return; }
98
99    clone.subtract('days', dayOfWeek+1);
100
101    for(var i = dayOfWeek; i > 0 ; i--) {
102      this.drawDay(clone.add('days', 1));
103    }
104  }
105
106  Calendar.prototype.fowardFill = function() {
107    var clone = this.current.clone().add('months', 1).subtract('days', 1);
108    var dayOfWeek = clone.day();
109
110    if(dayOfWeek === 6) { return; }
111
112    for(var i = dayOfWeek; i < 6 ; i++) {
113      this.drawDay(clone.add('days', 1));
114    }
115  }
116
117  Calendar.prototype.currentMonth = function() {
118    var clone = this.current.clone();
119    var self = this;
120
121    while(clone.month() === this.current.month()) {
122      this.drawDay(clone);
123      clone.add('days', 1);
124    }
125  }
126
127  Calendar.prototype.getWeek = function(day) {
128    if(!this.week || day.day() === 0) {
129      this.week = createElement('div', 'week');
130      this.month.appendChild(this.week);
131    }
132  }
133
134  Calendar.prototype.drawDay = function(day) {
135    var self = this;
136    this.getWeek(day);
137
138    //Outer Day
139    var outer = createElement('div', this.getDayClass(day));
140    outer.setAttribute('data-unix', day.unix() * 1000);
141    outer.addEventListener('click', function() {
142      self.openDay(this);
143    });
144
145    //Day Name
146    var name = createElement('div', 'day-name', day.format('ddd'));
147
148    //Day Number
149    var number = createElement('div', 'day-number', day.format('DD'));
150
151
152    //Events
153    var events = createElement('div', 'day-events');
154    this.drawEvents(day, events);
155
156    // show days of the week only on the 1st line
157    if(this.daysDraws < 7) {
158      outer.appendChild(name);
159    }
160    outer.appendChild(number);
161    outer.appendChild(events);
162    this.week.appendChild(outer);
163    this.daysDraws ++ ;
164  }
165
166  Calendar.prototype.drawEvents = function(day, element) {
167    // if(day.month() === this.current.month()) {
168      var todaysEvents = this.events.reduce(function(memo, ev) {
169        if(ev.date.isSame(day, 'day')) {
170          memo.push(ev);
171        }
172        return memo;
173      }, []);
174
175      todaysEvents.forEach(function(ev) {
176        var evSpan = createElement('span', ev.color);
177        element.appendChild(evSpan);
178      });
179    // }
180  }
181
182  Calendar.prototype.getDayClass = function(day) {
183    classes = ['day'];
184    if(day.month() !== this.current.month()) {
185      classes.push('other');
186    } else if (today.isSame(day, 'day')) {
187      classes.push('today');
188    }
189    return classes.join(' ');
190  }
191
192  Calendar.prototype.openDay = function(el) {
193    $(this.el).find('.calendar-opened-day').removeClass('calendar-opened-day');
194    el.classList += " calendar-opened-day";
195    var details, arrow;
196    var day = moment(parseInt(el.getAttribute('data-unix')));
197
198    var currentOpened = document.querySelector('.details');
199
200    //Check to see if there is an open detais box on the current row
201    if(currentOpened && currentOpened.parentNode === el.parentNode) {
202      details = currentOpened;
203      arrow = document.querySelector('.arrow');
204    } else {
205      //Close the open events on differnt week row
206      //currentOpened && currentOpened.parentNode.removeChild(currentOpened);
207      if(currentOpened) {
208        currentOpened.addEventListener('webkitAnimationEnd', function() {
209          currentOpened.parentNode.removeChild(currentOpened);
210        });
211        currentOpened.addEventListener('oanimationend', function() {
212          currentOpened.parentNode.removeChild(currentOpened);
213        });
214        currentOpened.addEventListener('msAnimationEnd', function() {
215          currentOpened.parentNode.removeChild(currentOpened);
216        });
217        currentOpened.addEventListener('animationend', function() {
218          currentOpened.parentNode.removeChild(currentOpened);
219        });
220        currentOpened.className = 'details out';
221      }
222
223      //Create the Details Container
224      details = createElement('div', 'details in');
225
226      //Create the arrow
227      var arrow = createElement('div', 'arrow');
228
229      //Create the event wrapper
230
231      details.appendChild(arrow);
232      el.parentNode.appendChild(details);
233    }
234
235    var todaysEvents = this.events.reduce(function(memo, ev) {
236      if(ev.date.isSame(day, 'day')) {
237        memo.push(ev);
238      }
239      return memo;
240    }, []);
241
242
243    this.renderEvents(todaysEvents, details);
244
245    arrow.style.left = el.offsetLeft - el.parentNode.offsetLeft + el.clientWidth * 0.5  - 3 + 'px';
246  }
247
248  Calendar.prototype.renderEvents = function(events, ele) {
249    //Remove any events in the current details element
250    var currentWrapper = ele.querySelector('.events');
251    var wrapper = createElement('div', 'events in' + (currentWrapper ? ' new' : ''));
252
253    events.forEach(function(ev) {
254      var div = createElement('div', 'event');
255      // var square = createElement('div', 'event-category ' + ev.color);
256      var span = createElement('a', 'event-title', ev.eventName);
257      if(ev.href) {
258        span.href = ev.href;
259      }
260
261      // div.appendChild(square);
262      div.appendChild(span);
263      wrapper.appendChild(div);
264    });
265
266    if(!events.length) {
267      var div = createElement('div', 'event empty');
268      var span = createElement('span', '', 'No Events');
269
270      div.appendChild(span);
271      wrapper.appendChild(div);
272    }
273
274    if(currentWrapper) {
275      currentWrapper.className = 'events out';
276      currentWrapper.addEventListener('webkitAnimationEnd', function() {
277        currentWrapper.parentNode.removeChild(currentWrapper);
278        ele.appendChild(wrapper);
279      });
280      currentWrapper.addEventListener('oanimationend', function() {
281        currentWrapper.parentNode.removeChild(currentWrapper);
282        ele.appendChild(wrapper);
283      });
284      currentWrapper.addEventListener('msAnimationEnd', function() {
285        currentWrapper.parentNode.removeChild(currentWrapper);
286        ele.appendChild(wrapper);
287      });
288      currentWrapper.addEventListener('animationend', function() {
289        currentWrapper.parentNode.removeChild(currentWrapper);
290        ele.appendChild(wrapper);
291      });
292    } else {
293      ele.appendChild(wrapper);
294    }
295  }
296
297  Calendar.prototype.drawLegend = function() {
298    var legend = createElement('div', 'legend');
299    var calendars = this.events.map(function(e) {
300      return e.calendar + '|' + e.color;
301    }).reduce(function(memo, e) {
302      if(memo.indexOf(e) === -1) {
303        memo.push(e);
304      }
305      return memo;
306    }
306, []).forEach(function(e) {
307      var parts = e.split('|');
308      var entry = createElement('span', 'entry ' +  parts[1], parts[0]);
309      legend.appendChild(entry);
310    });
311    this.el.appendChild(legend);
312  }
313
314  Calendar.prototype.nextMonth = function() {
315    this.current.add('months', 1);
316    this.next = true;
317    this.draw();
318  }
319
320  Calendar.prototype.prevMonth = function() {
321    this.current.subtract('months', 1);
322    this.next = false;
323    this.draw();
324  }
325
326  window.Calendar = Calendar;
327
328  function createElement(tagName, className, innerText) {
329    var ele = document.createElement(tagName);
330    if(className) {
331      ele.className = className;
332    }
333    if(innerText) {
334      ele.innerHTML = innerText;
335    }
336    return ele;
337  }
338}();

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.