This file contains 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
// 获取 GUID 方法, from Robert Kieffer | |
Math.guid = function () { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | |
var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8) | |
return v.toString(16) | |
}).toUpperCase() | |
} | |
// Object.create 支持 |
This file contains 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 noMatch = /\w\b\w/; | |
var noMatch = /(.)^/; |
This file contains 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 it = document.getElementsByClassName('mui-act-item-yhqbtn'); | |
var i = 0; | |
function get(){ | |
if(it.length <= i) return; | |
it[i++].click(); | |
var c = document.getElementsByClassName('mui-dialog-close')[0]; | |
c && c.click(); | |
setTimeout(function(){get(); console.log(i)}, 500); | |
} |
This file contains 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
'use strict'; | |
let Ajax = {}; | |
Ajax.xhr = () => { | |
let xhr, versions; | |
if(typeof XMLHttpRequest !== undefined) { | |
xhr = new XMLHttpRequest(); | |
} else { |
This file contains 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
// 普通字面量对象的深拷贝 | |
_.cloneDeep = function (obj) { | |
if (typeof(obj) != 'object' || obj == null) return obj; | |
if(obj instanceof Date) { | |
return new Date(obj.getTime()); | |
} | |
var newObj = {}; | |
// 数组 | |
if(Object.prototype.toString.call(obj) === '[object Array]') { |
This file contains 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
let getQueryString = (key, queryStr = location.search + location.hash) => { | |
let reg = new RegExp('(^|\\?|&)' + key + '=([^&]*)(\\s|&|$)', 'i') | |
return reg.test(queryStr) ? decodeURIComponent(RegExp.$2) : '' | |
} |
This file contains 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
// 颜色 从十六进制转为 rgba | |
exports.convertHex = function(hex, opacity) { | |
hex = hex.replace('#', ''); | |
r = parseInt(hex.substring(0, 2), 16); | |
g = parseInt(hex.substring(2, 4), 16); | |
b = parseInt(hex.substring(4, 6), 16); | |
result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity / 100 + ')'; | |
return result; | |
}; |
This file contains 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 PubSub = { | |
// 订阅函数 | |
subscribe: function (event, callback) { | |
// 创建事件存储对象 | |
this._events = this._events || {} | |
// 添加回调函数 | |
this._events[event] = this._events[event] || [] | |
this._events[event].push(callback) | |
// 链式调用 | |
return this |
This file contains 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
/** | |
* 给定数组,转换为对象类型,键/值必须在给定数组中。 | |
**/ | |
// Example: | |
const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const | |
const result: TupleToObject<typeof tuple> // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} |
OlderNewer