浏览代码

Merge pull request #500 from afrokick/fix/buildDocsScript

docs: fix build script
afrokick 6 年之前
父节点
当前提交
6f50622506
共有 2 个文件被更改,包括 26 次插入23 次删除
  1. 11 6
      docs/build.js
  2. 15 17
      docs/index.js

+ 11 - 6
docs/build.js

@@ -1,8 +1,13 @@
-var fs = require('fs');
-var handlebars = require('handlebars');
-var reference = require('reference');
+const fs = require('fs');
+const handlebars = require('handlebars');
+const reference = require('reference');
 
-var file = fs.readFileSync('./api.json');
+const file = fs.readFileSync('./api.json');
 
-var template = handlebars.compile(fs.readFileSync('./template.html', {encoding: 'utf8'}));
-fs.writeFile('./index.html', template({html: reference(file, {anchor: true})}));
+const template = handlebars.compile(
+  fs.readFileSync('./template.html', { encoding: 'utf8' })
+);
+fs.writeFileSync(
+  './index.html',
+  template({ html: reference(file, { anchor: true }) })
+);

+ 15 - 17
docs/index.js

@@ -1,17 +1,16 @@
-$(document).ready(function() {
-  var $api = $('.api');
-  var $start = $('.start');
-  var $show = $('.left .show');
-  var $hide = $('.left .hide');
-  var width = $(window).width();
-  var height = $(window).height();
-  var THRESHOLD = 700;
+/* global $ */
+$(document).ready(function () {
+  const $api = $('.api');
+  const $start = $('.start');
+  const $show = $('.left .show');
+  const $hide = $('.left .hide');
+  let width = $(window).width();
+  const THRESHOLD = 700;
 
   init();
 
-  $(window).on('resize', function() {
+  $(window).on('resize', function () {
     width = $(window).width();
-    height = $(window).height();
 
     init();
   });
@@ -21,8 +20,7 @@ $(document).ready(function() {
     hideAPI();
   }
 
-
-  function init() {
+  function init () {
     if (width < THRESHOLD) {
       $api.addClass('fullscreen');
       $start.addClass('full');
@@ -42,7 +40,7 @@ $(document).ready(function() {
     }
   }
 
-  function hideAPI() {
+  function hideAPI () {
     $api.addClass('hidden');
     if (width >= THRESHOLD) {
       $start.addClass('full');
@@ -51,7 +49,7 @@ $(document).ready(function() {
     }
   }
 
-  function showAPI() {
+  function showAPI () {
     if (width >= THRESHOLD) {
       $start.removeClass('full');
       $show.hide();
@@ -60,7 +58,7 @@ $(document).ready(function() {
     $api.removeClass('hidden');
   }
 
-  $('body').on('click', '.left', function() {
+  $('body').on('click', '.left', function () {
     if ($api.attr('class').indexOf('hidden') !== -1) {
       showAPI();
     } else if ($api.attr('class').indexOf('fullscreen') === -1) {
@@ -68,10 +66,10 @@ $(document).ready(function() {
       hideAPI();
     }
   });
-  $('body').on('click', '.right', function() {
+  $('body').on('click', '.right', function () {
     hideAPI();
   });
-  $('body').on('click', 'a', function() {
+  $('body').on('click', 'a', function () {
     if ($(this).attr('href').indexOf('#') === 0) {
       showAPI();
     }