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
| /** | |
| * 获得带颜色转义字符的控制台输出模板. | |
| * @param {String}tmpl 包含标签的模板字符串 | |
| * @param {boolean}isBright 是否高亮,default false | |
| * @return {String} | |
| * @public | |
| */ | |
| function getRichTmpl(tmpl, isBright){ | |
| if(typeof tmpl == 'object'){ return tmpl; } | |
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
| 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 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
| 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 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
| 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 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
| 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 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> | |
| <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 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 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 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> | |
| <body> | |
| <p><canvas id="canvas" style="border:2px solid black;" width="200" height="200"></canvas> | |
| <script> | |
| var canvas = document.getElementById("canvas"); | |
| var ctx = canvas.getContext("2d"); | |
| var data = "<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'>" + | |
| "<foreignObject width='100%' height='100%'>" + | |
| "<div xmlns='http://www.w3.org/1999/xhtml' style='font-size:40px'>" + |
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
| //用window.open的方式打开一个中转页面,再在里面执行代码打开(新窗口打开) | |
| function open_new_window(full_link){ | |
| window.open('javascript:window.name;', '<script>location.replace("'+full_link+'")<\/script>'); | |
| } | |
| //其中location.replace刷新页面的方式也可以替换成html自刷新的方式 | |
| var html = '<html><head><meta http-equiv='Refresh' content='0; URL=" 路径 + "' /></head><body></body></html>' | |
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
| var img = new Image, | |
| canvas = document.createElement("canvas"), | |
| ctx = canvas.getContext("2d"), | |
| src = "http://example.com/image"; // 外部域中的图片url | |
| img.crossOrigin = "Anonymous"; | |
| img.onload = function() { | |
| canvas.width = img.width; | |
| canvas.height = img.height; | |
| ctx.drawImage( img, 0, 0 ); |