switch account

This commit is contained in:
life
2015-02-08 22:07:20 +08:00
parent 41d4529105
commit b7b5d241f7
11 changed files with 302 additions and 69 deletions

20
node_modules/common.js generated vendored
View File

@@ -60,6 +60,26 @@ var Common = {
callback && callback(false);
});
},
inArray: function(arr, item) {
var me = this;
if(!arr) {
return false;
}
for(var i = 0; i < arr.length; i++) {
if(arr[i] == item) {
return true;
}
}
return false;
},
isImageExt: function(ext) {
var me = this;
if(!ext) {
return false;
}
ext = ext.toLowerCase();
return me.inArray(['jpg', 'jpeg', 'bmp', 'png', 'gif'], ext);
},
// 拆分filePath的各个部分
splitFile: function(fullFilePath) {
var ret = {

25
node_modules/file.js generated vendored
View File

@@ -180,6 +180,31 @@ var File = {
}
},
// tinymce 或 mceeditor上传图片
// callback({FileId: "xx"})
uploadImage: function(imagePath, callback) {
var me = this;
// 读取文件, 查看是否是图片
var filePathAttr = Common.splitFile(imagePath);
var ext = filePathAttr.ext;
if(!Common.isImageExt(ext)) {
return callback(false, 'Please select a image');
}
var fileId = Common.objectId();
// 复制到图片文件夹
filePathAttr.nameNotExt = fileId + '_cp_';
var newFilename = fileId + '.' + ext;
var newFilePath = User.getCurUserImagesPath() + '/' + newFilename;
// 复制之, 并写入到数据库中
Common.copyFile(imagePath, newFilePath, function(ret) {
if(ret) {
me._addImage(fileId, newFilePath, callback);
} else {
callback(false);
}
});
},
// 附件操作
addAttach: function(filePaths, noteId, callback) {
if(!noteId || !filePaths) {