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 getJsDir (src) { | |
var script = null; | |
if (src) { | |
script = [].filter.call(document.scripts, function (v) { | |
return v.src.indexOf(src) !== -1; | |
})[0]; | |
} else { | |
script = document.scripts[document.scripts.length - 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.prototype.after = function (fn) { | |
var that = this; | |
return function () { | |
var ret = that.apply(this, arguments); | |
fn.apply(this, arguments); | |
return ret; | |
}; |
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
setViewPort(640); | |
/** | |
* 设置窗口宽度 | |
* @param width | |
*/ | |
function setViewPort(width) { | |
var scale = window.screen.width / width, | |
isAndroid = /Android (\d+\.\d+)/.test(navigator.userAgent); |
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
fnInterval(5, 1000, function (index) { | |
console.log(index); | |
}); | |
/** | |
* 间隔执行fn | |
* @param {number} time 次数 | |
* @param {number} delay 间隔毫秒 | |
* @param {Function} fn fn(index) index从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() { | |
var app = angular.module('tools', []); | |
/** | |
* syncCheckboxModalToArray | |
* @$scope | |
* @modal string | |
* @array string | |
*/ | |
app.factory('syncCheckboxModalToArray', function() { |
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
var app = angular.module('limit-max', []); | |
/** | |
* 限制输入的最大数,最小数无法设置,因为删除时无法判断 | |
* @example | |
* <input ng-model="xx" type="number" limit-max="100"> | |
*/ | |
app.directive('limitMax', function() { | |
return { | |
restrict : 'A', |
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
/** | |
* 轮询ajax请求 | |
* @param fn | |
* @param [delay = 500] | |
* @constructor | |
* @example | |
* var pa = new PollAjax(function (continueNext, done) { | |
$.get('../') | |
.done(function (data) { | |
if (data.success) { |
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
/** | |
* 给图片打文字水印 | |
* @param img Object||String | |
* @param opt | |
* @constructor | |
*/ | |
function Watermark(img, opt) { | |
this.opt = opt; |
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
window.closeWindow = function () { | |
window.open('', '_self', ''); | |
window.close(); | |
}; |