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
function parseURL(url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return { | |
source: url, | |
protocol: a.protocol.replace(':',''), | |
host: a.hostname, | |
port: a.port, | |
query: a.search, | |
params: (function(){ |
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
<!doctype html> | |
<html> | |
<head> | |
<!-- Run in full-screen mode. --> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<!-- Make the status bar black with white text. --> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black"> |
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 urlparse = require('url').parse | |
, http = require('http') | |
, fs = require('fs'); | |
function upload(url, uploadfile, callback) { | |
var urlinfo = urlparse(url); | |
var options = { | |
method: 'POST', | |
host: urlinfo.host, | |
path: urlinfo.pathname |
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 http = require('http'), | |
url = require('url'), | |
path = require('path'), | |
fs = require('fs'), | |
config = require('./config.js') | |
var PORT = config.PORT; | |
var server = http.createServer(function (request, response) { | |
response.setHeader("Server", "ICBUNBSERVER"); |
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 url = require("url"); | |
var fs = require("fs"); | |
var path = require("path"); | |
var mime = require("./mime").types; | |
var config = require("./config"); | |
var utils = require("./utils"); | |
var zlib = require("zlib"); | |
var staticHandler = function () {}; | |
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 nodeStatic = require('node-static').Server; | |
var request = require("request"); | |
var dns = require("dns"); | |
var fileServer = new nodeStatic("./"); | |
var http = require("http"); | |
var httpServer = http.createServer(function(req, res) { | |
req.addListener('end', function() { | |
fileServer.serve(req, res, function(err, result) { | |
if (err && (err.status === 404)) { |
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
/** | |
* 获得带颜色转义字符的控制台输出模板. | |
* @param {String}tmpl 包含标签的模板字符串 | |
* @param {boolean}isBright 是否高亮,default false | |
* @return {String} | |
* @public | |
*/ | |
function getRichTmpl(tmpl, isBright){ | |
if(typeof tmpl == 'object'){ return tmpl; } | |
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
function XHRWorker(url, ready, scope) { | |
var oReq = new XMLHttpRequest(); | |
oReq.addEventListener('load', function() { | |
var worker = new Worker(window.URL.createObjectURL(new Blob([this.responseText]))); | |
if (ready) { | |
ready.call(scope, worker); | |
} | |
}, oReq); | |
oReq.open("get", url, true); | |
oReq.send(); |
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
function saveAs(blob, filename) { | |
var type = blob.type; | |
var force_saveable_type = 'application/octet-stream'; | |
if (type && type != force_saveable_type) { // 强制下载,而非在浏览器中打开 | |
var slice = blob.slice || blob.webkitSlice; | |
blob = slice.call(blob, 0, blob.size, force_saveable_type); | |
} | |
var url = URL.createObjectURL(blob); | |
var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a'); |
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 x= new ActiveXObject("Msxml2.XMLHTTP.6.0"); | |
x.onreadystatechange=function(){ | |
if(x.readyState<4)return; | |
var xml_dom = new ActiveXObject("MSXML2.DOMDocument"); | |
var tmpNode = xml_dom.createElement("tmpNode"); | |
tmpNode.dataType = "bin.base64"; | |
tmpNode.nodeTypedValue = x.responseBody; | |
base64string=tmpNode.text.replace(/\n/g,""); | |
document.write("<img src=\"data:image/bmp;base64,"+base64string+"\">") | |