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.

94 lines
3.8 KiB

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