//this is a .html file instead of a .js so that FBT will serve the page with substr for all SUBS var prevEditFolder=-1; var prevFolder=-1; var prevFile=[]; function selectFolder(id,att){ var i; if(prevFolder>=0&&prevFolder!=id){ document.getElementById("attachFolder"+prevFolder).style.background=''; } if(prevEditFolder>=0&&prevEditFolder!=id){ document.getElementById("rowFolder"+prevEditFolder).style.display='none'; prevEditFolder=-1; } while(prevFile.length>0){ i=prevFile.shift(); document.getElementById("attachFile"+i).style.background=''; document.getElementById("showAttachFile"+i).style.display='none'; document.getElementById("rowAttach"+i).style.display='none'; } if(prevAttach>=0){ document.getElementById("showAttachFile"+prevAttach).style.background=''; document.getElementById("rowAttach"+prevAttach).style.display='none'; } document.getElementById("attachFolder"+id).style.background='#aaaaaa'; if(att.length>0){ document.getElementById("attachFolderEmpty").style.display="none"; //document.getElementById("attachmentInfoTable").style.borderBottom="1px solid black"; for(i=0;i<att.length;i+=1){ document.getElementById("showAttachFile"+att[i]).style.display=''; } }else{ document.getElementById("attachFolderEmpty").style.display=""; document.getElementById("attachmentInfoTable").style.borderBottom=""; } prevFolder=id; prevFile=att; prevAttach=-1; } function selectFile(id){ if(prevFolder>=0){ document.getElementById("attachFolder"+prevFolder).style.background=''; } while(prevFile.length>0){ i=prevFile.shift(); if(i!=id){ document.getElementById("attachFile"+i).style.background=''; document.getElementById("showAttachFile"+i).style.display='none'; document.getElementById("rowAttach"+i).style.display='none'; } } if(prevAttach>=0){ document.getElementById("showAttachFile"+prevAttach).style.background=''; document.getElementById("rowAttach"+prevAttach).style.display='none'; } document.getElementById("attachFolderEmpty").style.display="none"; document.getElementById("attachFile"+id).style.background='#aaaaaa'; document.getElementById("showAttachFile"+id).style.display=''; document.getElementById("attachmentInfoTable").style.borderBottom="1px solid black"; selectAttach(id); prevFolder=-1; prevFile=[id]; } var prevAttach=-1; function selectAttach(id){ document.getElementById("attachmentInfoTable").style.borderBottom="1px solid black"; if(prevEditFolder>=0){ document.getElementById("rowFolder"+prevEditFolder).style.display='none'; } if(prevAttach>=0){ document.getElementById("showAttachFile"+prevAttach).style.background=''; document.getElementById("rowAttach"+prevAttach).style.display='none'; } document.getElementById("attachFolderEmpty").style.display="none"; document.getElementById("showAttachFile"+id).style.background='#aaaaaa'; if(id!=prevAttach){ //toggle if not selecting another one document.getElementById("rowAttach"+id).style.display=''; prevAttach=id; } else { prevAttach=-1; } prevEditFolder=-1; } function deleteVersion(id,vid,vfile){ var sat; sat=document.getElementById("versionList"+id+"_"+vid); sat.style.opacity=0.4; sat.style.filter='alpha(opacity=40)'; document.getElementById("updatedAttach").style.display='block'; document.getElementById("deleteVersionLink"+id+"_"+vid).style.display='none'; document.getElementById("restoreVersionLink"+id+"_"+vid).style.display='inline'; document.getElementById("swapVersionLink"+id+"_"+vid).style.display='none'; document.entry_form["deletedVersion"+id].value+=" "+vfile; } function attachAdvanced(check,id){ if(check){ var sat=document.getElementById("attachAdvanced"+id); if(sat){ if(check.checked){ sat.style.display=""; }else{ sat.style.display="none"; } } } } function showEditFolderMenu(id){ var editDiv=document.getElementById("attachFolder"+id); var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editDiv&&editFolderDiv){ var x=0; var y=0; var e=editDiv; while(e!=null){ x+=e.offsetLeft; y+=e.offsetTop; e=e.offsetParent; } editFolderDiv.style.left=(x+editDiv.offsetWidth)+'px'; editFolderDiv.style.top=y+'px'; editFolderDiv.style.display=""; editFolderDiv.folderId=id; if(editFolderDiv.hideEvent!=null){ clearTimeout(editFolderDiv.hideEvent); } editFolderDiv.hideEvent=null; } } function hideEditFolderMenu(id){ var editDiv=document.getElementById("attachFolder"+id); var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editDiv&&editFolderDiv){ if(!editFolderDiv.beingUsed){ editFolderDiv.style.display="none"; } } } function hideEditFolder(id){ var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editFolderDiv){ editFolderDiv.hideEvent=setTimeout('hideEditFolderMenu('+id+');',500); } } function createSubFolder(e){ var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editFolderDiv&&editFolderDiv.folderId){ var id=editFolderDiv.folderId; var editDiv=document.getElementById("attachFolder"+id); if(editDiv){ hideEditFolder(id); am.createSubFolder(e,id); } } } function moveFolder(e){ var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editFolderDiv&&editFolderDiv.folderId){ var id=editFolderDiv.folderId; var editDiv=document.getElementById("attachFolder"+id); if(editDiv){ hideEditFolder(id); am.moveFolder(e,id); } } } function deleteFolder(e){ var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editFolderDiv&&editFolderDiv.folderId){ var id=editFolderDiv.folderId; var editDiv=document.getElementById("attachFolder"+id); if(editDiv){ hideEditFolder(id); am.delFolder(e,id); } } } function renameFolder(e){ var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editFolderDiv&&editFolderDiv.folderId){ var id=editFolderDiv.folderId; var editDiv=document.getElementById("attachFolder"+id); if(editDiv){ hideEditFolder(id); am.renameFolder(e,id); } } } function globalFolder(e){ var editFolderDiv=document.getElementById("attachFolderEditMenu"); if(editFolderDiv&&editFolderDiv.folderId){ var id=editFolderDiv.folderId; var editDiv=document.getElementById("attachFolder"+id); if(editDiv){ hideEditFolder(id); am.globalFolder(e,id); } } } function showAttachInFolder(){ var showImg=document.getElementById("showAttachImg"); var hideImg=document.getElementById("hideAttachImg"); if(am&&showImg&&hideImg){ am.showAttachments(); showImg.style.display="none"; hideImg.style.display=""; am.refreshHtml(); } } function hideAttachInFolder(){ var showImg=document.getElementById("showAttachImg"); var hideImg=document.getElementById("hideAttachImg"); if(am&&showImg&&hideImg){ am.hideAttachments(); showImg.style.display=""; hideImg.style.display="none"; am.refreshHtml(); } } function showComment(e,aId){ //alert(aId); if(aId>0){ var attach=am.getAttachment(aId); //alert(attach); if(attach){ fitPopup(e,"\

