Skip to content

Instantly share code, notes, and snippets.

View ccwq's full-sized avatar
🎯
Focusing

Dave C ccwq

🎯
Focusing
View GitHub Profile
{"lastUpload":"2021-02-09T06:47:36.496Z","extensionVersion":"v3.4.3"}
@ccwq
ccwq / blobURL2blob
Created March 20, 2020 06:32
js 文件各种转换
/**
* blobURL2blob
* @param blobURL
* @returns {Promise<any>}
*/
export function blobURL2blob(blobURL){
return new Promise((resolve, reject) => {
var xhr = new XMLHttpRequest();
xhr.open('GET', blobURL, true);
xhr.responseType = 'blob';
@ccwq
ccwq / calc.js
Last active October 14, 2019 16:23
自己的rem计算js
/**
* @param designWidth 设计稿宽度
* @param scale 缩放比例(rem最小值不能小于12,如果小于12会被认为是12)
* @param maxWidth 大于此宽度停止计算rem
*/
(function (designWidth, scale, maxWidth) {
const doc = document;
const win = window;
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
@ccwq
ccwq / 对象池的基本实现
Last active November 9, 2017 01:47
对象池的基本实现
import _ from "lodash";
//marker对象池
let markerMgr = {
_idCounter:0,
_pool:[],
_outPool:{},
_reset(ins){
var m = this;
live-server ./ -o --port=635 --host=0.0.0.0 --ignorePattern=.*\\.less"
@ccwq
ccwq / 转换callbak到promise形式
Last active August 1, 2017 06:11
promise相关
/**
* 转换callbak到promise形式
* ex1:有一个api getGeo(success,fail);
* 使用后
* callbackToPromise.call(getGeo,arg1,arg2,"|",arg-2,arg-1).then ...
* ex2:callbackToPromise.call({callback:api.getGeo,scope:api},arg1,arg2,"|",arg-2,arg-1).then...
* @returns {Promise}
*/
var callbackToPromise = function(){
var args = Array.prototype.slice.call(arguments);
var isIE = function(ver){
var b = document.createElement('b')
b.innerHTML = '<!--[if IE ' + ver + ']><i></i><![endif]-->'
return b.getElementsByTagName('i').length === 1
}
location.href.replace(/(.+\/)(html)\/.+/,"$1");
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="date=no">
<meta name="format-detection" content="address=no">
<meta name="format-detection" content="email=no">
/**
* 获取当前页面的目录
* "http://aa/b/s/b.html" //"http://aa/b/s/"
* "http://aa/b/s/b.html/#a/b/c" //"http://aa/b/s/"
* "http://aa/b/s/b.html/?asdf=p&a=s#a/b/c" //"http://aa/b/s/"
**/
location.href.replace(/([^#?]+)\/.*?$/,"$1/")