hexo g rendered my javascript file wrongly

Created on 29 Jul 2017  ·  7Comments  ·  Source: hexojs/hexo

Environment Info

Node version(node -v):

v8.1.3

Your site _config.yml (Optional):


# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: 请叫我喵's StackHarbor
subtitle: Whisper to the World
description: Fight For Freedom!!!
author: 请叫我喵 Alynx
language: zh-Hans
timezone: Asia/Shanghai

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://sh.alynx.xyz/
root: /
permalink: posts/:year/:month/:day/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
  - README.md
  - .nojekyll
  - baidu_verify_qriNvBiolr.html
  - CNAME
  - robots.txt
  - favicon.ico

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: true # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: true
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: true
  tab_replace:

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
index_generator:
  per_page: 7

archive_generator:
  per_page: 20
  yearly: true
  monthly: true

tag_generator:
  per_page: 10

pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
#theme: landscape
theme: next

## Hexo markdown
marked:
  gfm: true
  pedantic: false
  sanitize: false
  tables: true
  breaks: true
  smartLists: true
  smartypants: true

## Hexo sitemap
sitemap:
  path: sitemap.xml
baidusitemap:
  path: baidusitemap.xml

# Hexo localsearch
search:
  path: search.xml
  field: post
  format: html
  limit: 10000

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo:
    github: [email protected]:AlynxZhou/stackharbor.alynx.xyz.git,gh-pages
    coding: [email protected]:AlynxZhou/stackharbor.alynx.xyz.git,coding-pages
#  branch: master
  message: Site updated by hexo at {{ now('YYYY-MM-DD HH:mm:ss') }}.

Your theme _config.yml (Optional):

Too long and seems no relation.

Hexo and Plugin version(npm ls --depth 0):

[email protected] /home/alynx/stackharbor.alynx.xyz
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

For BUG

Hello everyone here, I wrote a HTML5 canvas game use javascript snake.js. And want to add it into my site's about page with

<div id="snakeGame" class="snakeGame">
  <script type="text/javascript" src="js/snake.js"></script>
</div>

(Already works in another site with raw HTML, not hexo rendered.)

However this never worked, all I got is an error. As I see the js file I find something strange.

This is the output of diff ./source/about/snake.js ./public/about/snake.js after hexo g:

