String.prototype.toWeek=function(){
var date = new Date(this);
var week = "";
switch (date.getDay()) {
case 0:week = "周日";break;
case 1:week = "周一";break;
case 2:week = "周二";break;
case 3:week = "周三";break;
case 4:week = "周四";break;
case 5:week = "周五";break;
case 6:week = "周六";break;
}
return week;
};
上传图片用的是 webuploader.js
function webUpload(obj,fn) {
var width=100;
var height=85;
var uploader = WebUploader.create({
swf: './Uploader.swf',
server: "/itsm/a/file/upload",
pick: {id:obj.pickId},
});
uploader.on('fileQueued', function (file) {
uploader.md5File(file)
.progress(function (percentage) {
console.log('Percentage:', percentage);
})
.then(function (val) {
uploader.options.formData.fileMd5 = val;
uploader.options.formData.fileName = file.name;
uploader.options.formData.__sid = getQueryParam('sessionid');
uploader.options.formData.uploadType="all";
uploader.options.formData.bizType=obj.bizType;
uploader.options.formData.bizKey=obj.bizKey;
console.log(" uploader.options.formData:", uploader.options.formData);
uploader.upload()
});
uploader.makeThumb(file, function (error, src) {
if (error) {
console.log("不能预览")
return;
}
var img=new Image();
img.width=width;
img.height=height;
img.src=src
$(obj.pickId+" .webuploader-pick").html(img);
}, width, height);
});
uploader.on('uploadSuccess', function (file,response ) {
if(response.result=="true"){
$(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-success")
}else{
$(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-error")
}
console.log("上传成功返回值:",JSON.stringify(response))
fn.call(null,response)
});
uploader.on('uploadError', function (file) {
$(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-error")
console.log("上传失败")
});
}
function webUploadVoice(obj,fn) {
var width=100;
var height=85;
var uploader = WebUploader.create({
swf: './js/Uploader.swf',
server: "/itsm/a/file/upload",
pick: {id:obj.pickId},
accept: {
mimeTypes: 'audio/*'
}
});
setTimeout(function(){
$(".webuploader-element-invisible").attr("capture","microphone")
$(".webuploader-element-invisible").removeAttr("multiple")
})
uploader.on('fileQueued', function (file) {
uploader.md5File(file)
.progress(function (percentage) {
console.log('Percentage:', percentage);
})
.then(function (val) {
uploader.options.formData.fileMd5 = val;
uploader.options.formData.fileName = file.name;
uploader.options.formData.__sid = getQueryParam('sessionid');
uploader.options.formData.uploadType="all";
uploader.options.formData.bizType=obj.bizType;
uploader.options.formData.bizKey=obj.bizKey;
console.log(" uploader.options.formData:", uploader.options.formData);
uploader.upload()
});
uploader.makeThumb(file, function (error, src) {
if (error) {
console.log("不能预览")
return;
}
var img=new Image();
img.width=width;
img.height=height;
img.src=src
$(obj.pickId+" .webuploader-pick").html(img);
}, width, height);
});
uploader.on('uploadSuccess', function (file,response ) {
if(response.result=="true"){
$(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-success")
}else{
$(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-error")
}
console.log("上传成功返回值:",JSON.stringify(response))
fn.call(null,response)
});
uploader.on('uploadError', function (file) {
$(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-error")
console.log("上传失败")
});
}
动态插入js
document.write(" <script language="javascript" src="js/vconsole.min.js " > </script>");
document.write(" <script>var aa=new VConsole()</script>");