"+attach.getFilename()+"

\

: "+attach.getComment()+"

\ "); } } } function Folder(fId,fName,fParentId,fGlobal){ this.id=0; this.name=""; this.parentId=0; this.global=false; this.hasBeenCreated=false; this.hasBeenEdited=false; this.hasBeenDeleted=false; this.hasBeenMoved=false; this.getId=function(){return(this.id);} this.getName=function(){return(this.name);} this.getParentId=function(){return(this.parentId);} this.isGlobal=function(){return(this.global);} this.isCreated=function(){return(this.hasBeenCreated);} this.isEdited=function(){return(this.hasBeenEdited);} this.isDeleted=function(){return(this.hasBeenDeleted);} this.isMoved=function(){return(this.hasBeenMoved);} this.setId=function(id){ if(typeof(id)=="number"&&id>0){ this.id=id; } return(this.id); } this.setName=function(name){ if(typeof(name)=="string"&&name!=""){ this.name=name; } return(this.name); } this.setParentId=function(parentId){ if(typeof(parentId)=="number"&&parentId>=0){ this.parentId=parentId; } return(this.parentId); } this.setGlobal=function(state){ if(state){ this.global=true; }else{ this.global=false; } } this.created=function(state){ if(state){ this.hasBeenCreated=true; this.edited(true); }else{ this.hasBeenCreated=false; } } this.edited=function(state){ if(state){ this.hasBeenEdited=true; }else{ this.hasBeenEdited=false; } } this.deleted=function(state){ if(state){ this.hasBeenDeleted=true; this.edited(true); }else{ this.hasBeenDeleted=false; } } this.moved=function(state){ if(state){ this.hasBeenMoved=true; this.edited(true); }else{ this.hasBeenMoved=false; } } this.setId(fId); this.setName(fName); this.setParentId(fParentId); this.setGlobal(fGlobal); } function Attachment(aId,fId,aFilename,aSize,aUrl,aComment,aVersion,aUploadedBy,aDate){ this.id=0; this.folderId=0; this.filename=""; this.size="?"; this.url=""; this.comment=""; this.version=""; this.uploadedBy=""; this.date=""; this.hasBeenEdited=false; this.hasBeenDeleted=false; this.uploadFile=null; this.versionList=[]; this.deletedVersionList=[]; this.getId=function(){return(this.id);} this.getFolderId=function(){return(this.folderId);} this.getFilename=function(){return(this.filename);} this.getSize=function(){return(this.size);} this.getUrl=function(){return(this.url);} this.getComment=function(){return(this.comment);} this.getVersion=function(){return(this.version);} this.getUploadedBy=function(){return(this.uploadedBy);} this.getDate=function(){return(this.date);} this.getUploadFile=function(){return(this.uploadFile);} this.getVersionList=function(){return(this.versionList);} this.getDeletedVersionList=function(){return(this.deletedVersionList);} this.isEdited=function(){return(this.hasBeenEdited);} this.isDeleted=function(){return(this.hasBeenDeleted);} this.setId=function(id){ if(typeof(id)=="number"&&id>0){ this.id=id; } return(this.id); } this.setFolderId=function(folderId){ if(typeof(folderId)=="string"){ folderId=parseInt(folderId); } if(typeof(folderId)=="number"&&folderId>=0){ this.folderId=folderId; } return(this.folderId); } this.setFilename=function(filename){ if(typeof(filename)=="string"&&filename!=""){ this.filename=filename; } return(this.filename); } this.setSize=function(size){ if(typeof(size)=="string"&&size!=""){ this.size=size; } return(this.size); } this.setUrl=function(url){ if(typeof(url)=="string"&&url!=""){ this.url=url; } return(this.url); } this.setComment=function(comment){ if(typeof(comment)=="string"){ this.comment=comment; } return(this.comment); } this.setVersion=function(version){ if(typeof(version)=="string"){ this.version=version; } return(this.version); } this.setUploadedBy=function(uploadedBy){ if(typeof(uploadedBy)=="string"&&uploadedBy!=""){ this.uploadedBy=uploadedBy; } return(this.uploadedBy); } this.setDate=function(date){ if(typeof(date)=="string"&&date!=""){ this.date=date; } return(this.date); } this.setUploadFile=function(file){ if(typeof(file)=="object"){ this.uploadFile=file; } return(this.uploadFile); } this.edited=function(state){ if(state){ this.hasBeenEdited=true; }else{ this.hasBeenEdited=false; } } this.deleted=function(state){ if(state){ this.hasBeenDeleted=true; this.edited(true); }else{ this.hasBeenDeleted=false; } } this.addVersion=function(version){ if(version&&version.getId()>0){ var found=false; for(var i=0;i<this.versionList.length;i+=1){ if(this.versionList[i]==version){ found=true; break; } } if(!found){ this.versionList.push(version); var vFile="A"+version.getId()+".att"; for(var i=0;i<this.deletedVersionList;i+=1){ if(this.deletedVersionList[i]==vFile){ this.deletedVersionList.splice(i,1); break; } } } } } this.deleteVersion=function(version){ if(version&&version.getId()>0){ for(var i=0;i<this.versionList.length;i+=1){ if(this.versionList[i]==version){ this.versionList.splice(i,1); this.deletedVersionList.push("A"+version.getId()+".att"); break; } } } } this.setId(aId); this.setFolderId(fId); this.setFilename(aFilename); this.setSize(aSize); this.setUrl(aUrl); this.setComment(aComment); this.setVersion(aVersion); this.setUploadedBy(aUploadedBy); this.setDate(aDate); } function AttachmentVersion(vId,aId,vSize,vUrl,vComment,vVersion,vUploadedBy,vDate){ this.id=0; this.attachId=0; this.size="?"; this.url=""; this.comment=""; this.version=""; this.uploadedBy=""; this.date=""; this.hasBeenDeleted=false; this.uploadFile=null; this.getId=function(){return(this.id);} this.getAttachmentId=function(){return(this.attachId);} this.getSize=function(){return(this.size);} this.getUrl=function(){return(this.url);} this.getComment=function(){return(this.comment);} this.getVersion=function(){return(this.version);} this.getUploadedBy=function(){return(this.uploadedBy);} this.getDate=function(){return(this.date);} this.getUploadFile=function(){return(this.uploadFile);} this.getSwapVersion=function(){return(this.swapVersion);} this.isEdited=function(){return(this.hasBeenEdited);} this.isDeleted=function(){return(this.hasBeenDeleted);} this.setId=function(id){ if(typeof(id)=="number"&&id>0){ this.id=id; } return(this.id); } this.setAttachmentId=function(attachId){ if(typeof(attachId)=="string"){ attachId=parseInt(attachId); } if(typeof(attachId)=="number"&&attachId>=0){ this.attachId=attachId; } return(this.attachId); } this.setFilename=function(filename){ if(typeof(filename)=="string"&&filename!=""){ this.filename=filename; } return(this.filename); } this.setSize=function(size){ if(typeof(size)=="string"&&size!=""){ this.size=size; } return(this.size); } this.setUrl=function(url){ if(typeof(url)=="string"&&url!=""){ this.url=url; } return(this.url); } this.setComment=function(comment){ if(typeof(comment)=="string"&&comment!=""){ this.comment=comment; } return(this.comment); } this.setVersion=function(version){ if(typeof(version)=="string"&&version!=""){ this.version=version; } return(this.version); } this.setUploadedBy=function(uploadedBy){ if(typeof(uploadedBy)=="string"&&uploadedBy!=""){ this.uploadedBy=uploadedBy; } return(this.uploadedBy); } this.setDate=function(date){ if(typeof(date)=="string"&&date!=""){ this.date=date; } return(this.date); } this.setUploadFile=function(file){ if(typeof(file)=="object"){ this.uploadFile=file; } return(this.uploadFile); } this.edited=function(state){ if(state){ this.hasBeenEdited=true; }else{ this.hasBeenEdited=false; } } this.deleted=function(state){ if(state){ this.hasBeenDeleted=true; }else{ this.hasBeenDeleted=false; } } this.setId(vId); this.setAttachmentId(aId); this.setSize(vSize); this.setUrl(vUrl); this.setComment(vComment); this.setVersion(vVersion); this.setUploadedBy(vUploadedBy); this.setDate(vDate); } function AttachmentManager(div){ if(div){ if(typeof(div)=="string"){ this.container=document.getElementById(div); }else if(div.style){ this.container=div; }else{ this.container=document.getElementById("AttachmentManager"); } }else{ this.container=document.getElementById("AttachmentManager"); } this.folder=new Object(); this.folderRoot=null; this.folderInfo=new Object(); this.folderList=[]; this.folderMap=new Object(); this.folderMaxId=0; this.allowDelete=true; this.attach=new Object(); this.attachInfo=new Object(); this.attachList=[]; this.attachMap=new Object(); this.hideAttach=true; this.hideComment=false; this.hideVersion=false; this.editableAttach=false; this.editableFolder=false; this.editableGlobal=false; this.areAttachmentsEditable=function(){ return(this.editableAttach); } this.areCommentsHidden=function(){ return(this.hideComment); } this.isVersionHidden=function(){ return(this.hideVersion); } this.areFoldersEditable=function(){ return(this.editableFolder); } this.isDeleteAllowed=function(){ return(this.allowDelete); } this.isGlobalEditable=function(){ return(this.editableGlobal); } this.setAllowDelete=function(state){ if(state){ this.allowDelete=true; }else{ this.allowDelete=false; } } this.setAttachmentsEditable=function(state){ if(state){ this.editableAttach=true; }else{ this.editableAttach=false; } } this.setHideComments=function(state){ if(state){ this.hideComment=true; }else{ this.hideComment=false; } } this.setHideVersion=function(state){ if(state){ this.hideVersion=true; }else{ this.hideVersion=false; } } this.setFoldersEditable=function(state){ if(state){ this.editableFolder=true; }else{ this.editableFolder=false; } } this.setGlobalEditable=function(state){ if(state){ this.editableGlobal=true; }else{ this.editableGlobal=false; } } this.hideAttachments=function(){ this.hideAttach=true; } this.showAttachments=function(){ this.hideAttach=false; } this.folderExists=function(folder){ var exists=false; if(folder!=null){ var pId=folder.getParentId(); var id="fi"+pId; var list=this.folderInfo[id]; if(list){ for(var i=0;i<list.length;i+=1){ if(list[i]&&list[i].getName()&&list[i].getName()==folder.getName()){ exists=true; } } } } return(exists); } this.addFolder=function(folder){ if(folder!=null){ folder.deleted(false); var fId=folder.getId(); if(fId==0){ this.folderRoot=folder; }else{ var pId=folder.getParentId(); var id="fi"+pId; var list=this.folderInfo[id]; if(!list){ list=[]; } list.push(folder); this.folderInfo[id]=list; if(fId>this.folderMaxId)this.folderMaxId=fId; } if(!this.folder["f"+fId]){ this.folderList.push(folder); this.folderMap["fm"+fId]=this.folderList.length; this.folder["f"+fId]=folder; } } } this.deleteFolder=function(fId){ var folder; if(fId>0){ folder=this.getFolder(fId); if(folder){ folder.deleted(true); var pId=folder.getParentId(); var id="fi"+pId; var list=this.folderInfo[id]; if(list){ for(var i=0;i<list.length;i+=1){ if(list[i]==folder){ list.splice(i,1); break; } } } } } return(folder); } this.getFolder=function(fId){ var folder; if(fId>=0){ folder=this.folder["f"+fId]; } return(folder); } this.attachmentExists=function(attach){ var exists=false; if(attach!=null){ var fId=attach.getFolderId(); var id="ai"+fId; var list=this.attachInfo[id]; if(list){ for(var i=0;i<list.length;i+=1){ if(list[i]&&list[i].getFilename()&&list[i].getFilename()==attach.getFilename()){ exists=true; } } } } return(exists); } this.addAttachment=function(attach){ if(attach!=null){ var fId=attach.getFolderId(); var id="ai"+fId; var list=this.attachInfo[id]; if(!list){ list=[]; } list.push(attach); this.attachInfo[id]=list; if(!this.attach["a"+attach.getId()]){ this.attachList.push(attach); this.attachMap["am"+attach.getId()]=this.attachList.length; this.attach["a"+attach.getId()]=attach; } } } this.deleteAttachment=function(aId){ var attach=this.getAttachment(aId); if(attach){ attach.deleted(true); var fId=attach.getFolderId(); var id="ai"+fId; var list=this.attachInfo[id]; if(list){ for(var i=0;i<list.length;i+=1){ if(list[i]==attach){ list.splice(i,1); break; } } } } return(attach); } this.getAttachment=function(aId){ var attach; if(aId>0){ attach=this.attach["a"+aId]; } return(attach); } this.moveAttach=function(aId,fId){ var attach=this.getAttachment(aId); if(attach){ if(fId>=0&&attach.getFolderId()!=fId){ this.deleteAttachment(attach.getId()); attach.setFolderId(fId); this.addAttachment(attach); attach.deleted(false); } } } this.getFolderHiddenHtml=function(){ var html=""; for(var i=0;i<this.folderList.length;i+=1){ var folder=this.folderList[i]; html+="\ <input name=\"folderId"+(i+1)+"\" value=\""+folder.getId()+"\" type=\"hidden\">"; if(folder.isEdited()){ html+="\ \ \ \ "; if(folder.isCreated()){ html+="\ "; } }else{ html+="\ \ \ \ "; } if(folder.isGlobal()){ html+=""; } } return(html); } this.getAttachmentList=function(aList){ var list=""; if(aList&&aList.length>0){ var sep=""; for(var i=0;i<aList.length;i+=1){ list+=sep+this.attachMap["am"+aList[i].getId()]; sep=","; } } return(list); } this.getFolderHtml=function(folder,indent){ var fId=folder.getId(); var jId=this.folderMap["fm"+fId]; var fList=this.folderInfo["fi"+fId]; var aList=this.attachInfo["ai"+fId]; if(fId==0){ for(var i=1;i<this.folderList.length;i+=1){ var fol=this.folderList[i]; if(fol){ var folderParent=this.getFolder(fol.getParentId()); if(!folderParent){ this.deleteFolder(fol.getId()); fol.setParentId(0); this.addFolder(fol); fol.deleted(false); fol.moved(true); if(!fList){ fList=this.folderInfo["fi0"]; } } } } for(var i=0;i<this.attachList.length;i+=1){ var att=this.attachList[i]; if(att){ var fol=this.getFolder(att.getFolderId()); if(!fol){ this.deleteAttachment(att.getId()); att.setFolderId(0); this.addAttachment(att); att.deleted(false); if(!aList){ aList=this.attachInfo["ai0"]; } } } } } var indentString="<img src=\"<SUB REVISIONPREFIX>com/other/plus_black.gif\" style=\"visibility:hidden;\"> "; var indentHtml=""; for(var i=0;i<indent;i+=1){ indentHtml+=indentString; } var toggleImg=document.images["toggleFolder"+jId+"_IMG"]; var html="<div id=attachFolder"+jId+" onclick=\"selectFolder("+jId+",["+this.getAttachmentList(aList)+"]);\" style=\"padding:0px 8px;cursor:pointer;position:relative;\">"+indentHtml+"0)||(!this.hideAttach&&aList&&aList.length>0)){ html+="visible"; }else{ html+="hidden"; } var toggleInner=document.getElementById("toggleFolder"+jId+"_INNER"); html+=";\"> com/other/"+(folder.isGlobal()?"gfolder.gif":"folder.gif")+"\"> "+folder.getName(); if(this.areFoldersEditable()){ html+="
"; } html+="
"; if(fList&&fList.length>0){ for(var i=0;i<fList.length;i+=1){ var subId=fList[i].getId(); if(subId!=fId&&fList[i].getParentId()==fId){ html+=this.getFolderHtml(fList[i],indent+1); } } } if(aList&&aList.length>0){ var display="display:none;"; if(!this.hideAttach){ display=""; } indentHtml+=indentString+indentString; for(var i=0;i<aList.length;i+=1){ var ajId=this.attachMap["am"+aList[i].getId()]; html+="<div id=attachFile"+ajId+" onclick=\"selectFile("+ajId+");\" style=\"padding:0px 8px;cursor:pointer;"+display+"\">"+indentHtml+"com/other/text.gif\" "; if(!this.hideComment){ html+="alt=\""+aList[i].getComment()+" XXX1\" title=\""+aList[i].getComment()+"\" "; } html+="border=0> "+aList[i].getFilename()+"
"; } } html+=""; return(html); } this.getAttachmentHtml=function(){ var showHtml=""; var html="

\
"; var colspan=5; enableMailAtt = (typeof enableMailAtt != 'undefined' && enableMailAtt); var mailAttHead = ""; if (enableMailAtt) { mailAttHead = "
com/other/mailAtt.png\" border=0 alt=\"Attach to Notification\" title=\"Attach to Notification\">"; } if(this.hideVersion){ colspan--; html += "
"+mailAttHead+"
"; } else { html += "
"+mailAttHead+"
"; } html+="
\
\ "; for(var i=0;i<this.attachList.length;i+=1){ var attach=this.attachList[i]; if(attach){ var id=i+1; if(attach.isEdited()){ html+="<input name=editedAttach"+id+" value=Yes type=hidden>"; if(!this.hideVersion){ html+=""; } html+=""; if(!this.hideComment){ html+=""; } if(attach.getUploadFile()!=null){ attach.getUploadFile().style.display="none"; document.getElementById("updatedAttach").appendChild(attach.getUploadFile()); } html+=""; html+=""; html+=""; }else{ html+="\ \ \ \ "; } html+="\ \
"; if (enableMailAtt) { html+="
"; } html+="
\
"; if (!this.hideVersion){ html+="\
"; } html+="\
\
\

"; if (0) { // not a big fan of this if(!this.hideComment){ html+="\ com/other/comment.gif\" border=0 "; html+="\ alt=\""+attach.getComment()+"\" title=\""+attach.getComment()+"\" \ onclick=\"showComment(event,"+attach.getId()+");\" "; } html+=(attach.getComment().length>0?"":"style=\"visibility:hidden;\"")+">"; } html+="\ com/other/text.gif\" "; if(!this.hideComment){ html+="alt=\""+attach.getComment()+"XXX2\" title=\""+attach.getComment()+"\" "; } var size = ""; if (attach.getSize()!="?") { size = attach.getSize(); } html+="\ border=0>"+attach.getFilename()+"

