把一下代码直接复制到html中,运行一下,再回头研究下,主要用 微软 运行时组件(ActiveXObject)
______________________
"http://www.w3.org/TR/html4/loose.dtd">
mmsCreator
添加彩信素材,生成彩信
添加附件
var ID=1;
var isValid=false;
var fso=new ActiveXObject("Scripting.FileSystemObject");
//添加附件
function addAttach(obj){
fileID="element"+ID;
var objChild=document.createElement("div"); //构造条状容器对象
var file= document.createElement(""); //生成file
file.id=fileID; //设置fileID
file.name=fileID; //设置fileName
var timeField=document.createElement(""); //时间字段
timeField.name=fileID;
timeField.value=1;
timeField.title="输入时间,如 10";
timeField.attachEvent("onkeyup",fun(timeField,null,'checkNum')); //附件事件
var timeSelect=document.createElement("select");
timeSelect.name=fileID;
var second=document.createElement("option");
second.text="秒钟";
second.value="s"
second.title="时间单位:秒钟";
var minute=document.createElement("option");
minute.text="分钟";
minute.value="min";
second.title="时间单位:分钟";
var hour=document.createElement("option");
hour.text="小时";
hour.value="h";
second.title="时间单位:小时";
timeSelect.add(minute);
timeSelect.add(second);
timeSelect.add(hour);
var split1=document.createElement("
");
split1.name=fileID;
//
var myA= document.createElement("A"); //生成 删除
myA.innerHTML="删";
myA.href="javascript:void(0)";
myA.name=fileID;
myA.attachEvent("onclick",fun(obj,objChild,'del')); //附件事件
//组合
objChild.insertBefore(file);
objChild.insertBefore(timeField);
objChild.insertBefore(timeSelect);
objChild.insertBefore(myA);
objChild.insertBefore(split1);
obj.appendChild(objChild);
obj.refresh;
if(document.getElementById("done")==null){ //若无 完成,则建
var create=document.createElement("a");
create.id="done";
create.innerHTML="完成";
create.href="javascript:void(0)";
create.attachEvent("onclick",fun(obj,null,'done'));
document.body.appendChild(create);
document.body.refresh;
}
ID++;
}
//关联事件(关联到removeElement)
var fun=function(parentObj,childArray,flag){
if(flag=="del"){
return function(){
removeElement(parentObj,childArray)
}
}else if(flag=="done"){
return function(){
done(parentObj);
}
}else if(flag=="checkNum"){
return function(){
parentObj.value=parentObj.value.replace(/[^/d]/g,'');
}
}
}
//删除
function removeElement(obj,objChild){
if(obj.contains(objChild))
obj.removeChild(objChild);
//若 无附件,则无 完成
var objs = obj.getElementsByTagName("div");
if(objs.length==0){
document.body.removeChild(document.getElementById("done"));
}
}
//鉴定数字
function checkNumber(parent){
}
function done(obj){
var paths=new Array();
var path="";
var time=5;
var timeType="m";
var objs = obj.getElementsByTagName("div");
//smil header
var smil = ""
+ ""
+ ""
+ ""
+ ". width='126' height='126'/>"
+ ".. "
+ ".. "
+ "." + "" +
"";
for(i=0;i
for(j=0;j
var one=objs[i].children[j];
//非空
if(one.nodeName=="INPUT"&&one.value==""){
one.focus();
return;
}
if(one.nodeName=="INPUT"&&one.getAttribute("type")=="file"){
path=one.value;
}else if(one.nodeName=="INPUT"&&one.getAttribute("type")=="text"){
time=parseInt(one.value);
}else if(one.nodeName=="SELECT"&&one.getAttribute("type")=="select-one"){
timeType=one.value;
}
}
//放文件路径
paths[i]=path;
//smil body
var fName=fso.getFileName(path);
end=fName.substr(fName.indexOf(".")+1);
if(end=="txt"){
smil+="dur='"+time+timeType+"'> region='Text'/>";
}else if(end=="gif"||end=="jpg"||end=="jpeg"){
smil+="dur='"+time+timeType+"'> region='Image'/>";
}else if(end=="wav"||end=="mid"){
smil+="dur='"+time+timeType+"'>";
}
}
smil+="";
//当前目录生成彩信目录
var str=window.prompt("输入彩信名称如","aaa");
if(str==null||str==""){
return;
}
var basePath=fso.GetAbsolutePathName("")+"/"+str;
if(fso.FolderExists(basePath)){//存在,1:覆盖,2:删除,3重命名
if(confirm("目录已存在,确定要覆盖吗?")){
fso.deleteFolder(basePath);
}else{
str=window.prompt("输入彩信名称如","bbb");
if(str==null||str==""){
return;
}
basePath=fso.GetAbsolutePathName("")+"/"+str;
}
}
var dir=fso.createFolder(basePath);
//copy文件
for(i=0;i
fso.copyFile(paths[i],dir+"/",true);
//生成smil
var sfile=fso.createTextFile(dir+"/a.smil")
sfile.write(smil);
sfile.close();
alert("彩信所在目录:"+dir);
}