[JavaScript] aa →→→→→进入此内容的聊天室

来自 , 2021-03-22, 写在 JavaScript, 查看 140 次.
URL http://www.code666.cn/view/15d4e891
  1. // variables
  2. var $window = $(window), gardenCtx, gardenCanvas, $garden, garden;
  3. var clientWidth = $(window).width();
  4. var clientHeight = $(window).height();
  5.  
  6. $(function () {
  7.     // setup garden
  8.     $loveHeart = $("#loveHeart");
  9.     var offsetX = $loveHeart.width() / 2;
  10.     var offsetY = $loveHeart.height() / 2 - 55;
  11.     $garden = $("#garden");
  12.     gardenCanvas = $garden[0];
  13.     gardenCanvas.width = $("#loveHeart").width();
  14.     gardenCanvas.height = $("#loveHeart").height()
  15.     gardenCtx = gardenCanvas.getContext("2d");
  16.     gardenCtx.globalCompositeOperation = "lighter";
  17.     garden = new Garden(gardenCtx, gardenCanvas);
  18.      
  19.     $("#content").css("width", $loveHeart.width() + $("#code").width());
  20.     $("#content").css("height", Math.max($loveHeart.height(), $("#code").height()));
  21.     $("#content").css("margin-top", Math.max(($window.height() - $("#content").height()) / 2, 10));
  22.     $("#content").css("margin-left", Math.max(($window.width() - $("#content").width()) / 2, 10));
  23.  
  24.     // renderLoop
  25.     setInterval(function () {
  26.         garden.render();
  27.     }, Garden.options.growSpeed);
  28. });
  29.  
  30. $(window).resize(function() {
  31.     var newWidth = $(window).width();
  32.     var newHeight = $(window).height();
  33.     if (newWidth != clientWidth && newHeight != clientHeight) {
  34.         location.replace(location);
  35.     }
  36. });
  37.  
  38. function getHeartPoint(angle) {
  39.     var t = angle / Math.PI;
  40.     var x = 19.5 * (16 * Math.pow(Math.sin(t), 3));
  41.     var y = - 20 * (13 * Math.cos(t) - 5 * Math.cos(2 * t) - 2 * Math.cos(3 * t) - Math.cos(4 * t));
  42.     return new Array(offsetX + x, offsetY + y);
  43. }
  44.  
  45. function startHeartAnimation() {
  46.     var interval = 50;
  47.     var angle = 10;
  48.     var heart = new Array();
  49.     var animationTimer = setInterval(function () {
  50.         var bloom = getHeartPoint(angle);
  51.         var draw = true;
  52.         for (var i = 0; i < heart.length; i++) {
  53.             var p = heart[i];
  54.             var distance = Math.sqrt(Math.pow(p[0] - bloom[0], 2) + Math.pow(p[1] - bloom[1], 2));
  55.             if (distance < Garden.options.bloomRadius.max * 1.3) {
  56.                 draw = false;
  57.                 break;
  58.             }
  59.         }
  60.         if (draw) {
  61.             heart.push(bloom);
  62.             garden.createRandomBloom(bloom[0], bloom[1]);
  63.         }
  64.         if (angle >= 30) {
  65.             clearInterval(animationTimer);
  66.             showMessages();
  67.         } else {
  68.             angle += 0.2;
  69.         }
  70.     }, interval);
  71. }
  72.  
  73. (function($) {
  74.     $.fn.typewriter = function() {
  75.         this.each(function() {
  76.             var $ele = $(this), str = $ele.html(), progress = 0;
  77.             $ele.html('');
  78.             var timer = setInterval(function() {
  79.                 var current = str.substr(progress, 1);
  80.                 if (current == '<') {
  81.                     progress = str.indexOf('>', progress) + 1;
  82.                 } else {
  83.                     progress++;
  84.                 }
  85.                 $ele.html(str.substring(0, progress) + (progress & 1 ? '_' : ''));
  86.                 if (progress >= str.length) {
  87.                     clearInterval(timer);
  88.                 }
  89.             }, 75);
  90.         });
  91.         return this;
  92.     };
  93. })(jQuery);
  94.  
  95. function timeElapse(date){
  96.     var current = Date();
  97.     var seconds = (Date.parse(current) - Date.parse(date)) / 1000;
  98.     var days = Math.floor(seconds / (3600 * 24));
  99.     seconds = seconds % (3600 * 24);
  100.     var hours = Math.floor(seconds / 3600);
  101.     if (hours < 10) {
  102.         hours = "0" + hours;
  103.     }
  104.     seconds = seconds % 3600;
  105.     var minutes = Math.floor(seconds / 60);
  106.     if (minutes < 10) {
  107.         minutes = "0" + minutes;
  108.     }
  109.     seconds = seconds % 60;
  110.     if (seconds < 10) {
  111.         seconds = "0" + seconds;
  112.     }
  113.     var result = "<span class=\"digit\">" + days + "</span> days <span class=\"digit\">" + hours + "</span> hours <span class=\"digit\">" + minutes + "</span> minutes <span class=\"digit\">" + seconds + "</span> seconds";
  114.     $("#elapseClock").html(result);
  115. }
  116.  
  117. function showMessages() {
  118.     adjustWordsPosition();
  119.     $('#messages').fadeIn(5000, function() {
  120.         showLoveU();
  121.     });
  122. }
  123.  
  124. function adjustWordsPosition() {
  125.     $('#words').css("position", "absolute");
  126.     $('#words').css("top", $("#garden").position().top + 195);
  127.     $('#words').css("left", $("#garden").position().left + 70);
  128. }
  129.  
  130. function adjustCodePosition() {
  131.     $('#code').css("margin-top", ($("#garden").height() - $("#code").height()) / 2);
  132. }
  133.  
  134. function showLoveU() {
  135.     $('#loveu').fadeIn(3000);
  136. }
  137.  

回复 "aa"

这儿你可以回复上面这条便签

captcha