"+size+"

"+attach.getVersion()+"

"+attach.getUploadedBy()+"

"+attach.getDate()+"

"; var linkHtml="\

\
\
\
\ \ []\ "; if(this.areAttachmentsEditable()){ linkHtml+="\ \ []\ "; if(this.isDeleteAllowed()){ linkHtml+="\ \ []\ "; } } linkHtml+="\
\

"; showHtml+="\

\
\
\
"; showHtml+="\

"+attach.getFilename()+"\
com/other/info.gif\" onclick='fitInfo(event,\"Copy and paste this text into a TextArea field to embed the attached image\");'>

\
\

"; if (!this.hideVersion){ showHtml+="\
: | "+linkHtml+attach.getVersion()+"
"; linkHtml=""; // otherwise shown with size below } if (attach.getSize()!="?") { showHtml+="\
: | "+linkHtml+attach.getSize()+"
"; } showHtml+="\
: | "+attach.getUploadedBy()+"
\
: | "+attach.getDate()+"
"; if(!this.hideComment){ showHtml+="\
: | "+attach.getComment()+"
"; } if(attach.isEdited()){ if(attach.getUploadFile()!=null){ showHtml+="\
: | "+attach.getUploadFile().value+"
"; } showHtml+="\
\
"; } showHtml+="\

