Skip to content

Instantly share code, notes, and snippets.

Avatar
🐜
ant has power

hacke2 hacke2

🐜
ant has power
View GitHub Profile
@hacke2
hacke2 / randomMN.js
Created Aug 25, 2014
m-n的随机数
View randomMN.js
parseInt(Math.random())*(n-m)+m;
@hacke2
hacke2 / htmlEscape.js
Created Aug 25, 2014
处理一些文本里的HTML标签
View htmlEscape.js
function htmlEscape(text) {
return text.replace(/[<>"&]/g, function(match, pos, originalText){
switch(match) {
case "<" : return "&lt;";
case ">" : return "&gt;";
case "\"" : return "&amp;";
case "&" : return "&quot;";
}
});
}
View drag.js
var drag = document.getElementById('drag');
var inputX = document.getElementById('x');
var inputY = document.getElementById('y');
if(document.attachEvent){
drag.attachEvent('onmousedown',dragHandle);
}else{
drag.addEventListener('mousedown', dragHandle,false);
}
function dragHandle(event){
var event = event||window.event;
@hacke2
hacke2 / ajax.js
Last active Aug 29, 2015
自己封装的JAJAX
View ajax.js
function Ajax(parametObject) {
var xhr, responseType, defineParam, method, url, data;
defineParam = {
method : "GET",
type : "json"
}
url = parametObject.url;
data = parametObject.data;
responseType = parametObject.type || defineParam.type;