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 MyModules = (function Manager () { | |
var modules = {} | |
function define (name, deps, impl) { | |
for (var i = 0; i < deps.length; i++) { | |
deps[i] = modules[deps[i]] | |
} | |
modules[name] = impl.apply(impl, deps) | |
} |
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 baseVersion='V2.2'; //基础版本 | |
var version = ''; //版本号,默认按V2.1.3.2格式 | |
//输出目录 | |
var outputFolder = 'D:/release/{version}'; | |
//只复制不压缩的文件,以,分隔 | |
var srcFolder='sourcePackage'; | |
var copyFiles = 'js/config.js,*.doc'; | |
var md5File = 'MD5.txt'; | |
var zipFile = 'sourcePackage.{version}.zip'; |
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
/** | |
* 以字符串形式返回o 的类型: | |
* - 如果o 是null,如果o 是NaN,返回“nan” | |
* - 如果typeof 所返回的值不是“object”,则返回这个值 | |
* -(注意,有一些JavaScript 的实现将正则表达式识别为函数) | |
* - 如果o 的类不是“Object”, 则返回这个值 | |
* - 如果o 包含构造函数并且这个构造函数具有名称,则返回这个类 | |
* - 否则,一律返回“Object” | |
*/ | |
function type(o) { |
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
// 例6-2:用来枚举属性的对象工具函数 | |
/* | |
* 把p 中的可枚举属性复制到o 中,并返回o | |
* 如果o 和p 中含有同名属性,则覆盖o 中的属性 | |
* 这个函数并不处理getter 和setter 以及复制属性 | |
*/ | |
function extend(o, p){ | |
for(prop in p){ // 遍历p 中的所有属性 | |
o[prop] = p[prop]; // 将属性添加至o 中 | |
} |
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 inherit(p){ | |
if(p==null) throw TypeError(); | |
if(Object.create) | |
return Object.create(p); | |
var t = typeof p; | |
if(t!=="object" && t!=="function") throw TypeError(); | |
function f(){} | |
f.prototype = p; | |
return new f(); | |
} |
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
/* | |
* 这是运行在NodeJS 上的服务器端JavaScript | |
* 在HTTP 服务器之上,它运行一个WebSocket 服务器,该服务器使用来自 | |
* https://github.com/miksago/node-websocket-server/ 的第三方WebSocket 库实现 | |
* 如果得到“/” 的一个HTTP 请求,则返回聊天客户端的HTML 文件 | |
* 除此之外任何HTTP 请求都返回404 | |
* 通过WebSocket 协议接收到的消息都仅广播给所有激活状态的连接 | |
*/ | |
var http = require("http"); // 使用Node 的HTTP 服务器API | |
var ws = require("websocket-server");// 使用第三方WebSocket 库 |
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
// WebSocket API 的使用非常简单。 | |
// 首先,通过WebSocket() 构造函数创建一个套接字: | |
var socket = new WebSocket("ws://ws.example.com:1234/resource"); | |
// 创建套接字之后,通常需要在上面注册一个事件处理程序: | |
socket.onopen = function(e){ | |
/* 套接字已经连接 */ | |
}; | |
socket.onclose = function(e){ | |
/* 套接字已经关闭。*/ |
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="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Zipcode Database</title> | |
<script> | |
// IndexedDB 的实现仍然使用API 前缀 | |
var indexedDB = window.indexedDB || // 使用标准的DB API | |
window.mozIndexedDB || // 或者Firefox 早期版本的IndexedDB | |
window.webkitIndexedDB; // 或者Chrome 早期版本 |
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 fs = requestFileSystemSync(PERSISTENT, 1024*1024); | |
// 异步版本的API 需要使用回调函数来处理成功和失败的情况 | |
requestFileSystem(TEMPORARY, // 有效期 | |
50*1024*1024, // 大小:50MB | |
function(fs){ // fs 就是该文件系统对象 | |
// 这里使用fs 进行一些操作 | |
}, |
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
<script> | |
// 检测指定的blob 的前4 个字节 | |
// 如果这个幻数标识文件的类型,那么就将其异步地设置程Blob 的属性 | |
function typefile(file){ | |
var slice = file.slice(0, 4); // 只读取文件起始部分 | |
var reader = new FileReader(); // 创建一个异步的FileReader 对象 | |
reader.readAsArrayBuffer(slice); // 读取文件片段 | |
reader.onload = function(e){ | |
var buffer = reader.result; // ArrayBuffer 形式的结果 | |
var view = new DataView(buffer); // 访问结果中的字节内容 |
NewerOlder