\
\

\
"; var vList=attach.getVersionList(); if(vList&&vList.length>0){ showHtml+="\
\
\

\ com/other/plus_black.gif\" onclick=\"toggleInnerSection('versionAttach"+id+"');\">\ :

\
\

"; for(var j=0;j<vList.length;j+=1){ var linkHtml ="\ <table align=right cellpadding=0 cellspacing=0 border=0>\ <tr>\ <td style=\"text-align:right;vertical-align:top;white-space:nowrap;\">\
\ []\
"; if(this.areAttachmentsEditable()&&this.isDeleteAllowed()){ linkHtml+="\
\ []\
"; } linkHtml+="\

\
\

"; showHtml+="\

\
\

\
\

"; if (!this.hideVersion) { showHtml+="\
: | "+linkHtml+vList[j].getVersion()+"
"; linkHtml=""; } if (vList[j].getSize()!="?") { showHtml+="\
: | "+linkHtml+vList[j].getSize()+"
"; linkHtml=""; } showHtml+="\
: | "+linkHtml+vList[j].getUploadedBy()+"
\
: | "+vList[j].getDate()+"
"; if(!this.hideComment){ showHtml+="\
: | "+vList[j].getComment()+"
"; } showHtml+="\

\
\

\
"; } showHtml+="\

