#参考资料
###下载单个文件,默认将输出打印到标准输出中(STDOUT)中
curl http://www.centos.org
//pads n with zeros on the left, | |
//digits is minimum length of output | |
//zeroPad(3, 5); returns "005" | |
//zeroPad(2, 500); returns "500" | |
zeroPad: function(digits, n) { | |
n = n.toString(); | |
while(n.length < digits) | |
n = '0' + n; | |
return n; | |
}, |
(function() { | |
var supportOrientation = (typeof window.orientation === 'number' && | |
typeof window.onorientationchange === 'object'); | |
var init = function() { | |
var htmlNode = document.body.parentNode, | |
orientation; | |
var updateOrientation = function() { | |
if (supportOrientation) { | |
orientation = window.orientation; |
function getElementTop(element) { | |
if (document.documentElement.getBoundingClientRect !== 'undefined') { | |
return element.getBoundingClientRect().top + document.body.scrollTop; | |
} else { | |
var actualTop = element.offsetTop; | |
var current = element.offsetParent; | |
while (current !== null) { | |
actualTop += current.offsetTop; | |
current = current.offsetParent; | |
} |
function getElementViewTop(element) { | |
if (document.documentElement.getBoundingClientRect !== 'undefined') { | |
return element.getBoundingClientRect().top | |
} else { | |
var actualTop = element.offsetTop | |
var current = element.offsetParent | |
while (current !== null) { | |
actualTop += current.offsetTop | |
current = current.offsetParent | |
} |
function $extend() { | |
var arr = arguments, | |
result = {}, | |
i; | |
var _isObject = function(o) { | |
return Object.prototype.toString.call(o) === '[object Object]'; | |
} | |
var _extend = function self(destination, source) { |
addEventListener("scroll",()=> document.title=`read ${(scrollY/document.body.scrollHeight*100).toFixed(2)}%`) |
#参考资料
###下载单个文件,默认将输出打印到标准输出中(STDOUT)中
curl http://www.centos.org
# This configuration file binds many vi- and vim-like bindings to the | |
# appropriate tmux key bindings. Note that for many key bindings there is no | |
# tmux analogue. This is intended for tmux 1.3, which handles pane selection | |
# differently from the previous versions | |
# split windows like vim | |
# vim's definition of a horizontal/vertical split is reversed from tmux's | |
bind s split-window -v | |
bind v split-window -h |
function toChineseNum (index) { | |
let str = '' + index | |
if (index > 99) return '一百' | |
if (index < 10) { | |
return str.replace(/1/g, '一') | |
.replace(/2/g, '二') | |
.replace(/3/g, '三') | |
.replace(/4/g, '四') | |
.replace(/5/g, '五') | |
.replace(/6/g, '六') |
function autoTextarea (elem, extra, maxHeight) { | |
extra = extra || 0 | |
var addEvent = function (type, callback) { | |
elem.addEventListener ? elem.addEventListener(type, callback, false) : elem.attachEvent('on' + type, callback) | |
} | |
var getStyle = elem.currentStyle ? function (name) { | |
var val = elem.currentStyle[name] | |
if (name === 'height' && val.search(/px/i) !== 1) { | |
var rect = elem.getBoundingClientRect() | |
return rect.bottom - rect.top - parseFloat(getStyle('paddingTop')) - parseFloat(getStyle('paddingBottom')) + 'px' |