jekyll-zeta 0.10.4 → 0.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,490 @@
1
+ ;function createSVGMap (endYmd,dateBeginYmd,monStr,weekStr,WeekStart_) {
2
+ const monthArr = monStr.split(" "); // Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
3
+ const weekarr = weekStr.split(" "); // Sun Mon Tue Wed Thu Fri Sat
4
+ const WeekStart = WeekStart_ || 0; // 0 sunday
5
+
6
+ if (!endYmd) {
7
+ endYmd = `${new Date().getFullYear()}-12-31`;
8
+ }
9
+ else if(endYmd.length == 4){
10
+ endYmd = `${endYmd}-12-31`;
11
+ }
12
+ let dateEnd = new Date(date2ymd(new Date(endYmd)));
13
+ let dateBegin = dateBeginYmd ? new Date(date2ymd(new Date(dateBeginYmd))) : dateBeginYmd
14
+
15
+ const colorInit = '#eef7f2'
16
+
17
+
18
+ const namespaceURI = "http://www.w3.org/2000/svg";
19
+ const dayStartX = 35;
20
+ const dayStartY = 30;
21
+ const dayW = 12;
22
+ const dayH = 12;
23
+ const dayGap = 2;
24
+
25
+ const WeekCount = 53;
26
+
27
+
28
+ const mapW = dayStartX + (dayGap + dayW) * WeekCount + 10;
29
+ const mapH = dayStartY + (dayGap + dayH) * 7 + 20
30
+
31
+ const mapId = "MP-" + Math.random().toString(16).substring(2);
32
+ const daysId = mapId + "days";
33
+ const tipId = mapId + "tip";
34
+
35
+
36
+ const endDateDay = dateEnd.getDay();
37
+ const endStamp = dateEnd.getTime();
38
+ const DayCount = (WeekCount - 1) * 7 + ((7 + endDateDay - WeekStart) % 7);
39
+ var minYmd = getPreYearYmd(endStamp);
40
+
41
+ const MinYmdIdx =
42
+ DayCount - Math.floor((endStamp - new Date(minYmd)) / (24 * 3600000)) + 1;
43
+
44
+
45
+
46
+ const TodayIdx =
47
+ DayCount - Math.floor((endStamp - new Date(date2ymd(new Date))) / (24 * 3600000));
48
+
49
+
50
+ const beginIdx = !dateBegin ? -1 : DayCount - Math.floor((endStamp - dateBegin.getTime()) / (24 * 3600000));
51
+
52
+ function getPreYearYmd(stamp) {
53
+ const t = new Date(stamp);
54
+ let y = t.getFullYear() - 1;
55
+ let m = t.getMonth() + 1;
56
+ let d = t.getDate();
57
+ let ymd = `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d}`;
58
+ return ymd;
59
+ }
60
+
61
+ function idx2Ymd(idx) {
62
+ let t = new Date(endStamp - (DayCount - idx) * 3600000 * 24);
63
+ return date2ymd(t);
64
+ }
65
+ function date2ymd(t) {
66
+ let m = t.getMonth() + 1;
67
+ let d = t.getDate();
68
+ return `${t.getFullYear()}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d}`;
69
+ }
70
+
71
+ function createDayItem(idx) {
72
+ // if (idx < MinYmdIdx || idx > DayCount) {
73
+ // return
74
+ // }
75
+
76
+ const rc = document.createElementNS(namespaceURI, "rect");
77
+ rc.setAttribute("width", "" + dayW);
78
+ rc.setAttribute("height", "" + dayH);
79
+ rc.setAttribute("rx", "1");
80
+ rc.setAttribute("ry", "1");
81
+
82
+ rc.setAttribute("fill", colorInit);
83
+ const c = Math.floor(idx / 7);
84
+ const r = idx - c * 7;
85
+
86
+ const x = c * dayW + c * dayGap;
87
+ const y = r * dayH + r * dayGap;
88
+
89
+ rc.setAttribute("x", "" + x);
90
+ rc.setAttribute("y", "" + y);
91
+ rc.dataset.x = x
92
+ rc.dataset.y = y
93
+
94
+ let ymd = idx2Ymd(idx);
95
+ rc.dataset.ymd = ymd;
96
+ rc.id = "day-item-" + ymd;
97
+
98
+ let m = ymd.substring(5, 7);
99
+ let d = ymd.substring(8, 10);
100
+
101
+ if (d <= "07" && idx % 7 == 0) {
102
+ // showMonth
103
+ let mon = monthArr[Number(m) - 1];
104
+ let mEle = document.createElementNS(namespaceURI, "text");
105
+ mEle.setAttribute("y", `${dayStartY - 8}`);
106
+ mEle.setAttribute("x", x);
107
+ mEle.textContent = mon;
108
+ mEle.setAttribute("fill", idx > TodayIdx ? "#878787" : "#113");
109
+ mEle.setAttribute("font-size", "13");
110
+ mEle.setAttribute("font-family", "monospace");
111
+ // mEle.setAttribute('stroke','# f00')
112
+ // mEle.setAttribute('stroke-width','1')
113
+ monthG.appendChild(mEle);
114
+ }
115
+
116
+ return rc;
117
+ }
118
+
119
+ function updateDays(dataMap) {
120
+ const color = dataMap.color || '#40c463'
121
+
122
+
123
+ const t2 = document.createElementNS(namespaceURI,'tspan')
124
+ t2.setAttribute('font-size','12')
125
+ t2.setAttribute('dy','0')
126
+ t2.setAttribute('dx','10')
127
+ t2.setAttribute('fill','#888888')
128
+ t2.setAttribute('font-family','courier')
129
+ t2.textContent = '';
130
+ tilteE.append(t2)
131
+
132
+
133
+ let countOfItem = 0
134
+
135
+ function shuffle(array) {
136
+ let currentIndex = array.length;
137
+
138
+ // While there remain elements to shuffle...
139
+ while (currentIndex != 0) {
140
+ // Pick a remaining element...
141
+ let randomIndex = Math.floor(Math.random() * currentIndex);
142
+ currentIndex--;
143
+
144
+ // And swap it with the current element.
145
+ [array[currentIndex], array[randomIndex]] = [
146
+ array[randomIndex],
147
+ array[currentIndex],
148
+ ];
149
+ }
150
+ }
151
+
152
+ let daysHoder = groupDay;
153
+ let arrNodes = daysHoder.childNodes;
154
+ let count = WeekCount * 7;
155
+ let arrUpdates = new Array(count);
156
+ for (let i = 0; i < count; i++) {
157
+ arrUpdates[i] = i;
158
+ }
159
+ shuffle(arrUpdates);
160
+
161
+ function getDayDataCount(idx, ymd) {
162
+ let y = ymd.substring(0,4)
163
+ let m = ymd.substring(5,7)
164
+ let yObj = dataMap[y]
165
+ if (yObj && yObj[m]) {
166
+ let arr = yObj[m]
167
+ let r = arr.filter(e=>e.date == ymd)
168
+ return r && r.length ? r : null
169
+ }
170
+
171
+ return null;
172
+ }
173
+
174
+ function updateDay1(idx) {
175
+ let node = arrNodes[idx];
176
+ if (node) {
177
+ if (idx < MinYmdIdx || idx > DayCount) {
178
+ node.setAttribute("display", "none");
179
+ return;
180
+ }
181
+
182
+
183
+
184
+ let ymd = node.dataset.ymd;
185
+ let m = ymd.substring(5, 7);
186
+ let isOdd = Number(m) % 2;
187
+
188
+
189
+ let arrData = getDayDataCount(idx, node.dataset.ymd);
190
+ if(arrData && arrData.length){
191
+ countOfItem += arrData.length;
192
+ t2.textContent = `x ${countOfItem}`
193
+ }
194
+ if (!arrData && (idx > TodayIdx || idx < beginIdx)) {
195
+ node.setAttribute("fill", isOdd ? "url(#fillB)" : "url(#fillA)");
196
+
197
+
198
+ node.onmouseenter = function () {
199
+ node.setAttribute('stroke','#000000')
200
+ node.setAttribute('stroke-width','1')
201
+ showTip(node, idx, arrData);
202
+ };
203
+ node.onclick = node.onmouseenter
204
+ node.onmouseleave = function () {
205
+ node.setAttribute('stroke','')
206
+ node.setAttribute('stroke-width','')
207
+ showTip(node, -1);
208
+ };
209
+
210
+ return;
211
+ }
212
+
213
+
214
+
215
+
216
+ const c = arrData && arrData.length;
217
+ let colorSet = color
218
+ if (c) {
219
+ let customColor = arrData.find(e=>e.color)
220
+ if(customColor ){
221
+ colorSet = customColor.color
222
+ }
223
+
224
+ node.setAttribute("class", "svg-day-1");
225
+ node.setAttribute(
226
+ "fill",
227
+ c == 1
228
+ ? colorSet + "77"
229
+ : c == 2
230
+ ? colorSet + "aa"
231
+ : colorSet + "ff"
232
+ );
233
+
234
+ node.onmouseenter = function () {
235
+ node.setAttribute('stroke','#000000')
236
+ node.setAttribute('stroke-width','1')
237
+ showTip(node, idx, arrData);
238
+ };
239
+ node.onclick = node.onmouseenter
240
+ node.onmouseleave = function () {
241
+ node.setAttribute('stroke','')
242
+ node.setAttribute('stroke-width','')
243
+ showTip(node, -1);
244
+ };
245
+ } else {
246
+
247
+
248
+ node.onmouseenter = function () {
249
+ node.setAttribute('stroke','#000000')
250
+ node.setAttribute('stroke-width','1')
251
+ showTip(node, idx, arrData);
252
+ };
253
+ node.onclick = node.onmouseenter
254
+ node.onmouseleave = function () {
255
+ node.setAttribute('stroke','')
256
+ node.setAttribute('stroke-width','')
257
+ showTip(node, -1);
258
+ };
259
+
260
+ let ymd = node.dataset.ymd;
261
+ if (ymd) {
262
+ let m = ymd.substring(5, 7);
263
+ let isOdd = Number(m) % 2;
264
+ node.setAttribute("fill", isOdd ? "#edebf0" : "#edebf0aa");
265
+ } else {
266
+ node.setAttribute("fill", "#efefef");
267
+ }
268
+ }
269
+ }
270
+ }
271
+
272
+ var startIdx = 0;
273
+ function updateMultiDays() {
274
+ if (startIdx < arrUpdates.length) {
275
+ const C = 19;
276
+ var i = 0;
277
+ while (i++ < C) {
278
+ if (startIdx >= arrUpdates.length) return;
279
+ updateDay1(arrUpdates[startIdx++]);
280
+ }
281
+
282
+ requestAnimationFrame(updateMultiDays);
283
+ }
284
+ }
285
+ updateMultiDays();
286
+ }
287
+
288
+ // 创建 <svg> 根元素
289
+ const svg = document.createElementNS(namespaceURI, "svg");
290
+ svg.id = mapId;
291
+ svg.setAttribute("width", "" + mapW);
292
+ svg.setAttribute("height", "" + mapH);
293
+
294
+ // svg.style.backgroundColor = "#fffff0";
295
+ svg.style.overflow = "visible";
296
+
297
+
298
+ let defsObj = document.createElementNS(namespaceURI, "defs");
299
+ defsObj.innerHTML = `
300
+ <pattern id="fillA" patternUnits="userSpaceOnUse" width="${3}" height="${3}">
301
+ <path d="M 0 0 L 6 6" stroke="#ccc" stroke-width="1"/>
302
+ </pattern>
303
+
304
+ <pattern id="fillB" patternUnits="userSpaceOnUse" width="${6}" height="${6}">
305
+ <path d="M 0 6 L 6 0" stroke="#bbb" stroke-width="1"/>
306
+ </pattern>
307
+ `;
308
+
309
+ svg.appendChild(defsObj);
310
+
311
+ const monthG = document.createElementNS(namespaceURI, "g");
312
+ monthG.setAttribute("transform", `translate(${dayStartX}, ${0})`);
313
+ svg.appendChild(monthG);
314
+
315
+ const weekG = document.createElementNS(namespaceURI, "g");
316
+ weekG.setAttribute("transform", `translate(${0}, ${dayStartY})`);
317
+ svg.appendChild(weekG);
318
+ function createWeek(str, pos) {
319
+ let w2 = document.createElementNS(namespaceURI, "text");
320
+ w2.textContent = str;
321
+ w2.setAttribute("font-family", "monospace");
322
+ w2.setAttribute("font-size", "13");
323
+ w2.setAttribute("fill", "#333");
324
+ // w2.setAttribute('text-anchor','end')
325
+ w2.setAttribute("width", "" + (dayStartX + 10));
326
+ w2.setAttribute("height", "" + dayH);
327
+ w2.setAttribute("x", "5");
328
+ const y = pos * (dayH + dayGap) + 10;
329
+ w2.setAttribute("y", "" + y);
330
+
331
+ weekG.appendChild(w2);
332
+ return w2;
333
+ }
334
+
335
+ createWeek(weekarr[(WeekStart + 1) % 7], 1);
336
+ createWeek(weekarr[(WeekStart + 3) % 7], 3);
337
+ createWeek(weekarr[(WeekStart + 5) % 7], 5);
338
+
339
+ // 创建一个 <rect> 元素(矩形)
340
+ const groupDay = document.createElementNS(namespaceURI, "g");
341
+ groupDay.id = daysId;
342
+ groupDay.setAttribute("transform", `translate(${dayStartX}, ${dayStartY})`);
343
+
344
+ svg.appendChild(groupDay);
345
+
346
+ const fragment = document.createDocumentFragment();
347
+
348
+ const count = 7 * 53;
349
+ for (let i = 0; i < count; i++) {
350
+ const rc = createDayItem(i);
351
+ if (rc) {
352
+ fragment.appendChild(rc);
353
+ }
354
+ }
355
+
356
+
357
+
358
+ groupDay.appendChild(fragment);
359
+
360
+ const tilteE = document.createElementNS(namespaceURI, "text");
361
+ tilteE.setAttribute("y", `${dayStartY + (dayGap + dayH) * 7 + 10 } `);
362
+ tilteE.setAttribute("x", `${mapW - 10}` );
363
+
364
+ tilteE.setAttribute("fill", '#999999');
365
+ tilteE.setAttribute("font-size", "15");
366
+ // tilteE.setAttribute("font-weight", "medium");
367
+ tilteE.setAttribute("font-family", "monospace");
368
+ tilteE.setAttribute('text-anchor','end')
369
+ tilteE.setAttribute('dominant-baseline','middle')
370
+ svg.appendChild(tilteE)
371
+
372
+
373
+ const beginYmd = idx2Ymd(MinYmdIdx)
374
+ if (beginYmd.substring(0,4) == endYmd.substring(0,4)) {
375
+ tilteE.textContent = beginYmd.substring(0,4)
376
+ }else{
377
+ tilteE.textContent = ` ~ ${endYmd}`
378
+ }
379
+
380
+
381
+
382
+
383
+
384
+ const tipG = document.createElementNS(namespaceURI, "g");
385
+ tipG.id = tipId;
386
+ svg.appendChild(tipG);
387
+
388
+ var tipState = {
389
+ showFlag: 0,
390
+ idx: -1,
391
+ };
392
+ function showTip(dayNode, dayidx, items) {
393
+ if (dayidx < 0 ) {
394
+ tipState.showFlag = 0;
395
+ setTimeout(() => {
396
+ if (tipState.showFlag == 0) {
397
+ tipG.style.display = 'none'
398
+ }
399
+ }, 50);
400
+
401
+ return;
402
+ }
403
+
404
+ if (tipState.showFlag == 2) {
405
+ return;
406
+ }
407
+
408
+ tipState.showFlag = 1;
409
+ tipState.idx = dayidx;
410
+ tipG.innerHTML = ''
411
+ tipG.style.display = 'block'
412
+
413
+ const isEmpy = items ? 0 : 1
414
+ if(!items){
415
+ items = [{date:dayNode.dataset.ymd}]
416
+ }
417
+
418
+ tipG.setAttribute("class", "svg-hm-day-tip");
419
+ var width = "200";
420
+ const count = items.length
421
+ const vSpace = 10;
422
+ const lineH = 25;
423
+ const height = vSpace * 2 + lineH * count + "";
424
+
425
+
426
+ const frag = document.createDocumentFragment();
427
+ let rcbg = document.createElementNS(namespaceURI, "rect");
428
+ rcbg.setAttribute("fill", "#333333cc");
429
+
430
+ rcbg.setAttribute("height", height);
431
+ rcbg.setAttribute("rx", "5");
432
+ rcbg.setAttribute("ry", "5");
433
+ frag.append(rcbg);
434
+
435
+ tipG.onmouseenter = function () {
436
+ if(isEmpy)return
437
+ tipState.showFlag = 2;
438
+ };
439
+
440
+ tipG.onmouseleave = function () {
441
+ tipState.showFlag = 0;
442
+ tipG.style.display = 'none'
443
+ };
444
+ let txtLen = 0
445
+ items.forEach((e, i) => {
446
+ let m = e.date.substring(5,7)
447
+ let d = e.date.substring(8,10)
448
+ m = m.startsWith('0') ? m.substring(1):m
449
+ d = d.startsWith('0') ? d.substring(1):d
450
+ const txt = `${m}-${d} ${e.title || ""}`;
451
+ if(txt.length > txtLen){
452
+ txtLen = txt.length
453
+ }
454
+ const txtE = document.createElementNS(namespaceURI, "text");
455
+ txtE.textContent = txt;
456
+ txtE.setAttribute("fill", "#fff");
457
+ txtE.setAttribute("font-size", "16");
458
+ txtE.setAttribute("font-family", "monospace");
459
+ txtE.setAttribute("x", "10");
460
+ if (e.url) {
461
+ const xlinkNS = "http://www.w3.org/1999/xlink";
462
+ const a = document.createElementNS(namespaceURI, "a");
463
+ a.setAttributeNS(xlinkNS, "xlink:href", e.url);
464
+ a.setAttribute("target", "_blank");
465
+ txtE.setAttribute("y", "" + (vSpace + i * lineH + 18));
466
+
467
+ a.appendChild(txtE);
468
+ frag.appendChild(a);
469
+ } else {
470
+ txtE.setAttribute("y", "" + (vSpace + i * lineH + 15));
471
+ frag.appendChild(txtE);
472
+ }
473
+ });
474
+
475
+ width = txtLen * 14.55 + 25
476
+
477
+ rcbg.setAttribute("width", width);
478
+ tipG.appendChild(frag);
479
+
480
+ const row = dayidx % 7;
481
+ const column = (dayidx - row) / 7;
482
+ const x = dayStartX + column * (dayGap + dayW) + dayW / 2 - width / 2;
483
+ const y = dayStartY + row * (dayGap + dayH) - height - dayGap;
484
+
485
+ tipG.setAttribute("transform", `translate(${x}, ${y})`);
486
+ }
487
+
488
+ return {svg,updateDays}
489
+ }
490
+
@@ -0,0 +1,11 @@
1
+ {
2
+ "compress": {
3
+ "pure_funcs": ["console.log"]
4
+ },
5
+ "mangle": true,
6
+ "output": {
7
+ "max_line_len": 200
8
+ }
9
+
10
+ }
11
+
@@ -94,8 +94,12 @@
94
94
  endYear = '' + endYear + '-12-31'