\ \ \ "; } showHtml+="\ \ "; } } html+=""; return(html+showHtml); } this.getFolderEditHtml=function(){ var html="\
"; return(html); } this.getFolderMoveHtml=function(folderRoot,folder,selectName,indent,moveAttach,id){ if(!folderRoot){folderRoot=this.folderRoot;} var fId=folderRoot.getId(); var fList=this.folderInfo["fi"+fId]; var html=""; var indentString=""; if(indent==0&&selectName!=""){ html+="0){html+=" id=\""+id+"\"";} html+=">"; } for(var i=0;i<indent;i+=1){ indentString+=" "; } if(folderRoot!=folder||moveAttach){ html+="<option value=\""+folderRoot.getId()+"\""; if((!moveAttach&&((folder.getParentId()>0&&folder.getParentId()==folderRoot.getId())||(folder.getParentId()<=0&&folderRoot.getId()<=0)))||(moveAttach&&folder==folderRoot)){ html+=" selected"; } html+=">"+indentString+folderRoot.getName(); } if(fList&&fList.length>0){ for(var i=0;i<fList.length;i+=1){ html+=this.getFolderMoveHtml(fList[i],folder,"",indent+1,moveAttach); } } if(indent==0&&selectName!=""){ html+="</select>"; } return(html); } this.editAttach=function(e,id){ if(id&&id>0){ var attach=this.attachList[id-1]; if(attach){ var folder=this.getFolder(attach.getFolderId()); if(!folder){folder=this.folderRoot;} fitPopup(e,"\ "+attach.getFilename()+"\

"+ ( this.hideComment?"": "
: |
" )+ ( this.hideVersion?"": "
: |
" )+"\
: |
\
Move To: | "+this.getFolderMoveHtml(this.folderRoot,folder,"moveto",0,true)+"
\

\
\ \ "); } } } this.editAttachSave=function(id,form){ if(id&&id>0){ var attach=this.attachList[id-1]; if(attach&&form){ var testAttach=new Attachment(attach.getId(),form["moveto"].options[form["moveto"].selectedIndex].value,attach.getFilename()); if(attach.getFolderId()==testAttach.getFolderId()||!this.attachmentExists(testAttach)){ attach.edited(true); if(form["comment"]) attach.setComment(form["comment"].value); if(form["version"]) attach.setVersion(form["version"].value); if(form["updateAttach"+id]&&form["updateAttach"+id].value!=""){attach.setUploadFile(form["updateAttach"+id]);} am.moveAttach(attach.getId(),form["moveto"].options[form["moveto"].selectedIndex].value); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); }else{ alert("Unable to move attachment. An attachment with filename "+attach.getFilename()+" already exists."); } } } cal_hide(); } this.deleteAttach=function(e,id){ if(id&&id>0){ var attach=this.attachList[id-1]; if(attach){ fitPopup(e,"\ \

"+attach.getFilename()+"

\
\

Are you sure you want to delete this attachment?

\
\

\ \ \
\ \ "); } }else{ fitPopup(e,"You have selected an unknown attachment id."); } } this.deleteAttachSave=function(id,form){ if(id&&id>0){ var attach=this.attachList[id-1]; if(attach){ attach.edited(true); am.deleteAttachment(attach.getId()); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); } } cal_hide(); } this.createSubFolder=function(e,id){ if(id&&id>0){ var folder=this.folderList[id-1]; if(folder){ fitPopup(e,"\ \

"+folder.getName()+"

\
\

Name of sub folder to be created:

\
" + ((this.isGlobalEditable()) ? "\

Check the checkbox to make the folder a global folder: \

" : "") +"\
\

\ \ "); if(document.forms[document.forms.length-1].subfolder){ document.forms[document.forms.length-1].subfolder.focus(); } } } } this.createSubFolderSave=function(id,form){ if(id&&id>=0){ var folder=this.folderList[id-1]; if(folder&&form&&form["subfolder"].value!=""){ var name=form["subfolder"].value; if(name&&name.length>0){ this.folderMaxId+=1; var subFolder=new Folder(this.folderMaxId,name,folder.getId()); if(!this.folderExists(subFolder)){ subFolder.created(true); if(form["global"] && form["global"].checked){ subFolder.setGlobal(true); } am.addFolder(subFolder); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); }else{ alert("Unable to create folder. A folder named "+name+" already exists."); return; } }else{ alert("The folder must be given a name."); return; } } } cal_hide(); } this.moveFolder=function(e,id){ if(id&&id>1){ var folder=this.folderList[id-1]; if(folder){ fitPopup(e,"\ \

"+folder.getName()+"

\
\

Move To: "+this.getFolderMoveHtml(this.folderRoot,folder,"moveFolderList",0,false)+"

\
\

\ \
\ \ "); } }else{ fitPopup(e,"\ You are not allowed to move the "+this.folderRoot.getName()+" folder."); } } this.moveFolderSave=function(id,form){ if(id&&id>0){ var folder=this.folderList[id-1]; if(folder){ var newParentId=parseInt(form["moveFolderList"].options[form["moveFolderList"].selectedIndex].value); if(newParentId>=0&&newParentId!=folder.getParentId()){ var testFolder=new Folder(folder.getId(),folder.getName(),newParentId); if(!this.folderExists(testFolder)){ this.deleteFolder(folder.getId()); folder.setParentId(newParentId); this.addFolder(folder); folder.moved(true); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); }else{ alert("Unable to move folder. A folder with the name "+folder.getName()+" already exists."); return; } } } } cal_hide(); } this.delFolder=function(e,id){ if(id&&id>1){ var folder=this.folderList[id-1]; if(folder){ fitPopup(e,"\ \

"+folder.getName()+"

\
\

Are you sure you want to delete this folder?

\
\

\ \ \
\ \ "); } }else{ fitPopup(e,"\ You are not allowed to delete the "+this.folderRoot.getName()+" folder."); } } this.delFolderSave=function(id,form){ if(id&&id>0){ var folder=this.folderList[id-1]; if(folder){ folder.edited(true); am.deleteFolder(folder.getId()); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); } } cal_hide(); } this.renameFolder=function(e,id){ if(id&&id>1){ var folder=this.folderList[id-1]; if(folder){ fitPopup(e,"\ \

"+folder.getName()+"

\
\

Type in the new name for the "+folder.getName()+" folder: \

\
\

\ \
\ \ "); if(document.forms[document.forms.length-1].newname){ document.forms[document.forms.length-1].newname.focus(); document.forms[document.forms.length-1].newname.select(); } } }else{ fitPopup(e,"\ You are not allowed to rename the "+this.folderRoot.getName()+" folder."); } } this.renameFolderSave=function(id,form){ if(id&&id>1){ var folder=this.folderList[id-1]; if(folder&&form&&form["newname"].value!=""){ folder.edited(true); folder.setName(form["newname"].value); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); } } cal_hide(); } this.globalFolder=function(e,id){ if(id&&id>1){ var folder=this.folderList[id-1]; if(folder){ fitPopup(e,"\ \

"+folder.getName()+"

\
" + ((this.isGlobalEditable()) ? "\

Check the checkbox to make the folder a global folder: \

" : "") + "\
\

\ \
\ \ "); } }else{ fitPopup(e,"\ You are not allowed to change the global status of the "+this.folderRoot.getName()+" folder."); } } this.globalFolderSave=function(id,form){ if(id&&id>1){ var folder=this.folderList[id-1]; if(folder&&form&&form["global"]){ if(folder.isGlobal()){ if(!form["global"].checked){ folder.setGlobal(false); folder.edited(true); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); } }else{ if(form["global"].checked){ folder.setGlobal(true); folder.edited(true); document.getElementById("updatedAttach").style.display='block'; am.refreshHtml(); } } } } cal_hide(); } this.refreshHtml=function(){ var display="none"; if(document.getElementById("updatedAttach")){ display=document.getElementById("updatedAttach").style.display; } var html="\

\ \
\

\
\ com/other/text.gif\" style=\"float:right;"+(this.hideAttach?"":"display:none;")+"\" onclick=\"showAttachInFolder();\" title=\"\">com/other/folder.gif\" style=\"float:right;"+(this.hideAttach?"display:none;":"")+"\" onclick=\"hideAttachInFolder();\" title=\"\">
\
"; if(this.areFoldersEditable()){html+=this.getFolderEditHtml();} if(this.folderRoot){ html+=this.getFolderHiddenHtml()+this.getFolderHtml(this.folderRoot,0); } html+="

"+this.getAttachmentHtml()+"

"; if(this.areFoldersEditable()&&document.createElement){ var form=document.createElement("form"); if(form){ form.innerHTML=this.getFolderMoveHtml(this.folderRoot,this.folderRoot,"tempFolderList",0,true); for(var i=1;i<=promptMax;i+=1){ if(document.entry_form&&document.entry_form["uploadfolderBackground"+i]){ var uf=document.entry_form["uploadfolderBackground"+i]; uf.options.length=0; for(var j=0;j<form["tempFolderList"].options.length;j+=1){ var optn=document.createElement("option"); optn.selected=form["tempFolderList"].options[j].selected; optn.text=form["tempFolderList"].options[j].text; optn.value=form["tempFolderList"].options[j].value; uf.options.add(optn); } } else if(document.entry_form&&document.entry_form["uploadfolder"+i]){ var uf=document.entry_form["uploadfolder"+i]; uf.options.length=0; for(var j=0;j<form["tempFolderList"].options.length;j+=1){ var optn=document.createElement("option"); optn.selected=form["tempFolderList"].options[j].selected; optn.text=form["tempFolderList"].options[j].text; optn.value=form["tempFolderList"].options[j].value; uf.options.add(optn); } } } } } this.container.innerHTML=html; prevEditFolder=-1; prevFile=[]; prevAttach=-1; if(prevFolder>0){ var el=document.getElementById("attachFolder"+prevFolder); if(!el){ prevFolder=-1; el=document.getElementById("attachFolder1"); } if(el){ el.onclick(); }else{ prevFolder=-1; } } } }