Mayx's Home Page
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.7 KiB

  1. var message_Path = '/Live2dHistoire/live2d/';
  2. var talkAPI = BlogAPI + "/ai_chat";
  3. function initVisitors() {
  4. if ($('.visitors').length === 1) {
  5. var $visitor = $('.visitors:first');
  6. $.get(BlogAPI + '/count_click_add?id=' + $visitor.attr('id'), function (data) {
  7. $visitor.text(Number(data));
  8. });
  9. } else if ($('.visitors-index').length > 0) {
  10. $('.visitors-index').each(function () {
  11. var $elem = $(this);
  12. $.get(BlogAPI + '/count_click?id=' + $elem.attr('id'), function (data) {
  13. $elem.text(Number(data));
  14. });
  15. });
  16. }
  17. }
  18. $(function () {
  19. (function () {
  20. var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
  21. .text($backToTopTxt).attr("title", $backToTopTxt).click(function () {
  22. $("html, body").animate({ scrollTop: 0 }, 120);
  23. }), $backToTopFun = function () {
  24. var st = $(document).scrollTop(), winh = $(window).height();
  25. (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
  26. };
  27. $(window).bind("scroll", $backToTopFun);
  28. $(function () { $backToTopFun(); });
  29. })();
  30. initVisitors();
  31. if (Math.floor((new Date().getTime() - lastUpdated.getTime()) / (24 * 60 * 60 * 1000)) > 90) {
  32. $("html").css({
  33. "-webkit-filter": "grayscale(100%)",
  34. "filter": "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)"
  35. })
  36. $('body').html(function (_, oldHTML) {
  37. return oldHTML.replace(/Mayx/g, 'Ghost');
  38. });
  39. console.warn("Mayx may already be Dead");
  40. }
  41. });
  42. function getSearchJSON(callback) {
  43. if (typeof Storage == 'undefined') {
  44. $.getJSON("/search.json", callback);
  45. return;
  46. }
  47. var searchData = JSON.parse(localStorage.getItem("blog_" + lastUpdated.valueOf()));
  48. if (!searchData) {
  49. for (var i = localStorage.length - 1; i >= 0; i--) {
  50. var key = localStorage.key(i);
  51. if (key.indexOf('blog_') === 0) {
  52. localStorage.removeItem(key);
  53. }
  54. }
  55. $.getJSON("/search.json", function (data) {
  56. localStorage.setItem("blog_" + lastUpdated.valueOf(), JSON.stringify(data));
  57. callback(data);
  58. });
  59. } else {
  60. callback(searchData);
  61. }
  62. }
  63. if (typeof window.go === 'undefined') {
  64. window.go = function (url) {
  65. window.location.href = url;
  66. return;
  67. }
  68. }
  69. function getWelcomeText(pathname, title) {
  70. pathname = pathname || window.location.pathname;
  71. title = title || document.title.split(' | ')[0];
  72. if (pathname === '/' || pathname === '/index.html') {
  73. var now = (new Date()).getHours();
  74. if (now > 23 || now <= 5) return '你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?';
  75. if (now > 5 && now <= 7) return '早上好!一日之计在于晨,美好的一天就要开始了!';
  76. if (now > 7 && now <= 11) return '上午好!工作顺利嘛,不要久坐,多起来走动走动哦!';
  77. if (now > 11 && now <= 14) return '中午了,工作了一个上午,现在是午餐时间!';
  78. if (now > 14 && now <= 17) return '午后很容易犯困呢,今天的运动目标完成了吗?';
  79. if (now > 17 && now <= 19) return '傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~~';
  80. if (now > 19 && now <= 21) return '晚上好,今天过得怎么样?';
  81. if (now > 21 && now <= 23) return '已经这么晚了呀,早点休息吧,晚安~~';
  82. return '嗨~ 快来逗我玩吧!';
  83. }
  84. return '欢迎阅读<span style="color:#0099cc;">「 ' + title + ' 」</span>';
  85. }