95
95
  }
96
96
 
97
-
98
- const svgmap = createSVGMap(endYear,dataObj.beginDate)
97
+ {% assign MothStr = site.theme_config.heatMapMonth -%}
98
+ {%- assign HeatMapShowWeek = site.theme_config.heatMapShowWeek -%}
99
+ const WeeKStart = {{ site.theme_config.heatMapWeekStart | default: 1 }} ;// 0 sunday 1 monday 2. tuesday ...
100
+ const _MonthStr = '{{ MothStr | default: "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" }}';
101
+ const _showWeek = '{{ HeatMapShowWeek | default: "Sun Mon Tue Wed Thu Fri Sat" }}';
102
+ const svgmap = createSVGMap(endYear,dataObj.beginDate,_MonthStr,_showWeek,WeeKStart)
99
103
  container.appendChild(svgmap.svg);
100
104
  svgmap.updateDays(dataObj)
101
105
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-zeta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - vitock
@@ -65,6 +65,7 @@ files:
65
65
  - _includes/archive_list.html
66
66
  - _includes/back_link.html
67
67
  - _includes/collecttags.html
68
+ - _includes/encrypt_page.js
68
69
  - _includes/encrypted.html
69
70
  - _includes/getPostData.js
70
71
  - _includes/getmapdata.js
@@ -74,6 +75,12 @@ files:
74
75
  - _includes/heatmap.js
75
76
  - _includes/heatmap_svg.js
76
77
  - _includes/home.html
78
+ - _includes/js_source/encrypt_page.js
79
+ - _includes/js_source/getPostData.js
80
+ - _includes/js_source/getmapdata.js
81
+ - _includes/js_source/heatmap.js
82
+ - _includes/js_source/heatmap_svg.js
83
+ - _includes/js_source/terser.json
77
84
  - _includes/lovemap_layout.html
78
85
  - _includes/main.css
79
86
  - _includes/menu_item.html