@xiee/utils 1.1.12 → 1.1.13

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.
package/js/post-nav.js ADDED
@@ -0,0 +1,22 @@
1
+ // navigate to previous/next posts by Left/Right arrows
2
+ (function(d) {
3
+ const a1 = d.querySelector('.nav-prev > a'), a2 = d.querySelector('.nav-next > a');
4
+ d.addEventListener('keyup', function(e) {
5
+ if (e.target.nodeName.toUpperCase() != 'BODY') return;
6
+ let u;
7
+ if (a1 && e.which == 37) { // Left arrow
8
+ u = a1.href;
9
+ } else if (a2 && e.which == 39) { // Right arrow
10
+ u = a2.href;
11
+ }
12
+ if (u) window.location = u;
13
+ });
14
+
15
+ const us = d.querySelectorAll('.unlist');
16
+ if (us.length === 0) return;
17
+ const s = sessionStorage.getItem('hide-notes');
18
+ if (s !== null) return us.forEach(u => u.classList.remove('unlist'));
19
+ if (a1 && a2) {
20
+ window.location = d.referrer === a2.href ? a1.href : a2.href;
21
+ }
22
+ })(document);
@@ -6,7 +6,7 @@
6
6
  h.classList.add('toggle-notes');
7
7
  h.onclick = function(e) {
8
8
  s === null && !/^(localhost|[0-9.]+)$/.test(location.hostname) &&
9
- alert('你好像发现了个什么不得了的机关……请勿公开,自行享用即可,谢谢!');
9
+ alert('你好像点了个神秘开关……请勿公开,自行阅读即可(再次点击可关闭),谢谢!');
10
10
  s = d.body.classList.toggle('hide-notes');
11
11
  try { sessionStorage.setItem('hide-notes', s); } catch (e) {};
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"