21,592c21
<       innerHTML = arguments[0], others = 2 <= arguments.length ? slice.call(arguments, 1) : [];
<       para = document.createElement("p");
<       para.innerHTML = innerHTML;
<       if (others[0] != null) {
<         para.id = others[0];
<       }
<       if (others[1] != null) {
<         para.className = others[1];
<       }
<       this.parent.appendChild(para);
<       return para;
<     };
< 
<     DomCreator.prototype.createSpan = function() {
<       var id, others, para, span;
<       id = arguments[0], others = 2 <= arguments.length ? slice.call(arguments, 1) : [];
<       para = document.createElement("p");
<       span = document.createElement("span");
<       span.id = id;
<       if (others[0] != null) {
<         para.className = others[0];
<       }
<       para.appendChild(span);
<       this.parent.appendChild(para);
<       return span;
<     };
< 
<     DomCreator.prototype.createCanvas = function() {
<       var canvas, height, others, para, width;
<       width = arguments[0], height = arguments[1], others = 3 <= arguments.length ? slice.call(arguments, 2) : [];
<       para = document.createElement("p");
<       canvas = document.createElement("canvas");
<       canvas.width = width;
<       canvas.height = height;
<       if (others[0] != null) {
<         canvas.id = others[0];
<       }
<       if (others[1] != null) {
<         canvas.className = others[1];
<       }
<       para.appendChild(canvas);
<       this.parent.appendChild(para);
<       return canvas;
<     };
< 
<     DomCreator.prototype.createButton = function() {
<       var button, id, others;
<       id = arguments[0], others = 2 <= arguments.length ? slice.call(arguments, 1) : [];
<       button = document.createElement("button");
<       button.id = id;
<       if (others[0] != null) {
<         button.className = others[0];
<       }
<       this.parent.appendChild(button);
<       return button;
<     };
< 
<     DomCreator.prototype.createRadio = function() {
<       var id, label, labelHTML, name, others, radio, value;
<       name = arguments[0], value = arguments[1], labelHTML = arguments[2], id = arguments[3], others = 5 <= arguments.length ? slice.call(arguments, 4) : [];
<       radio = document.createElement("input");
<       radio.type = "radio";
<       radio.name = name;
<       radio.value = value;
<       label = document.createElement("label");
<       label.innerHTML = labelHTML;
<       label.htmlFor = id;
<       radio.id = id;
<       if ((others[0] != null) && others[0]) {
<         radio.checked = true;
<       }
<       if (others[1] != null) {
<         radio.className = others[1];
<       }
<       this.parent.appendChild(radio);
<       this.parent.appendChild(label);
<       return radio;
<     };
< 
<     DomCreator.prototype.createStyle = function(innerHTML) {
<       var style;
<       style = document.createElement("style");
<       style.innerHTML = innerHTML;
<       this.parent.appendChild(style);
<       return style;
<     };
< 
<     return DomCreator;
< 
<   })();
< 
<   FakeStorage = (function() {
<     function FakeStorage() {
<       this.clear = bind(this.clear, this);
<       this.removeItem = bind(this.removeItem, this);
<       this.getItem = bind(this.getItem, this);
<       this.setItem = bind(this.setItem, this);
<       var data;
<       data = {};
<     }
< 
<     FakeStorage.prototype.setItem = function(id, val) {
<       return this.data[id] = String(val);
<     };
< 
<     FakeStorage.prototype.getItem = function(id) {
<       if (this.data.hasOwnProperty(id)) {
<         return this.data[id];
<       } else {
<         return void 0;
<       }
<     };
< 
<     FakeStorage.prototype.removeItem = function(id) {
<       return delete this.data[id];
<     };
< 
<     FakeStorage.prototype.clear = function() {
<       return this.data = {};
<     };
< 
<     return FakeStorage;
< 
<   })();
< 
<   App = (function() {
<     function App(DomCreator) {
<       this.refresh = bind(this.refresh, this);
<       this.death = bind(this.death, this);
<       this.stop = bind(this.stop, this);
<       this.start = bind(this.start, this);
<       this.main = bind(this.main, this);
<       this.setButtonContent = bind(this.setButtonContent, this);
<       this.setMap = bind(this.setMap, this);
<       this.setSpeed = bind(this.setSpeed, this);
<       this.handleTouchEnd = bind(this.handleTouchEnd, this);
<       this.handleTouchStart = bind(this.handleTouchStart, this);
<       this.handleMoveKeyDown = bind(this.handleMoveKeyDown, this);
<       this.handleButtonKeyDown = bind(this.handleButtonKeyDown, this);
<       this.renderPresent = bind(this.renderPresent, this);
<       this.drawBorder = bind(this.drawBorder, this);
<       this.drawSnake = bind(this.drawSnake, this);
<       this.drawFood = bind(this.drawFood, this);
<       this.drawWall = bind(this.drawWall, this);
<       this.drawBackground = bind(this.drawBackground, this);
<       this.clearScore = bind(this.clearScore, this);
<       this.setScore = bind(this.setScore, this);
<       this.addScore = bind(this.addScore, this);
<       this.moveSnake = bind(this.moveSnake, this);
<       this.deleteSnakeTail = bind(this.deleteSnakeTail, this);
<       this.checkHeadCollision = bind(this.checkHeadCollision, this);
<       this.insertSnakeHead = bind(this.insertSnakeHead, this);
<       this.changeSnakeMove = bind(this.changeSnakeMove, this);
<       this.checkFoodCollision = bind(this.checkFoodCollision, this);
<       this.createFood = bind(this.createFood, this);
<       this.createSnake = bind(this.createSnake, this);
<       this.fixPos = bind(this.fixPos, this);
<       this.removeStorage = bind(this.removeStorage, this);
<       this.loadStorage = bind(this.loadStorage, this);
<       this.getStorage = bind(this.getStorage, this);
<       this.setStorage = bind(this.setStorage, this);
<       this.createDom = bind(this.createDom, this);
<       this.createDom(DomCreator);
<       this.unitNum = 30;
<       this.unitSize = Math.floor(this.canvas.height / this.unitNum);
<       this.timerId = null;
<       this.status = "REFRESHED";
<       this.touchStart = [];
<       this.directions = ["UP", "DOWN", "LEFT", "RIGHT"];
<       this.opposite = {
<         "UP": "DOWN",
<         "DOWN": "UP",
<         "LEFT": "RIGHT",
<         "RIGHT": "LEFT"
<       };
<       this.intervals = [200, 150, 100];
<       this.interval = this.intervals[1];
<       this.maps = [
<         {
<           "head": null,
<           "move": null,
<           "wall": []
<         }, {
<           "head": [14, 14],
<           "move": "RIGHT",
<           "wall": [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [23, 0], [24, 0], [25, 0], [26, 0], [27, 0], [28, 0], [29, 0], [29, 1], [29, 2], [29, 3], [29, 4], [29, 5], [29, 6], [0, 29], [1, 29], [2, 29], [3, 29], [4, 29], [5, 29], [6, 29], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [23, 29], [24, 29], [25, 29], [26, 29], [27, 29], [28, 29], [29, 29], [29, 23], [29, 24], [29, 25], [29, 26], [29, 27], [29, 28], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10], [16, 10], [17, 10], [18, 10], [19, 10], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19], [15, 19], [16, 19], [17, 19], [18, 19], [19, 19]]
<         }, {
<           "head": [10, 13],
<           "move": "RIGHT",
<           "wall": [[23, 0], [24, 0], [25, 0], [26, 0], [27, 0], [28, 0], [29, 0], [29, 10], [29, 11], [29, 12], [29, 13], [29, 14], [15, 0], [15, 1], [15, 2], [15, 3], [15, 4], [15, 5], [15, 6], [15, 7], [15, 8], [15, 9], [0, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10], [0, 20], [1, 20], [2, 20], [3, 20], [4, 20], [5, 20], [6, 20], [7, 20], [8, 20], [9, 20], [10, 20], [11, 20], [12, 20], [13, 20], [14, 20], [15, 20], [16, 20], [17, 20], [18, 20], [19, 20], [20, 20], [21, 20], [22, 20], [23, 20], [24, 20], [25, 20], [26, 20], [27, 20], [28, 20], [29, 20]]
<         }
<       ];
<       this.map = this.maps[0];
<       this.refresh();
<       addEventListener("keydown", this.handleButtonKeyDown, false);
<     }
< 
<     App.prototype.createDom = function(DomCreator) {
<       this.domCreator = new DomCreator("snakeGame");
<       this.domCreator.createPara("空格暂停/开始,回车重来");
<       this.domCreator.createPara("WASD、方向键或划屏操纵");
<       this.scoreBar = this.domCreator.createSpan("score");
<       this.canvas = this.domCreator.createCanvas(300, 300, "snakeCanvas");
<       this.ctx = this.canvas.getContext("2d");
<       this.switchButton = this.domCreator.createButton("switch");
<       this.refreshButton = this.domCreator.createButton("refresh");
<       this.domCreator.createPara("选择速度");
<       this.speedRadio = [this.domCreator.createRadio("speed", "low", "低", "speed0"), this.domCreator.createRadio("speed", "mid", "中", "speed1", true), this.domCreator.createRadio("speed", "high", "高", "speed2")];
<       this.domCreator.createPara("选择地图");
<       this.mapRadio = [this.domCreator.createRadio("map", "map0", "无地图", "map0", true), this.domCreator.createRadio("map", "map1", "地图一", "map1"), this.domCreator.createRadio("map", "map2", "地图二", "map2")];
<       this.speedRadio[0].onclick = this.setSpeed;
<       this.speedRadio[1].onclick = this.setSpeed;
<       this.speedRadio[2].onclick = this.setSpeed;
<       this.mapRadio[0].onclick = this.setMap;
<       this.mapRadio[1].onclick = this.setMap;
<       this.mapRadio[2].onclick = this.setMap;
<       this.domCreator.createStyle(".snakeGame {\n  font: 16px/1.8 \"Noto Sans\", \"Noto Sans CJK\", \"Lato\", \"Microsoft Jhenghei\", \"Hiragino Sans GB\", \"Microsoft YaHei\", arial, sans-serif;\n  color: #333;\n  text-shadow: 4px 4px 4px #aaa;\n  text-align: center;\n}\n\n.snakeGame p {\n  margin: 5px auto 5px auto;\n}\n\n.snakeGame button {\n   font-size: 30px;\n  margin: 5px 30px 5px 30px;\n  color: #fff;\n  background-color: #d9534f;\n  border-color: #d43f3a;\n  display: inline-block;\n  padding: 6px 12px 6px 12px;\n  font-size: 14px;\n  font-weight: 400;\n  line-height: 1.42857143;\n  white-space: nowrap;\n  vertical-align: middle;\n  touch-action: manipulation;\n  cursor: pointer;\n  user-select: none;\n  background-image: none;\n  border: 1px solid transparent;\n  border-radius: 4px;\n}\n\n.snakeGame button:hover {\n  color: #fff;\n  background-color: #c9302c;\n  border-color: #ac2925;\n}\n\n.snakeGame label {\n  margin: auto 5px auto 5px;\n}");
<       if (window.navigator.msPointerEnabled) {
<         this.eventTouchStart = "MSPointerDown";
<         this.eventTouchMove = "MSPointerMove";
<         this.eventTouchEnd = "MSPointerUp";
<       } else {
<         this.eventTouchStart = "touchstart";
<         this.eventTouchMove = "touchmove";
<         this.eventTouchEnd = "touchend";
<       }
<       if (window.fakeStorage == null) {
<         window.fakeStorage = new FakeStorage();
<       }
<       return this.storage = (this.checkLocalStorage() ? window.localStorage : window.fakeStorage);
<     };
< 
<     App.prototype.checkLocalStorage = function() {
<       var err;
<       try {
<         window.localStorage.setItem("test", 1);
<         window.localStorage.removeItem("test");
<         return true;
<       } catch (error) {
<         err = error;
<         return false;
<       }
<     };
< 
<     App.prototype.setStorage = function() {
<       var snakeStorage;
<       snakeStorage = {
<         "score": this.score,
<         "status": "STOPPED",
<         "food": this.food,
<         "snake": this.snake
<       };
<       if (this.mapRadio[1].checked) {
<         snakeStorage["map"] = 1;
<       } else if (this.mapRadio[2].checked) {
<         snakeStorage["map"] = 2;
<       } else {
<         snakeStorage["map"] = 0;
<       }
<       if (this.speedRadio[0].checked) {
<         snakeStorage["speed"] = 0;
<       } else if (this.speedRadio[2].checked) {
<         snakeStorage["speed"] = 2;
<       } else {
<         snakeStorage["speed"] = 1;
<       }
<       return this.storage.setItem("snakeStorage", JSON.stringify(snakeStorage));
<     };
< 
<     App.prototype.getStorage = function() {
<       var snakeStorage;
<       if ((snakeStorage = this.storage.getItem("snakeStorage")) != null) {
<         return JSON.parse(snakeStorage);
<       } else {
<         return void 0;
<       }
<     };
< 
<     App.prototype.loadStorage = function(snakeStorage) {
<       var k, l, len, len1, mapRadio, ref, ref1, speedRadio;
<       ref = this.mapRadio;
<       for (k = 0, len = ref.length; k < len; k++) {
<         mapRadio = ref[k];
<         mapRadio.checked = false;
<       }
<       this.mapRadio[snakeStorage["map"]].checked = true;
<       this.map = this.maps[snakeStorage["map"]];
<       ref1 = this.speedRadio;
<       for (l = 0, len1 = ref1.length; l < len1; l++) {
<         speedRadio = ref1[l];
<         speedRadio.checked = false;
<       }
<       this.speedRadio[snakeStorage["speed"]].checked = true;
<       this.interval = this.intervals[snakeStorage["speed"]];
<       this.score = snakeStorage["score"];
<       this.status = snakeStorage["status"];
<       this.food = snakeStorage["food"];
<       this.snake = snakeStorage["snake"];
<       this.setButtonContent();
<       this.setScore();
<       return this.renderPresent();
<     };
< 
<     App.prototype.removeStorage = function() {
<       return this.storage.removeItem("snakeStorage");
<     };
< 
<     App.prototype.fixPos = function(point) {
<       point[0] %= this.unitNum;
<       point[1] %= this.unitNum;
<       while (point[0] < 0) {
<         point[0] += this.unitNum;
<       }
<       while (point[1] < 0) {
<         point[1] += this.unitNum;
<       }
<       return point;
<     };
< 
<     App.prototype.createSnake = function() {
<       var headX, headY, i, k, list, move;
<       list = [];
<       if (this.map.head != null) {
<         headX = this.map.head[0];
<         headY = this.map.head[1];
<       } else {
<         headX = Math.floor(Math.random() * this.unitNum);
<         headY = Math.floor(Math.random() * this.unitNum);
<       }
<       if (this.map.move != null) {
<         move = this.map.move;
<       } else {
<         move = this.directions[Math.floor(Math.random() * this.directions.length)];
<       }
<       for (i = k = 0; k < 4; i = ++k) {
<         switch (move) {
<           case "UP":
<             list.push(this.fixPos([headX, headY + i]));
<             break;
<           case "DOWN":
<             list.push(this.fixPos([headX, headY - i]));
<             break;
<           case "LEFT":
<             list.push(this.fixPos([headX + i, headY]));
<             break;
<           case "RIGHT":
<             list.push(this.fixPos([headX - i, headY]));
<         }
<       }
<       this.snake.list = list;
<       return this.snake.move = move;
<     };
< 
<     App.prototype.createFood = function() {
<       var results;
<       this.food = [Math.floor(Math.random() * this.unitNum), Math.floor(Math.random() * this.unitNum)];
<       results = [];
<       while (this.checkFoodCollision()) {
<         results.push(this.food = [Math.floor(Math.random() * this.unitNum), Math.floor(Math.random() * this.unitNum)]);
<       }
<       return results;
<     };
< 
<     App.prototype.checkFoodCollision = function() {
<       var body, brick, k, l, len, len1, ref, ref1;
<       ref = this.snake.list;
<       for (k = 0, len = ref.length; k < len; k++) {
<         body = ref[k];
<         if (this.food[0] === body[0] && this.food[1] === body[1]) {
<           return true;
<         }
<       }
<       ref1 = this.map.wall;
<       for (l = 0, len1 = ref1.length; l < len1; l++) {
<         brick = ref1[l];
<         if (this.food[0] === brick[0] && this.food[1] === brick[1]) {
<           return true;
<         }
<       }
<       return false;
<     };
< 
<     App.prototype.changeSnakeMove = function() {
<       while (this.moveQueue.length && (this.snake.move === this.opposite[this.moveQueue[0]] || this.moveQueue[0] === this.moveQueue[1] || this.snake.move === this.moveQueue[0])) {
<         this.moveQueue.shift();
<       }
<       if (this.moveQueue.length) {
<         return this.snake.move = this.moveQueue.shift();
<       }
<     };
< 
<     App.prototype.insertSnakeHead = function() {
<       var headX, headY;
<       headX = this.snake.list[0][0];
<       headY = this.snake.list[0][1];
<       switch (this.snake.move) {
<         case "UP":
<           return this.snake.list.unshift(this.fixPos([headX, headY - 1]));
<         case "DOWN":
<           return this.snake.list.unshift(this.fixPos([headX, headY + 1]));
<         case "LEFT":
<           return this.snake.list.unshift(this.fixPos([headX - 1, headY]));
<         case "RIGHT":
<           return this.snake.list.unshift(this.fixPos([headX + 1, headY]));
<       }
<     };
< 
<     App.prototype.checkHeadCollision = function() {
<       var body, brick, k, l, len, len1, ref, ref1;
<       ref = this.snake.list.slice(1, this.snake.list.length - 1);
<       for (k = 0, len = ref.length; k < len; k++) {
<         body = ref[k];
<         if (this.snake.list[0][0] === body[0] && this.snake.list[0][1] === body[1]) {
<           return -1;
<         }
<       }
<       ref1 = this.map.wall;
<       for (l = 0, len1 = ref1.length; l < len1; l++) {
<         brick = ref1[l];
<         if (this.snake.list[0][0] === brick[0] && this.snake.list[0][1] === brick[1]) {
<           return -1;
<         }
<       }
<       if (this.snake.list[0][0] === this.food[0] && this.snake.list[0][1] === this.food[1]) {
<         return 1;
<       }
<       return 0;
<     };
< 
<     App.prototype.deleteSnakeTail = function() {
<       return this.snake.list.pop();
<     };
< 
<     App.prototype.moveSnake = function() {
<       this.changeSnakeMove();
<       this.insertSnakeHead();
<       switch (this.checkHeadCollision()) {
<         case 1:
<           this.addScore();
<           return this.createFood();
<         case 0:
<           return this.deleteSnakeTail();
<         case -1:
<           this.deleteSnakeTail();
<           return -1;
<       }
<     };
< 
<     App.prototype.addScore = function() {
<       this.score++;
<       return this.setScore();
<     };
< 
<     App.prototype.setScore = function() {
<       return this.scoreBar.innerHTML = this.score + " 分";
<     };
< 
<     App.prototype.clearScore = function() {
<       this.score = 0;
<       return this.setScore();
<     };
< 
<     App.prototype.drawBackground = function() {
<       var i, j, k, ref, results;
<       this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
<       results = [];
<       for (i = k = 0, ref = this.unitNum; 0 <= ref ? k < ref : k > ref; i = 0 <= ref ? ++k : --k) {
<         results.push((function() {
<           var l, ref1, results1;
<           results1 = [];
<           for (j = l = 0, ref1 = this.unitNum; 0 <= ref1 ? l < ref1 : l > ref1; j = 0 <= ref1 ? ++l : --l) {
<             if ((i + j) % 2) {
<               this.ctx.fillStyle = "rgba(200, 200, 200, 0.5)";
<             } else {
<               this.ctx.fillStyle = "rgba(255, 255, 255, 0.5)";
<             }
<             results1.push(this.ctx.fillRect(i * this.unitSize, j * this.unitSize, this.unitSize, this.unitSize));
<           }
<           return results1;
<         }).call(this));
<       }
<       return results;
<     };
< 
<     App.prototype.drawWall = function() {
<       var brick, k, len, ref, results;
<       ref = this.map.wall;
<       results = [];
<       for (k = 0, len = ref.length; k < len; k++) {
<         brick = ref[k];
<         this.ctx.fillStyle = "rgba(3, 3, 3, 0.7)";
<         results.push(this.ctx.fillRect(brick[0] * this.unitSize, brick[1] * this.unitSize, this.unitSize, this.unitSize));
<       }
<       return results;
<     };
< 
<     App.prototype.drawFood = function() {
<       this.ctx.strokeStyle = "rgba(0, 100, 100, 1)";
<       return this.ctx.strokeRect(this.food[0] * this.unitSize, this.food[1] * this.unitSize, this.unitSize, this.unitSize);
<     };
< 
<     App.prototype.drawSnake = function() {
<       var body, k, len, ref;
<       ref = this.snake.list.slice(1, this.snake.list.length);
<       for (k = 0, len = ref.length; k < len; k++) {
<         body = ref[k];
<         this.ctx.fillStyle = "rgba(100, 100, 200, 1)";
<         this.ctx.fillRect(body[0] * this.unitSize, body[1] * this.unitSize, this.unitSize, this.unitSize);
<       }
<       this.ctx.fillStyle = "rgba(200, 0, 0, 1)";
<       return this.ctx.fillRect(this.snake.list[0][0] * this.unitSize, this.snake.list[0][1] * this.unitSize, this.unitSize, this.unitSize);
<     };
< 
<     App.prototype.drawBorder = function() {
<       this.ctx.strokeStyle = "rgba(3, 3, 3, 0.7)";
<       return this.ctx.strokeRect(0, 0, this.canvas.width, this.canvas.height);
<     };
< 
<     App.prototype.renderPresent = function() {
<       this.drawBackground();
<       this.drawWall();
<       this.drawFood();
<       this.drawSnake();
<       return this.drawBorder();
<     };
< 
<     App.prototype.handleButtonKeyDown = function(event) {
<       switch (event.keyCode) {
<         case 32:
<           event.preventDefault();
<           return this.switchButton.onclick();
<         case 13:
<           event.preventDefault();
<           return this.refreshButton.onclick();
<       }
<     };
< 
<     App.prototype.handleMoveKeyDown = function(event) {
<       var move;
<       switch (event.keyCode) {
<         case 38:
<           move = "UP";
<           break;
<         case 40:
<           move = "DOWN";
<           break;
<         case 37:
<           move = "LEFT";
<           break;
<         case 39:
<           move = "RIGHT";
<           break;
<         case 87:
<           move = "UP";
<           break;
<         case 83:
<           move = "DOWN";
<           break;
<         case 65:
<           move = "LEFT";
<           break;
<         case 68:
<           move = "RIGHT";
<       }
<       if (move != null) {
<         event.preventDefault();
<         return this.moveQueue.push(move);
<       }
<     };
< 
<     App.prototype.handleTouchStart = function(event) {
<       if (event.touches.length > 1 || event.targetTouches.length > 1) {
---
>       innerHTML = arguments[0], others = 2 <= 0="" arguments.length="" ?="" slice.call(arguments,="" 1)="" :="" [];="" para="document.createElement("p");" para.innerhtml="innerHTML;" if="" (others[0]="" !="null)" {="" para.id="others[0];" }="" (others[1]="" para.classname="others[1];" this.parent.appendchild(para);="" return="" para;="" };="" domcreator.prototype.createspan="function()" var="" id,="" others,="" para,="" span;="" id="arguments[0]," others="2" <="arguments.length" span="document.createElement("span");" span.id="id;" para.appendchild(span);="" domcreator.prototype.createcanvas="function()" canvas,="" height,="" width;="" width="arguments[0]," height="arguments[1]," 2)="" canvas="document.createElement("canvas");" canvas.width="width;" canvas.height="height;" canvas.id="others[0];" canvas.classname="others[1];" para.appendchild(canvas);="" canvas;="" domcreator.prototype.createbutton="function()" button,="" others;="" button="document.createElement("button");" button.id="id;" button.classname="others[0];" this.parent.appendchild(button);="" button;="" domcreator.prototype.createradio="function()" label,="" labelhtml,="" name,="" radio,="" value;="" name="arguments[0]," value="arguments[1]," labelhtml="arguments[2]," 4)="" radio="document.createElement("input");" radio.type="radio" ;="" radio.name="name;" radio.value="value;" label="document.createElement("label");" label.innerhtml="labelHTML;" label.htmlfor="id;" radio.id="id;" ((others[0]="" &&="" others[0])="" radio.checked="true;" radio.classname="others[1];" this.parent.appendchild(radio);="" this.parent.appendchild(label);="" radio;="" domcreator.prototype.createstyle="function(innerHTML)" style;="" style="document.createElement("style");" style.innerhtml="innerHTML;" this.parent.appendchild(style);="" domcreator;="" })();="" fakestorage="(function()" function="" fakestorage()="" this.clear="bind(this.clear," this);="" this.removeitem="bind(this.removeItem," this.getitem="bind(this.getItem," this.setitem="bind(this.setItem," data;="" data="{};" fakestorage.prototype.setitem="function(id," val)="" this.data[id]="String(val);" fakestorage.prototype.getitem="function(id)" (this.data.hasownproperty(id))="" this.data[id];="" else="" void="" 0;="" fakestorage.prototype.removeitem="function(id)" delete="" fakestorage.prototype.clear="function()" this.data="{};" fakestorage;="" app="(function()" app(domcreator)="" this.refresh="bind(this.refresh," this.death="bind(this.death," this.stop="bind(this.stop," this.start="bind(this.start," this.main="bind(this.main," this.setbuttoncontent="bind(this.setButtonContent," this.setmap="bind(this.setMap," this.setspeed="bind(this.setSpeed," this.handletouchend="bind(this.handleTouchEnd," this.handletouchstart="bind(this.handleTouchStart," this.handlemovekeydown="bind(this.handleMoveKeyDown," this.handlebuttonkeydown="bind(this.handleButtonKeyDown," this.renderpresent="bind(this.renderPresent," this.drawborder="bind(this.drawBorder," this.drawsnake="bind(this.drawSnake," this.drawfood="bind(this.drawFood," this.drawwall="bind(this.drawWall," this.drawbackground="bind(this.drawBackground," this.clearscore="bind(this.clearScore," this.setscore="bind(this.setScore," this.addscore="bind(this.addScore," this.movesnake="bind(this.moveSnake," this.deletesnaketail="bind(this.deleteSnakeTail," this.checkheadcollision="bind(this.checkHeadCollision," this.insertsnakehead="bind(this.insertSnakeHead," this.changesnakemove="bind(this.changeSnakeMove," this.checkfoodcollision="bind(this.checkFoodCollision," this.createfood="bind(this.createFood," this.createsnake="bind(this.createSnake," this.fixpos="bind(this.fixPos," this.removestorage="bind(this.removeStorage," this.loadstorage="bind(this.loadStorage," this.getstorage="bind(this.getStorage," this.setstorage="bind(this.setStorage," this.createdom="bind(this.createDom," this.createdom(domcreator);="" this.unitnum="30;" this.unitsize="Math.floor(this.canvas.height" this.unitnum);="" this.timerid="null;" this.status="REFRESHED" this.touchstart="[];" this.directions="["UP"," "down",="" "left",="" "right"];="" this.opposite="{" "up":="" "down":="" "up",="" "left":="" "right",="" "right":="" "left"="" this.intervals="[200," 150,="" 100];="" this.interval="this.intervals[1];" this.maps="[" "head":="" null,="" "move":="" "wall":="" []="" },="" [14,="" 14],="" [[0,="" 0],="" [1,="" [2,="" [3,="" [4,="" [5,="" [6,="" [0,="" 1],="" 2],="" 3],="" 4],="" 5],="" 6],="" [23,="" [24,="" [25,="" [26,="" [27,="" [28,="" [29,="" 29],="" 23],="" 24],="" 25],="" 26],="" 27],="" 28],="" [10,="" 10],="" [11,="" [12,="" [13,="" [15,="" [16,="" [17,="" [18,="" [19,="" 19],="" 19]]="" 13],="" [[23,="" 11],="" 12],="" 7],="" 8],="" 9],="" [7,="" [8,="" [9,="" 20],="" [20,="" [21,="" [22,="" 20]]="" ];="" this.map="this.maps[0];" this.refresh();="" addeventlistener("keydown",="" this.handlebuttonkeydown,="" false);="" app.prototype.createdom="function(DomCreator)" this.domcreator="new" domcreator("snakegame");="" this.domcreator.createpara("空格暂停="" 开始,回车重来");="" this.domcreator.createpara("wasd、方向键或划屏操纵");="" this.scorebar="this.domCreator.createSpan("score");" this.canvas="this.domCreator.createCanvas(300," 300,="" "snakecanvas");="" this.ctx="this.canvas.getContext("2d");" this.switchbutton="this.domCreator.createButton("switch");" this.refreshbutton="this.domCreator.createButton("refresh");" this.domcreator.createpara("选择速度");="" this.speedradio="[this.domCreator.createRadio("speed"," "low",="" "低",="" "speed0"),="" this.domcreator.createradio("speed",="" "mid",="" "中",="" "speed1",="" true),="" "high",="" "高",="" "speed2")];="" this.domcreator.createpara("选择地图");="" this.mapradio="[this.domCreator.createRadio("map"," "map0",="" "无地图",="" this.domcreator.createradio("map",="" "map1",="" "地图一",="" "map1"),="" "map2",="" "地图二",="" "map2")];="" this.speedradio[0].onclick="this.setSpeed;" this.speedradio[1].onclick="this.setSpeed;" this.speedradio[2].onclick="this.setSpeed;" this.mapradio[0].onclick="this.setMap;" this.mapradio[1].onclick="this.setMap;" this.mapradio[2].onclick="this.setMap;" this.domcreator.createstyle(".snakegame="" {\n="" font:="" 16px="" 1.8="" \"noto="" sans\",="" sans="" cjk\",="" \"lato\",="" \"microsoft="" jhenghei\",="" \"hiragino="" gb\",="" yahei\",="" arial,="" sans-serif;\n="" color:="" #333;\n="" text-shadow:="" 4px="" #aaa;\n="" text-align:="" center;\n}\n\n.snakegame="" p="" margin:="" 5px="" auto="" auto;\n}\n\n.snakegame="" font-size:="" 30px;\n="" 30px="" #fff;\n="" background-color:="" #d9534f;\n="" border-color:="" #d43f3a;\n="" display:="" inline-block;\n="" padding:="" 6px="" 12px="" 12px;\n="" 14px;\n="" font-weight:="" 400;\n="" line-height:="" 1.42857143;\n="" white-space:="" nowrap;\n="" vertical-align:="" middle;\n="" touch-action:="" manipulation;\n="" cursor:="" pointer;\n="" user-select:="" none;\n="" background-image:="" border:="" 1px="" solid="" transparent;\n="" border-radius:="" 4px;\n}\n\n.snakegame="" button:hover="" #c9302c;\n="" #ac2925;\n}\n\n.snakegame="" 5px;\n}");="" (window.navigator.mspointerenabled)="" this.eventtouchstart="MSPointerDown" this.eventtouchmove="MSPointerMove" this.eventtouchend="MSPointerUp" (window.fakestorage="=" null)="" window.fakestorage="new" fakestorage();="" this.storage="(this.checkLocalStorage()" window.localstorage="" window.fakestorage);="" app.prototype.checklocalstorage="function()" err;="" try="" window.localstorage.setitem("test",="" 1);="" window.localstorage.removeitem("test");="" true;="" catch="" (error)="" err="error;" false;="" app.prototype.setstorage="function()" snakestorage;="" snakestorage="{" "score":="" this.score,="" "status":="" "stopped",="" "food":="" this.food,="" "snake":="" this.snake="" (this.mapradio[1].checked)="" snakestorage["map"]="1;" (this.mapradio[2].checked)="" (this.speedradio[0].checked)="" snakestorage["speed"]="0;" (this.speedradio[2].checked)="" this.storage.setitem("snakestorage",="" json.stringify(snakestorage));="" app.prototype.getstorage="function()" ((snakestorage="this.storage.getItem("snakeStorage"))" json.parse(snakestorage);="" app.prototype.loadstorage="function(snakeStorage)" k,="" l,="" len,="" len1,="" mapradio,="" ref,="" ref1,="" speedradio;="" ref="this.mapRadio;" for="" (k="0," len="ref.length;" k="" len;="" k++)="" mapradio="ref[k];" mapradio.checked="false;" this.mapradio[snakestorage["map"]].checked="true;" ref1="this.speedRadio;" (l="0," len1="ref1.length;" l="" len1;="" l++)="" speedradio="ref1[l];" speedradio.checked="false;" this.speedradio[snakestorage["speed"]].checked="true;" this.score="snakeStorage["score"];" this.food="snakeStorage["food"];" this.setbuttoncontent();="" this.setscore();="" this.renderpresent();="" app.prototype.removestorage="function()" this.storage.removeitem("snakestorage");="" app.prototype.fixpos="function(point)" point[0]="" %="this.unitNum;" point[1]="" while="" (point[0]="" 0)="" +="this.unitNum;" (point[1]="" point;="" app.prototype.createsnake="function()" headx,="" heady,="" i,="" list,="" move;="" list="[];" (this.map.head="" headx="this.map.head[0];" heady="this.map.head[1];" *="" (this.map.move="" move="this.map.move;" this.directions.length)];="" (i="k" =="" 4;="" i="++k)" switch="" (move)="" case="" list.push(this.fixpos([headx,="" i]));="" break;="" -="" list.push(this.fixpos([headx="" heady]));="" this.snake.list="list;" this.snake.move="move;" app.prototype.createfood="function()" results;="" this.unitnum),="" math.floor(math.random()="" this.unitnum)];="" results="[];" (this.checkfoodcollision())="" results.push(this.food="[Math.floor(Math.random()" this.unitnum)]);="" app.prototype.checkfoodcollision="function()" body,="" brick,="" ref1;="" body="ref[k];" (this.food[0]="==" body[0]="" this.food[1]="==" body[1])="" brick="ref1[l];" brick[0]="" brick[1])="" app.prototype.changesnakemove="function()" (this.movequeue.length="" (this.snake.move="==" this.opposite[this.movequeue[0]]="" ||="" this.movequeue[0]="==" this.movequeue[1]="" this.movequeue[0]))="" this.movequeue.shift();="" (this.movequeue.length)="" app.prototype.insertsnakehead="function()" heady;="" (this.snake.move)="" this.snake.list.unshift(this.fixpos([headx,="" 1]));="" this.snake.list.unshift(this.fixpos([headx="" 1,="" app.prototype.checkheadcollision="function()" this.snake.list.length="" (this.snake.list[0][0]="==" this.snake.list[0][1]="==" -1;="" this.food[0]="" this.food[1])="" 1;="" app.prototype.deletesnaketail="function()" this.snake.list.pop();="" app.prototype.movesnake="function()" this.changesnakemove();="" this.insertsnakehead();="" (this.checkheadcollision())="" 1:="" this.addscore();="" this.createfood();="" 0:="" this.deletesnaketail();="" -1:="" app.prototype.addscore="function()" this.score++;="" app.prototype.setscore="function()" this.scorebar.innerhtml="this.score" "="" 分";="" app.prototype.clearscore="function()" app.prototype.drawbackground="function()" j,="" this.ctx.clearrect(0,="" 0,="" this.canvas.width,="" this.canvas.height);=""> ref; i = 0 <= 0="" ref="" ?="" ++k="" :="" --k)="" {="" results.push((function()="" var="" l,="" ref1,="" results1;="" results1="[];" for="" (j="l" =="" 0,="" ref1="this.unitNum;" <="ref1" l=""> ref1; j = 0 <= ref1="" ?="" ++l="" :="" --l)="" {="" if="" ((i="" +="" j)="" %="" 2)="" this.ctx.fillstyle="rgba(200, 200, 200, 0.5)" ;="" }="" else="" results1.push(this.ctx.fillrect(i="" *="" this.unitsize,="" j="" this.unitsize));="" return="" results1;="" }).call(this));="" results;="" };="" app.prototype.drawwall="function()" var="" brick,="" k,="" len,="" ref,="" ref="this.map.wall;" results="[];" for="" (k="0," len="ref.length;" k="" <="" len;="" k++)="" brick="ref[k];" results.push(this.ctx.fillrect(brick[0]="" brick[1]="" app.prototype.drawfood="function()" this.ctx.strokestyle="rgba(0, 100, 100, 1)" this.ctx.strokerect(this.food[0]="" this.food[1]="" this.unitsize);="" app.prototype.drawsnake="function()" body,="" ref;="" this.snake.list.length);="" body="ref[k];" this.ctx.fillrect(body[0]="" body[1]="" this.ctx.fillrect(this.snake.list[0][0]="" this.snake.list[0][1]="" app.prototype.drawborder="function()" this.ctx.strokerect(0,="" 0,="" this.canvas.width,="" this.canvas.height);="" app.prototype.renderpresent="function()" this.drawbackground();="" this.drawwall();="" this.drawfood();="" this.drawsnake();="" this.drawborder();="" app.prototype.handlebuttonkeydown="function(event)" switch="" (event.keycode)="" case="" 32:="" event.preventdefault();="" this.switchbutton.onclick();="" 13:="" this.refreshbutton.onclick();="" app.prototype.handlemovekeydown="function(event)" move;="" 38:="" move="UP" break;="" 40:="" 37:="" 39:="" 87:="" 83:="" 65:="" 68:="" (move="" !="null)" this.movequeue.push(move);="" app.prototype.handletouchstart="function(event)" (event.touches.length=""> 1 || event.targetTouches.length > 1) {
780a210
> </=></=></=>
\ No newline at end of file

You can see that many lines was rendered into one line with wrong words.

I think that hexo only renders Markdown and HTML files in my environment, not js files, so I think there may be bugs that let it handle my js wrongly?

Thanks for everyone who give advice in advance.

For question

Nope.

For feature request


Nope.

question skip-render stale

Most helpful comment

Add /about/snake.js to skip_renderer in _config.yml:

skip_render:
  - README.md
  - .nojekyll
  - baidu_verify_qriNvBiolr.html
  - CNAME
  - robots.txt
  - favicon.ico
  - /about/snake.js

All 7 comments

Add /about/snake.js to skip_renderer in _config.yml:

skip_render:
  - README.md
  - .nojekyll
  - baidu_verify_qriNvBiolr.html
  - CNAME
  - robots.txt
  - favicon.ico
  - /about/snake.js

Hexo normally doesn't minimize the js/css files. Does @sunjiayu12 solution solve the problem?

@NoahDragon @sunjiayu12 Nope. I've tried this way. Also sometimes skip_render works incorrectly, and seems this is not minimize, it's totally incorrect behavior...

I met the same problem about this .QAQ And @sunjiayu12 's solution seems doesn't work = =. Is there any solution to this problem???

I found a detailed issue about how to use skip_render in #1146 . It matters to me! Hope it may also helps.

I think if no neat/minify plugin was installed hexo should do nothing with javascript file but it did to my file and behave wrongly. Hexo itself says it only render html/md files so js file doesn't need to add to skip_render.

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lushijie picture lushijie  ·  3Comments

netcan picture netcan  ·  3Comments

demurgos picture demurgos  ·  3Comments

ghost picture ghost  ·  3Comments

cxgreat2014 picture cxgreat2014  ·  3Comments