This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const types = 'Boolean Number String Function Array Date RegExp Object Error'.split(' ') | |
const class2type = {} | |
types.forEach(name => { | |
class2type['[object ' + name + ']'] = name.toLowerCase() | |
}) | |
function type (obj) { | |
if (obj === null) { | |
return obj + '' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function runSteps (arr) { | |
if (arr.length === 0) { | |
return | |
} | |
return arr.reduce(function(promise, item) { | |
return promise.then(createStep(item)) | |
}, Promise.resolve([])) | |
} | |
function createStep ({ step, timeout }) { | |
return new Promise(function (resolve, reject) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function demo() { | |
console.log('Taking a break...'); | |
await sleep(2000); | |
console.log('Two second later'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Element.prototype.hasClassName = function (a) { | |
return new RegExp("(?:^|\\s+)" + a + "(?:\\s+|$)").test(this.className); | |
}; | |
Element.prototype.addClassName = function (a) { | |
if (!this.hasClassName(a)) { | |
this.className = [this.className, a].join(" "); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertCurrency(currencyDigits) { | |
// Constants: | |
var MAXIMUM_NUMBER = 99999999999.99; | |
// Predefine the radix characters and currency symbols for output: | |
var CN_ZERO = "零"; | |
var CN_ONE = "壹"; | |
var CN_TWO = "贰"; | |
var CN_THREE = "叁"; | |
var CN_FOUR = "肆"; | |
var CN_FIVE = "伍"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleDispatcher (options) { | |
if (!DISPATCHER_ENABLE) { | |
return | |
} | |
const inIgnore = DISPATCHER_IGNORE.some(res => { | |
return options.url && options.url.indexOf(res) > -1 | |
}) | |
if (inIgnore) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseUrl (url) { | |
const l = document.createElement('a') | |
l.href = url | |
const protocol = l.protocol + '//' | |
const host = l.hostname | |
const path = decodeURIComponent(l.pathname) | |
const reg = /\/(v\d\.\d+)(.*)/g | |
const match = reg.exec(path) | |
const ver = match && match[1] || '' | |
const api = ver ? path.replace('/' + ver, '') : path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script> | |
<script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/canvg.js"></script> | |
<script> | |
function getImgData(chartContainer) { | |
var chartArea = chartContainer.getElementsByTagName('iframe')[0]. | |
contentDocument.getElementById('chartArea'); | |
var svg = chartArea.innerHTML; | |
var doc = chartContainer.ownerDocument; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAllParams () { | |
const params = {} | |
const reg = /([^&?;]*?)=([^&?;]*)/g | |
while (let match = reg.exec(location.search)) { | |
if (match[1]) { | |
const name = decodeURIComponent(match[1]) | |
const value = match[2] ? decodeURIComponent(match[2]) : null | |
params[name] = value | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 获取参数 | |
function getURLParam (name) { | |
return decodeURIComponent( | |
(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || | |
['', ''])[1].replace(/\+/g, '%20')) || null | |
} |
NewerOlder