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
import { libFn } from './lib'; | |
export function commonFn(){ | |
libFn() | |
} |
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 emoji2utf16(point){ | |
if( point<0x10000 ){//softbank | |
return unescape("%u"+point.toString(16)) | |
} | |
var offset = point - 0x10000, | |
lead = 0xd800 + (offset >> 10), | |
trail = 0xdc00 + (offset & 0x3ff); | |
//return unescape("%u"+lead.toString(16) + "%u"+ (trail).toString(16)); | |
return String.fromCharCode(lead) + String.fromCharCode(trail); | |
} |
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 addParam(key,val,url){ | |
var url = url || window.location.href, | |
hashPart = url.split('#'), | |
reg = new RegExp("([\?|&]"+key+"=)([^&#?]*)"), | |
rst = ''; | |
if( hashPart[0].match(reg) ){ | |
rst = hashPart[0].replace(reg, function(){ | |
var arg = arguments; | |
return arg[1] + val; | |
}) + ( hashPart[1]? '#'+hashPart[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 flatten(array) { | |
return array.length > 0 ? new Array().concat.apply([], array) : array | |
} |
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
<!DOCTYPE html> | |
<html lang="zh-cn"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>web worker</title> | |
<script type="text/javascript"> | |
var w = new Worker('work.js'); | |
w.onmessage = function(e){ | |
console.log('work said:',e.data); | |
}; |
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 getViewportSize(w){ | |
w = w || window; | |
//w3c | |
if( w.innerWidth != null ){ | |
return { w:w.innerWidth,h:innerHeight }; | |
} | |
var d = w.document; |