commit
562b55eb79
@ -1,139 +0,0 @@
|
||||
function Recursion(node){
|
||||
var count=0;
|
||||
for (var key in node) {
|
||||
count++;
|
||||
var value = node[key];
|
||||
delete node[key];
|
||||
//如果node为叶子节点
|
||||
if (key.toString() == '$') {
|
||||
for (var attr in value)
|
||||
node[attr] = value[attr];
|
||||
} else {
|
||||
if (value instanceof Array) {
|
||||
if (value.length > 0) {
|
||||
node["children"] = value;
|
||||
for (var obj in value)
|
||||
Recursion(value[obj]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count==1)
|
||||
node["children"]=[];
|
||||
}
|
||||
|
||||
function randomString(len) {
|
||||
len = len || 32;
|
||||
var $chars = 'abcdefhijkmnprstwxyz'; // 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1
|
||||
var maxPos = $chars.length;
|
||||
var pwd = '';
|
||||
for (i = 0; i < len; i++) {
|
||||
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
|
||||
}
|
||||
return pwd;
|
||||
}
|
||||
|
||||
function compArray(array1,array2){
|
||||
if((array1&&typeof array1 ==="object"&&array1.constructor===Array)&&(array2&&typeof array2 ==="object"&&array2.constructor===Array)){
|
||||
if(array1.length==array2.length){
|
||||
for(var i=0;i<array1.length;i++){
|
||||
var ggg=compObj(array1[i],array2[i]);
|
||||
if(!ggg)
|
||||
return false;
|
||||
}
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
throw new Error("argunment is error ;");
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
function compObj(obj1,obj2){//比较两个对象是否相等,不包含原形上的属性计较
|
||||
if((obj1&&typeof obj1==="object")&&((obj2&&typeof obj2==="object"))){
|
||||
var count1=propertyLength(obj1);
|
||||
var count2=propertyLength(obj2);
|
||||
if(count1==count2){
|
||||
for(var ob in obj1){
|
||||
if(obj1.hasOwnProperty(ob)&&obj2.hasOwnProperty(ob)){
|
||||
if(obj1[ob].constructor==Array&&obj2[ob].constructor==Array){//如果属性是数组
|
||||
if(!compArray(obj1[ob],obj2[ob])){
|
||||
return false;
|
||||
};
|
||||
}else if(typeof obj1[ob]==="string"&&typeof obj2[ob]==="string"){//纯属性
|
||||
if(obj1[ob]!==obj2[ob]){
|
||||
return false;
|
||||
}
|
||||
}else if(typeof obj1[ob]==="object"&&typeof obj2[ob]==="object"){//属性是对象
|
||||
if(!compObj(obj1[ob],obj2[ob])){
|
||||
return false;
|
||||
};
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
function propertyLength(obj){//获得对象上的属性个数,不包含对象原形上的属性
|
||||
var count=0;
|
||||
if(obj&&typeof obj==="object") {
|
||||
for(var ooo in obj) {
|
||||
if(obj.hasOwnProperty(ooo)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}else {
|
||||
throw new Error("argunment can not be null;");
|
||||
}
|
||||
};
|
||||
|
||||
function selectorMatches(selector,labels){
|
||||
if(typeof(selector) === 'object'){
|
||||
var answer = true;
|
||||
var count = 0;
|
||||
for(var key in selector){
|
||||
count++;
|
||||
if(answer && labels[key] !== selector[key])
|
||||
answer = false;
|
||||
}
|
||||
|
||||
return answer && count > 0;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Date.prototype.Format = function(fmt)
|
||||
{ //author: meizz
|
||||
var o = {
|
||||
"M+" : this.getMonth()+1, //月份
|
||||
"d+" : this.getDate(), //日
|
||||
"h+" : this.getHours(), //小时
|
||||
"m+" : this.getMinutes(), //分
|
||||
"s+" : this.getSeconds(), //秒
|
||||
"q+" : Math.floor((this.getMonth()+3)/3), //季度
|
||||
"S" : this.getMilliseconds() //毫秒
|
||||
};
|
||||
if(/(y+)/.test(fmt))
|
||||
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
|
||||
for(var k in o)
|
||||
if(new RegExp("("+ k +")").test(fmt))
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
|
||||
return fmt;
|
||||
}
|
||||
|
||||
exports.randomString = randomString;
|
||||
exports.Recursion = Recursion;
|
||||
exports.compObj = compObj;
|
||||
exports.selectorMatches = selectorMatches;
|
File diff suppressed because one or more lines are too long
@ -1,213 +0,0 @@
|
||||
var fs = require('fs'), path = require('path'), util = require('util'), Stream = require('stream').Stream;
|
||||
|
||||
|
||||
|
||||
module.exports = resumable = function(temporaryFolder){
|
||||
var $ = this;
|
||||
$.temporaryFolder = temporaryFolder;
|
||||
$.maxFileSize = null;
|
||||
$.fileParameterName = 'file';
|
||||
|
||||
try {
|
||||
fs.mkdirSync($.temporaryFolder);
|
||||
}catch(e){}
|
||||
|
||||
|
||||
var cleanIdentifier = function(identifier){
|
||||
return identifier.replace(/^0-9A-Za-z_-/img, '');
|
||||
}
|
||||
|
||||
var getChunkFilename = function(chunkNumber, identifier){
|
||||
// Clean up the identifier
|
||||
identifier = cleanIdentifier(identifier);
|
||||
// What would the file name be?
|
||||
return path.join($.temporaryFolder, './resumable-'+identifier+'.'+chunkNumber);
|
||||
}
|
||||
|
||||
var validateRequest = function(chunkNumber, chunkSize, totalSize, identifier, filename, fileSize){
|
||||
// Clean up the identifier
|
||||
identifier = cleanIdentifier(identifier);
|
||||
|
||||
// Check if the request is sane
|
||||
if (chunkNumber==0 || chunkSize==0 || totalSize==0 || identifier.length==0 || filename.length==0) {
|
||||
return 'non_resumable_request';
|
||||
}
|
||||
var numberOfChunks = Math.max(Math.floor(totalSize/(chunkSize*1.0)), 1);
|
||||
if (chunkNumber>numberOfChunks) {
|
||||
return 'invalid_resumable_request1';
|
||||
}
|
||||
|
||||
// Is the file too big?
|
||||
if($.maxFileSize && totalSize>$.maxFileSize) {
|
||||
return 'invalid_resumable_request2';
|
||||
}
|
||||
|
||||
if(typeof(fileSize)!='undefined') {
|
||||
if(chunkNumber<numberOfChunks && fileSize!=chunkSize) {
|
||||
// The chunk in the POST request isn't the correct size
|
||||
return 'invalid_resumable_request3';
|
||||
}
|
||||
if(numberOfChunks>1 && chunkNumber==numberOfChunks && fileSize!=((totalSize%chunkSize)+chunkSize)) {
|
||||
// The chunks in the POST is the last one, and the fil is not the correct size
|
||||
return 'invalid_resumable_request4';
|
||||
}
|
||||
if(numberOfChunks==1 && fileSize!=totalSize) {
|
||||
// The file is only a single chunk, and the data size does not fit
|
||||
return 'invalid_resumable_request5';
|
||||
}
|
||||
}
|
||||
|
||||
return 'valid';
|
||||
}
|
||||
|
||||
//'found', filename, original_filename, identifier
|
||||
//'not_found', null, null, null
|
||||
$.get = function(req, callback){
|
||||
var chunkNumber = req.param('resumableChunkNumber', 0);
|
||||
var chunkSize = req.param('resumableChunkSize', 0);
|
||||
var totalSize = req.param('resumableTotalSize', 0);
|
||||
var identifier = req.param('resumableIdentifier', "");
|
||||
var filename = req.param('resumableFilename', "");
|
||||
|
||||
if(validateRequest(chunkNumber, chunkSize, totalSize, identifier, filename)=='valid') {
|
||||
var chunkFilename = getChunkFilename(chunkNumber, identifier);
|
||||
fs.exists(chunkFilename, function(exists){
|
||||
if(exists){
|
||||
callback('found', chunkFilename, filename, identifier);
|
||||
} else {
|
||||
callback('not_found', chunkFilename, filename, identifier);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback('not_found2', chunkFilename, filename, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
//'partly_done', filename, original_filename, identifier
|
||||
//'done', filename, original_filename, identifier
|
||||
//'invalid_resumable_request', null, null, null
|
||||
//'non_resumable_request', null, null, null
|
||||
$.post = function(req, callback){
|
||||
|
||||
var fields = req.body;
|
||||
var files = req.files;
|
||||
|
||||
var chunkNumber = fields['resumableChunkNumber'];
|
||||
var chunkSize = fields['resumableChunkSize'];
|
||||
var totalSize = fields['resumableTotalSize'];
|
||||
var identifier = cleanIdentifier(fields['resumableIdentifier']);
|
||||
var filename = fields['resumableFilename'];
|
||||
|
||||
var original_filename = fields['resumableIdentifier'];
|
||||
|
||||
if(!files[$.fileParameterName] || !files[$.fileParameterName].size) {
|
||||
callback('invalid_resumable_request', null, null, null);
|
||||
return;
|
||||
}
|
||||
var validation = validateRequest(chunkNumber, chunkSize, totalSize, identifier, files[$.fileParameterName].size);
|
||||
if(validation=='valid') {
|
||||
var chunkFilename = getChunkFilename(chunkNumber, identifier);
|
||||
|
||||
// Save the chunk (TODO: OVERWRITE)
|
||||
fs.rename(files[$.fileParameterName].path, chunkFilename, function(){
|
||||
|
||||
// Do we have all the chunks?
|
||||
var currentTestChunk = 1;
|
||||
var numberOfChunks = Math.max(Math.floor(totalSize/(chunkSize*1.0)), 1);
|
||||
var testChunkExists = function(){
|
||||
fs.exists(getChunkFilename(currentTestChunk, identifier), function(exists){
|
||||
if(exists){
|
||||
currentTestChunk++;
|
||||
if(currentTestChunk>numberOfChunks) {
|
||||
callback('done', filename, original_filename, identifier);
|
||||
} else {
|
||||
// Recursion
|
||||
testChunkExists();
|
||||
}
|
||||
} else {
|
||||
callback('partly_done', filename, original_filename, identifier);
|
||||
}
|
||||
});
|
||||
}
|
||||
testChunkExists();
|
||||
});
|
||||
} else {
|
||||
callback(validation, filename, original_filename, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pipe chunks directly in to an existsing WritableStream
|
||||
// r.write(identifier, response);
|
||||
// r.write(identifier, response, {end:false});
|
||||
//
|
||||
// var stream = fs.createWriteStream(filename);
|
||||
// r.write(identifier, stream);
|
||||
// stream.on('data', function(data){...});
|
||||
// stream.on('end', function(){...});
|
||||
$.write = function(identifier, writableStream, options) {
|
||||
options = options || {};
|
||||
options.end = (typeof options['end'] == 'undefined' ? true : options['end']);
|
||||
|
||||
// Iterate over each chunk
|
||||
var pipeChunk = function(number) {
|
||||
|
||||
var chunkFilename = getChunkFilename(number, identifier);
|
||||
|
||||
fs.exists(chunkFilename, function(exists) {
|
||||
|
||||
if (exists) {
|
||||
// If the chunk with the current number exists,
|
||||
// then create a ReadStream from the file
|
||||
// and pipe it to the specified writableStream.
|
||||
var sourceStream = fs.createReadStream(chunkFilename);
|
||||
sourceStream.pipe(writableStream, {
|
||||
end: false
|
||||
});
|
||||
sourceStream.on('end', function() {
|
||||
// When the chunk is fully streamed,
|
||||
// jump to the next one
|
||||
pipeChunk(number + 1);
|
||||
});
|
||||
} else {
|
||||
// When all the chunks have been piped, end the stream
|
||||
if (options.end) writableStream.end();
|
||||
if (options.onDone) options.onDone();
|
||||
}
|
||||
});
|
||||
}
|
||||
pipeChunk(1);
|
||||
}
|
||||
|
||||
|
||||
$.clean = function(identifier, options) {
|
||||
options = options || {};
|
||||
|
||||
// Iterate over each chunk
|
||||
var pipeChunkRm = function(number) {
|
||||
|
||||
var chunkFilename = getChunkFilename(number, identifier);
|
||||
|
||||
//console.log('removing pipeChunkRm ', number, 'chunkFilename', chunkFilename);
|
||||
fs.exists(chunkFilename, function(exists) {
|
||||
if (exists) {
|
||||
|
||||
console.log('exist removing ', chunkFilename);
|
||||
fs.unlink(chunkFilename, function(err) {
|
||||
if (err && options.onError) options.onError(err);
|
||||
});
|
||||
|
||||
pipeChunkRm(number + 1);
|
||||
|
||||
} else {
|
||||
|
||||
if (options.onDone) options.onDone();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
pipeChunkRm(1);
|
||||
}
|
||||
|
||||
return $;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,216 +0,0 @@
|
||||
/* 样式重置 */
|
||||
body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{ margin:0; padding:0;}
|
||||
body,table,input,textarea,select,button { font-family: "微软雅黑","宋体"; font-size:12px;line-height:1.5; background:#fff;}
|
||||
div,img,tr,td,table{ border:0;}
|
||||
table,tr,td{border:0;cellspacing:0; cellpadding:0;}
|
||||
ol,ul,li{ list-style-type:none}
|
||||
a:link,a:visited{color:#7f7f7f;text-decoration:none;}
|
||||
a:hover,a:active{color:#000;}
|
||||
.fl{ float:left;}
|
||||
.fr{ float:right;}
|
||||
.cl{ clear:both; overflow:hidden;}
|
||||
|
||||
/* 数据页面 */
|
||||
.data_container{
|
||||
width:100%;
|
||||
margin:0 auto;
|
||||
}
|
||||
.data_heaer{
|
||||
height:66px;
|
||||
width:100%;
|
||||
background-color:#3499db;
|
||||
text-align:center;
|
||||
}
|
||||
.data_heaer h2{
|
||||
font-size:30px;
|
||||
font-weight:300;
|
||||
color:#fff;
|
||||
line-height:66px;
|
||||
}
|
||||
.data_content{
|
||||
width:1280px;
|
||||
height:838px;
|
||||
margin:0 auto;
|
||||
background-color:#fff;
|
||||
border:1px solid #e0dede;
|
||||
border-top:none;
|
||||
}
|
||||
.data_leftside{
|
||||
width:612px;
|
||||
border-right:1px solid #e0dede;
|
||||
}
|
||||
.data_h3{
|
||||
width:100%;
|
||||
text-align:center;
|
||||
height:50px;
|
||||
font-size:18px;
|
||||
color:#444;
|
||||
line-height:50px;
|
||||
}
|
||||
.data_leftside_files{
|
||||
border-right:1px solid #e0dede;
|
||||
border-bottom:1px solid #e0dede;
|
||||
height:710px;
|
||||
overflow :auto;
|
||||
}
|
||||
.data_leftside_files input{
|
||||
margin-top:15px;
|
||||
width:15px;
|
||||
height:15px;
|
||||
}
|
||||
.data_leftside_files li{
|
||||
height:40px;
|
||||
line-height:40px;
|
||||
border-bottom:1px solid #e0dede;
|
||||
padding:0 10px;
|
||||
}
|
||||
.data_leftside_files li.data_title{
|
||||
width:210px; height:36px;
|
||||
line-height:36px;
|
||||
text-align:center;
|
||||
background-color:#e9f3fb;
|
||||
border:none;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
-o-text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
}
|
||||
.date_label{
|
||||
display:block;
|
||||
width:168px;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
-o-text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
}
|
||||
.data_leftside_shu{
|
||||
border-right:none;
|
||||
}
|
||||
.data_leftside_shu li{
|
||||
border-bottom:none;
|
||||
}
|
||||
.data_conbar{ width:149px;
|
||||
height:834px;
|
||||
border-right:1px solid #e0dede;
|
||||
border-left:1px solid #e0dede;
|
||||
}
|
||||
.date_btns{
|
||||
width:260px;
|
||||
margin:20px auto;
|
||||
}
|
||||
.date_btns_w{
|
||||
width:390px;
|
||||
}
|
||||
.date_btns button{
|
||||
margin:10px 20px;
|
||||
}
|
||||
.data_btn{
|
||||
border:none;
|
||||
width:108px;
|
||||
height:35px;
|
||||
line-height:35px;
|
||||
text-align:center;
|
||||
background-color:#3499db;
|
||||
color:#fff;
|
||||
font-size:14px;
|
||||
-webkit-border-radius:5px;
|
||||
-moz-border-radius:5px;
|
||||
-o-border-radius:5px;
|
||||
border-radius:5px;
|
||||
}
|
||||
.data_btn:hover{
|
||||
background-color:#2989da;
|
||||
}
|
||||
.data_rightside{
|
||||
width:667px;
|
||||
}
|
||||
.data_rightside_w{
|
||||
width:407px;
|
||||
}
|
||||
.data_leftside_files li.data_title_w{
|
||||
width:183px;
|
||||
}
|
||||
.date_label_w{
|
||||
width:150px;
|
||||
}
|
||||
.data_leftside_shu li{
|
||||
border-bottom:none;
|
||||
}
|
||||
|
||||
a.data_file_btn{ display:block; position:relative; width:108px; height:35px; margin:15px auto; line-height:35px; font-size:14px; color: #fff; text-align:center;
|
||||
background-color: #79b4e7;
|
||||
background-image: -webkit-linear-gradient(#79b4e7, #1377cf);
|
||||
background-image: linear-gradient(#79b4e7, #1377cf);
|
||||
border-color: #076bc2;
|
||||
-webkit-border-radius:5px;
|
||||
-moz-border-radius:5px;
|
||||
-o-border-radius:5px;
|
||||
border-radius:5px;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
margin:0 10px;
|
||||
}
|
||||
a:hover.data_file_btn{
|
||||
background-color: #076bc2;
|
||||
background-image: -webkit-linear-gradient(#79b4e7, #076bc2);
|
||||
background-image: linear-gradient(#79b4e7, #076bc2);
|
||||
border-color: #076bc2;}
|
||||
.data_file_btn input{ position:absolute; left:0px;opacity:0; filter:alpha(opacity=0); width:108px; height:35px;}
|
||||
|
||||
|
||||
.data_conbox{
|
||||
width:407px;
|
||||
height:709px;
|
||||
border-top:1px solid #e0dede;
|
||||
border-bottom:1px solid #e0dede;
|
||||
overflow: auto;
|
||||
}
|
||||
.data_con_title{
|
||||
width:49.8%;
|
||||
height:36px;
|
||||
line-height:36px;
|
||||
text-align:center;
|
||||
background-color:#e9f3fb;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
-o-text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
}
|
||||
.data_con_line{
|
||||
border-right:1px solid #e0dede;
|
||||
|
||||
}
|
||||
.data_con_li{
|
||||
width:49.8%;
|
||||
height:36px;
|
||||
line-height:36px;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
-o-text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
border-bottom:1px solid #e0dede;
|
||||
}
|
||||
.mt15{ margin-top:15px;}
|
||||
|
||||
|
||||
/* 树形结构 */
|
||||
.data_rightside_tree{
|
||||
width:259px;
|
||||
height:709px;
|
||||
border-right:1px solid #e0dede;
|
||||
border-top:1px solid #e0dede;
|
||||
border-bottom:1px solid #e0dede;
|
||||
overflow: auto;
|
||||
}
|
||||
.tree { min-height:20px;padding:15px;padding-left:30px;border-bottom:1px dashed #ccc;}
|
||||
.tree li {list-style-type:none;margin:0; padding:10px 5px 0 20px; position:relative}
|
||||
.tree li::before, .tree li::after { content:'';left:-30px;position:absolute; right:auto}
|
||||
.tree li::before { border-left:1px solid #999; bottom:50px;height:100%; top:0; width:0px}
|
||||
.tree li::after {border-top:1px solid #999;height:20px; top:25px; width:35px}
|
||||
.tree li p {display:inline-block;padding:3px 10px;border:1px solid #fff; margin-left:-15px; width:150px; }
|
||||
.tree li.parent_li>p {cursor:pointer}
|
||||
.tree>ul>li::before, .tree>ul>li::after {border:0}
|
||||
.tree li:last-child::before { height:30px}
|
||||
.tree li.parent_li>p:hover, .tree li.parent_li>p:hover+ul li p { }
|
||||
.icon-plus-sign{ margin-left:-15px; background:url(../img/icons1.gif) -5px 10px no-repeat; }
|
||||
.icon-minus-sign{ margin-left:-15px; background:url(../img/icons2.gif) -6px 9px no-repeat;}
|
@ -1 +0,0 @@
|
||||
1
|
@ -0,0 +1,10 @@
|
||||
/// <reference path="../../includes.d.ts" />
|
||||
/// <reference path="developerHelpers.d.ts" />
|
||||
declare module Developer {
|
||||
var _module: ng.IModule;
|
||||
var controller: (name: string, inlineAnnotatedConstructor: any[]) => ng.IModule;
|
||||
var route: (templateName: string, reloadOnSearch?: boolean) => {
|
||||
templateUrl: string;
|
||||
reloadOnSearch: boolean;
|
||||
};
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
/// <reference path="../../includes.d.ts" />
|
||||
/// <reference path="developerHelpers.d.ts" />
|
||||
declare module Developer {
|
||||
var _module: ng.IModule;
|
||||
var controller: (name: string, inlineAnnotatedConstructor: any[]) => ng.IModule;
|
||||
var route: (templateName: string, reloadOnSearch?: boolean) => {
|
||||
templateUrl: string;
|
||||
reloadOnSearch: boolean;
|
||||
};
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
/// <reference path="../../includes.d.ts" />
|
||||
/// <reference path="developerHelpers.d.ts" />
|
||||
declare module Developer {
|
||||
var _module: ng.IModule;
|
||||
var controller: (name: string, inlineAnnotatedConstructor: any[]) => ng.IModule;
|
||||
var route: (templateName: string, reloadOnSearch?: boolean) => {
|
||||
templateUrl: string;
|
||||
reloadOnSearch: boolean;
|
||||
};
|
||||
}
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -1,24 +0,0 @@
|
||||
function Recursion(node){
|
||||
var count=0;
|
||||
for (var key in node) {
|
||||
count++;
|
||||
var value = node[key];
|
||||
delete node[key];
|
||||
//如果node为叶子节点
|
||||
if (key.toString() == '$') {
|
||||
for (var attr in value)
|
||||
node[attr] = value[attr];
|
||||
} else {
|
||||
if (value instanceof Array) {
|
||||
if (value.length > 0) {
|
||||
node["children"] = value;
|
||||
for (var obj in value)
|
||||
Recursion(value[obj]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count==1)
|
||||
node["children"]=[];
|
||||
}
|
||||
exports.Recursion=Recursion;
|
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 98 KiB |
@ -0,0 +1,85 @@
|
||||
/* 样式重置 */
|
||||
body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{ margin:0; padding:0;}
|
||||
body,table,input,textarea,select,button { font-family: "微软雅黑","宋体"; font-size:12px;line-height:1.5; background:#fff;}
|
||||
div,img,tr,td,table{ border:0;}
|
||||
table,tr,td{border:0;cellspacing:0; cellpadding:0;}
|
||||
ol,ul,li{ list-style-type:none}
|
||||
a:link,a:visited{color:#7a7a7a;text-decoration:none;}
|
||||
a:hover,a:active{color:#333;}
|
||||
|
||||
|
||||
/* 清除 */
|
||||
.clear{ zoom:1;}
|
||||
.clear:after {content:".";height:0;visibility:hidden;display:block;clear:both;}
|
||||
.fl{ float:left;}
|
||||
.fr{ float:right;}
|
||||
.cl{ clear:both; overflow:hidden;}
|
||||
/* public*/
|
||||
.ml5{ margin-top: 5px;}.ml10{ margin-top: 10px;}
|
||||
.ml5{ margin-left:5px;}.ml10{ margin-left:10px;}
|
||||
.mr5{ margin-right:5px;}.mr10{ margin-right:10px;}
|
||||
a.sj_btn_grey{ display:inline-block; padding:0px 15px; height:30px; line-height:30px; -webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;border-radius:3px; background-image:-webkit-linear-gradient(top, #fdfdfd,#e8e8e8);background-image:linear-gradient(top,#fdfdfd,#e8e8e8); border:1px solid #cecece; color:#505050;}
|
||||
a:hover.sj_btn_grey{ background-image:-webkit-linear-gradient(top, #eeeeee,#d3d3d3);background-image:linear-gradient(top,#eeeeee,#d3d3d3);}
|
||||
.sj_btn_grey{ display:inline-block; padding:0px 15px; height:30px; line-height:30px; -webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;border-radius:3px; background-image:-webkit-linear-gradient(top, #fdfdfd,#e8e8e8);background-image:linear-gradient(top,#fdfdfd,#e8e8e8); border:1px solid #cecece; color:#505050;}
|
||||
.sj_btn_grey:hover{ background-image:-webkit-linear-gradient(top, #eeeeee,#d3d3d3);background-image:linear-gradient(top,#eeeeee,#d3d3d3);}
|
||||
/* sj_header */
|
||||
.sj_header{ height:70px; width:100%; background:#1d1d1d;}
|
||||
.sj_header a.sj_logo{ display:block; height:41px; width:146px; padding:14px 20px 0 12px;}
|
||||
.sj_topnav{ height:70px; width:100%; padding-left: 180px; }
|
||||
.sj_topnav li a{ height:70px; line-height:70px; font-size:14px; color:#fff; padding:0 20px;}
|
||||
.sj_topnav li a:hover,.sj_topnav li a.sj_topnav_active{ background-image:-webkit-linear-gradient(top, #424242,#323232);background-image:linear-gradient(top,#424242,#323232); }
|
||||
/* sj_content */
|
||||
.sj_content{ width:100%; position:relative; color:#505050;}
|
||||
.sj_leftnav{ width:170px; min-height:800px; max-height:985px; background:#1d1d1d; position:absolute; left:0; top:0px;}
|
||||
.sj_leftnav_i{ background:#717171; padding:0 5px;;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;border-radius:3px; margin-left:80px; }
|
||||
.sj_menu {margin-top:12px;background:#1d1d1d; }
|
||||
.sj_menu_nav { background-image:-webkit-linear-gradient(top, #404040,#353535);background-image:linear-gradient(top,#404040,#353535); color: #fff; height:40px; line-height:38px; padding-left:15px; border: none; border-top: 2px solid #4d4d4d; border-bottom: 2px solid #1d1d1d;}
|
||||
.sj_menu_nav:hover{ background-image:-webkit-linear-gradient(top, #535353,#353535);background-image:linear-gradient(top,#535353,#353535);}
|
||||
.sj_menu_nav i{ font-style: normal;}
|
||||
.sj_menu_nav a{ color: #fff;}
|
||||
.sj_menu .sj_menu_nav ul{background: #1d1d1d; color: #fff;padding-left: 20px; border:none;}
|
||||
.sj_menu_ul{ }
|
||||
.sj_menu_ul li a{ display: block; background: #1d1d1d; color: #fff;padding-left: 30px; height: 40px; line-height: 40px; }
|
||||
.sj_menu_ul li a:hover{background: #fff; color:#1d1d1d;}
|
||||
|
||||
|
||||
#menu li a:hover { background-image:-webkit-linear-gradient(top, #535353,#353535);background-image:linear-gradient(top,#535353,#353535);}
|
||||
#menu li ul li a { background: #1d1d1d; color: #fff;padding-left: 20px; border:none;}
|
||||
#menu li ul li a:hover,.sj_leftnav ul#menu li ul li .leftnavact { background: #fff; color:#1d1d1d;}
|
||||
.sj_menu_01{ background:url(../new/images/sj_icons.png) 0 0px no-repeat; padding-left:20px;}
|
||||
.sj_menu_02{ background:url(../new/images/sj_icons.png) 0 -29px no-repeat; padding-left:20px;}
|
||||
.sj_menu_03{ background:url(../new/images/sj_icons.png) 0 -112px no-repeat; padding-left:20px;}
|
||||
.sj_menu_04{ background:url(../new/images/sj_icons.png) 0 -133px no-repeat; padding-left:20px;}
|
||||
.sj_contentbox{ width:100%; background:#fff; min-height:800px; }
|
||||
.sj_icons_home{ background:url(../new/images/sj_icons.png) 0 -60px no-repeat; width:15px; height:15px; margin-top:10px; margin-right:3px;}
|
||||
.sj_content_position{ background:#eee; height:35px; line-height:35px; color:#7a7a7a; margin:2px 0 0 170px; padding-left:20px;}
|
||||
.sj_content_position ul li{ float:left;}
|
||||
.sj_filter li{ float:left;}
|
||||
.sj_filter li a{ display: inline-block; border:1px solid #cecece;background-image:-webkit-linear-gradient(top, #fcfcfc,#e9e9e9);background-image:linear-gradient(top, #fcfcfc,#e9e9e9); padding:5px 15px; color:#505050; margin-right:5px;}
|
||||
.sj_filter li a:hover,.sj_filter li a.active{ background:#cdcdcd; border:1px solid #9e9e9e;}
|
||||
.sj_content_top{ margin:20px 20px 0 190px;}
|
||||
.sj_searchbox{position:relative;}
|
||||
.sj_search_input{-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;border-radius:3px; border:1px solid #d3d3d3; background:#fff; padding-left:5px; color:#888; height:28px; width:210px;box-shadow: inset 0px 0px 5px #dcdcdc; }
|
||||
.sj_searchbox a.sj_search_btn{ position:absolute; top:5px; right:5px; background:url(../new/images/sj_icons.png) 0 -82px no-repeat; display:block; width:20px; height:20px; }
|
||||
/* table */
|
||||
.sj_content_table{ }
|
||||
.sj_content_table > tbody > tr > td{ height:36px; line-height:36px;}
|
||||
.sj_content_table tr td.tl{ text-align:left;}
|
||||
.sj_content_table .table-header{background-image:-webkit-linear-gradient(top, #f7f7f7,#dfdfdf);background-image:linear-gradient(top, #f7f7f7,#dfdfdf); border-bottom:1px solid #a6a6a6;}
|
||||
.sj_content_table > thead > tr > th{ height:36px; line-height:36px;}
|
||||
.sj_content_table .sj_tr_grey{ background:#f3f3f3;}
|
||||
.sj_table_td01{ width:2%;}
|
||||
.sj_table_td02{ width:9%;}
|
||||
.sj_table_td03{ width:22%;}
|
||||
.sj_table_td04{ width:14%;}
|
||||
.sj_table_td05{ width:13%;}
|
||||
.sj_table_td06{ width:10%;}
|
||||
.sj_table_td07{ width:30%;}
|
||||
.sj_table_td08{ width:60%;}
|
||||
.sj_table_td09{ width:70%;}
|
||||
.sj_over_hid{ display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
.sj_content_table table tr td input{ margin-top:15px;}
|
||||
.sj_content_table .sj_table_top td{ border-bottom:1px solid #a6a6a6; font-weight:bold; border-right:1px solid #ccc;}
|
||||
.sj_table_bottom{ height:30px; line-height:30px; }
|
||||
.sj_table_bottom li{ float:left;}
|
||||
.sj_table_select{ background:#fff; border:1px solid #b1b1b1; height:25px; margin:0 5px;}
|
Binary file not shown.
@ -1,213 +0,0 @@
|
||||
var fs = require('fs'), path = require('path'), util = require('util'), Stream = require('stream').Stream;
|
||||
|
||||
|
||||
|
||||
module.exports = resumable = function(temporaryFolder){
|
||||
var $ = this;
|
||||
$.temporaryFolder = temporaryFolder;
|
||||
$.maxFileSize = null;
|
||||
$.fileParameterName = 'file';
|
||||
|
||||
try {
|
||||
fs.mkdirSync($.temporaryFolder);
|
||||
}catch(e){}
|
||||
|
||||
|
||||
var cleanIdentifier = function(identifier){
|
||||
return identifier.replace(/^0-9A-Za-z_-/img, '');
|
||||
}
|
||||
|
||||
var getChunkFilename = function(chunkNumber, identifier){
|
||||
// Clean up the identifier
|
||||
identifier = cleanIdentifier(identifier);
|
||||
// What would the file name be?
|
||||
return path.join($.temporaryFolder, './resumable-'+identifier+'.'+chunkNumber);
|
||||
}
|
||||
|
||||
var validateRequest = function(chunkNumber, chunkSize, totalSize, identifier, filename, fileSize){
|
||||
// Clean up the identifier
|
||||
identifier = cleanIdentifier(identifier);
|
||||
|
||||
// Check if the request is sane
|
||||
if (chunkNumber==0 || chunkSize==0 || totalSize==0 || identifier.length==0 || filename.length==0) {
|
||||
return 'non_resumable_request';
|
||||
}
|
||||
var numberOfChunks = Math.max(Math.floor(totalSize/(chunkSize*1.0)), 1);
|
||||
if (chunkNumber>numberOfChunks) {
|
||||
return 'invalid_resumable_request1';
|
||||
}
|
||||
|
||||
// Is the file too big?
|
||||
if($.maxFileSize && totalSize>$.maxFileSize) {
|
||||
return 'invalid_resumable_request2';
|
||||
}
|
||||
|
||||
if(typeof(fileSize)!='undefined') {
|
||||
if(chunkNumber<numberOfChunks && fileSize!=chunkSize) {
|
||||
// The chunk in the POST request isn't the correct size
|
||||
return 'invalid_resumable_request3';
|
||||
}
|
||||
if(numberOfChunks>1 && chunkNumber==numberOfChunks && fileSize!=((totalSize%chunkSize)+chunkSize)) {
|
||||
// The chunks in the POST is the last one, and the fil is not the correct size
|
||||
return 'invalid_resumable_request4';
|
||||
}
|
||||
if(numberOfChunks==1 && fileSize!=totalSize) {
|
||||
// The file is only a single chunk, and the data size does not fit
|
||||
return 'invalid_resumable_request5';
|
||||
}
|
||||
}
|
||||
|
||||
return 'valid';
|
||||
}
|
||||
|
||||
//'found', filename, original_filename, identifier
|
||||
//'not_found', null, null, null
|
||||
$.get = function(req, callback){
|
||||
var chunkNumber = req.param('resumableChunkNumber', 0);
|
||||
var chunkSize = req.param('resumableChunkSize', 0);
|
||||
var totalSize = req.param('resumableTotalSize', 0);
|
||||
var identifier = req.param('resumableIdentifier', "");
|
||||
var filename = req.param('resumableFilename', "");
|
||||
|
||||
if(validateRequest(chunkNumber, chunkSize, totalSize, identifier, filename)=='valid') {
|
||||
var chunkFilename = getChunkFilename(chunkNumber, identifier);
|
||||
fs.exists(chunkFilename, function(exists){
|
||||
if(exists){
|
||||
callback('found', chunkFilename, filename, identifier);
|
||||
} else {
|
||||
callback('not_found', chunkFilename, filename, identifier);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback('not_found2', chunkFilename, filename, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
//'partly_done', filename, original_filename, identifier
|
||||
//'done', filename, original_filename, identifier
|
||||
//'invalid_resumable_request', null, null, null
|
||||
//'non_resumable_request', null, null, null
|
||||
$.post = function(req, callback){
|
||||
|
||||
var fields = req.body;
|
||||
var files = req.files;
|
||||
|
||||
var chunkNumber = fields['resumableChunkNumber'];
|
||||
var chunkSize = fields['resumableChunkSize'];
|
||||
var totalSize = fields['resumableTotalSize'];
|
||||
var identifier = cleanIdentifier(fields['resumableIdentifier']);
|
||||
var filename = fields['resumableFilename'];
|
||||
|
||||
var original_filename = fields['resumableIdentifier'];
|
||||
|
||||
if(!files[$.fileParameterName] || !files[$.fileParameterName].size) {
|
||||
callback('invalid_resumable_request', null, null, null);
|
||||
return;
|
||||
}
|
||||
var validation = validateRequest(chunkNumber, chunkSize, totalSize, identifier, files[$.fileParameterName].size);
|
||||
if(validation=='valid') {
|
||||
var chunkFilename = getChunkFilename(chunkNumber, identifier);
|
||||
|
||||
// Save the chunk (TODO: OVERWRITE)
|
||||
fs.rename(files[$.fileParameterName].path, chunkFilename, function(){
|
||||
|
||||
// Do we have all the chunks?
|
||||
var currentTestChunk = 1;
|
||||
var numberOfChunks = Math.max(Math.floor(totalSize/(chunkSize*1.0)), 1);
|
||||
var testChunkExists = function(){
|
||||
fs.exists(getChunkFilename(currentTestChunk, identifier), function(exists){
|
||||
if(exists){
|
||||
currentTestChunk++;
|
||||
if(currentTestChunk>numberOfChunks) {
|
||||
callback('done', filename, original_filename, identifier);
|
||||
} else {
|
||||
// Recursion
|
||||
testChunkExists();
|
||||
}
|
||||
} else {
|
||||
callback('partly_done', filename, original_filename, identifier);
|
||||
}
|
||||
});
|
||||
}
|
||||
testChunkExists();
|
||||
});
|
||||
} else {
|
||||
callback(validation, filename, original_filename, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pipe chunks directly in to an existsing WritableStream
|
||||
// r.write(identifier, response);
|
||||
// r.write(identifier, response, {end:false});
|
||||
//
|
||||
// var stream = fs.createWriteStream(filename);
|
||||
// r.write(identifier, stream);
|
||||
// stream.on('data', function(data){...});
|
||||
// stream.on('end', function(){...});
|
||||
$.write = function(identifier, writableStream, options) {
|
||||
options = options || {};
|
||||
options.end = (typeof options['end'] == 'undefined' ? true : options['end']);
|
||||
|
||||
// Iterate over each chunk
|
||||
var pipeChunk = function(number) {
|
||||
|
||||
var chunkFilename = getChunkFilename(number, identifier);
|
||||
|
||||
fs.exists(chunkFilename, function(exists) {
|
||||
|
||||
if (exists) {
|
||||
// If the chunk with the current number exists,
|
||||
// then create a ReadStream from the file
|
||||
// and pipe it to the specified writableStream.
|
||||
var sourceStream = fs.createReadStream(chunkFilename);
|
||||
sourceStream.pipe(writableStream, {
|
||||
end: false
|
||||
});
|
||||
sourceStream.on('end', function() {
|
||||
// When the chunk is fully streamed,
|
||||
// jump to the next one
|
||||
pipeChunk(number + 1);
|
||||
});
|
||||
} else {
|
||||
// When all the chunks have been piped, end the stream
|
||||
if (options.end) writableStream.end();
|
||||
if (options.onDone) options.onDone();
|
||||
}
|
||||
});
|
||||
}
|
||||
pipeChunk(1);
|
||||
}
|
||||
|
||||
|
||||
$.clean = function(identifier, options) {
|
||||
options = options || {};
|
||||
|
||||
// Iterate over each chunk
|
||||
var pipeChunkRm = function(number) {
|
||||
|
||||
var chunkFilename = getChunkFilename(number, identifier);
|
||||
|
||||
//console.log('removing pipeChunkRm ', number, 'chunkFilename', chunkFilename);
|
||||
fs.exists(chunkFilename, function(exists) {
|
||||
if (exists) {
|
||||
|
||||
console.log('exist removing ', chunkFilename);
|
||||
fs.unlink(chunkFilename, function(err) {
|
||||
if (err && options.onError) options.onError(err);
|
||||
});
|
||||
|
||||
pipeChunkRm(number + 1);
|
||||
|
||||
} else {
|
||||
|
||||
if (options.onDone) options.onDone();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
pipeChunkRm(1);
|
||||
}
|
||||
|
||||
return $;
|
||||
}
|
Loading…
Reference in new issue