代码拉取完成,页面将自动刷新
同步操作将从 Bowen/highcharts 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/* eslint-env node, es6 */
/* eslint no-console: 0, require-jsdoc: 0 */
/**
* This script retrieves the n most popular charts from cloud.highcharts.com, downloads
* the configurations and prepare them for side-by-side testing in
* http://utils.highcharts.local/samples.
* The downloaded charts can be viewed under the "cloud" heading.
*/
'use strict';
let co = require('co');
let fs = require('co-fs-extra');
let request = require('co-request');
let properties = require('properties');
function wrap(script) {
return 'window.addEventListener("DOMContentLoaded", function () {' + script + '});\n';
}
function html(hash) {
return '<script src="https://code.highcharts.com/stock/highstock.js"></script>' +
'<script src="https://code.highcharts.com/stock/modules/data.js"></script>' +
'<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>' +
'<div id="highcharts-' + hash + '"></div>';
}
co(function* () {
let props = yield new Promise((resolve, reject) => {
properties.parse('git-ignore-me.properties', { path: true }, function (error, obj) {
return error ? reject(error) : resolve(obj);
});
});
let result = yield request({
uri: props['cloud.uri'] + '/api/charts/popular/',
method: 'POST',
json: {
authentication: props['cloud.authentication'],
limit: props['cloud.limit']
}
});
let hashes = result.body;
let jsFile = 'demo.js';
let htmlFile = 'demo.html';
let targetDir = './samples/cloud/charts/';
yield fs.ensureDir(targetDir);
for (let i = 0; i < hashes.length; i++) {
console.log('Downloading script: ' + hashes[i] + ' (' + (i + 1) + '/' + hashes.length + ')');
let scriptResult = yield request.get(props['cloud.uri'] + '/inject/' + hashes[i]);
let script = scriptResult.body;
let path = targetDir + hashes[i] + '/';
yield fs.ensureDir(path);
yield fs.remove(path + jsFile);
yield fs.remove(path + htmlFile);
yield fs.writeFile(path + jsFile, wrap(script));
yield fs.writeFile(path + htmlFile, html(hashes[i]));
}
}).catch(function (err) {
console.log(err);
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。