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 formatDuration(dur) { | |
const timeRange = [60, 60, 24, 1000]; | |
const units = ['秒', '分钟', '小时', '天']; | |
let i = 0; | |
let total = dur; | |
function getUnitStr(pad) { | |
const larger = (total / timeRange[i]) >= 1; | |
const base = total % timeRange[i]; | |
if (base === 0) return ''; |
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 JSON_stringify(s, emit_unicode) | |
{ | |
var json = JSON.stringify(s); | |
return emit_unicode ? json : json.replace(/[\u007f-\uffff]/g, | |
function(c) { | |
return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4); | |
} | |
); | |
} |
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
// scroll setting | |
unmaps('u, e'); | |
mapkey('u', '#2Scroll a page up', 'Normal.scroll("pageUp")', {repeatIgnore: true}); | |
unmaps('E, R'); | |
mapkey('J', '#3Go one tab left', 'RUNTIME("previousTab")'); | |
mapkey('K', '#3Go one tab right', 'RUNTIME("nextTab")'); | |
unmaps('B, F, S, D, H, L'); | |
mapkey('H', '#4Go back in history', 'history.go(-1)'); |
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 wrapper(cb){ | |
var args, that; | |
function doItAgain(){ | |
cb.apply(that, args); | |
} | |
function execute(){ | |
that = this; | |
args = [].slice.call(arguments, 0); |