function updatecomment() {
     if(document.myform.bugperson.value.length==0||
        document.myform.bugtitle.value.length==0||
        document.myform.module.value.length==0||
        document.myform.description.value.length==0) {
        alert("You must give reporter name, title, module bug description");
        return false;
     }
     if(document.myform.description.value.length>1024){
        alert("description can not longer than 1024 characters!");
        return false;
     }
     var curdate = new Date()
     document.myform.description.value.replace("<","<");
     document.myform.description.value.replace(">",">");
        document.myform.text.value="<bugblock>\n<bugid>"+
            bugid+"</bugid>\n<assignee>"+document.myform.bugperson.value+"</assignee>\n";
        document.myform.text.value+="<bugpriority>"+document.myform.bugpriority.value+"</bugpriority>\n";
        document.myform.text.value+="<bugtitle>"+document.myform.bugtitle.value+"</bugtitle>\n";
        document.myform.text.value+="<bugstatus>"+document.myform.bugstatus.value+"</bugstatus>\n";
        document.myform.text.value+="<module>"+document.myform.module.value+"</module>\n";
        document.myform.text.value+="<description>\n"+document.myform.description.value+"\n</description>\n";
        document.myform.text.value+="<timestamp>: "
               +curdate.toString()+"</timestamp>\n</bugblock>\n";
        return true;
} var bugid=''; if( document.location.href.match(/keyval=/))
        bugid= document.location.href.replace(/.+keyval=([0-9]+)&.*/,'$1');
if(bugid.length>1) {
        document.myform.editmode.value="replace";
} if(bugid.length==0) bugid=Math.round((new Date()).getTime()/1000); document.myform.bugpriority.selectedIndex=2; function fillin() {
        var text=document.myform.text.value.split(/\n/);
        var disp=0;
        document.myform.keyval.value=bugid;
        for(i=0;i<text.length;i++)
        {
                if(disp==1) {
                        if(text[i].match(/<\/description>/)){ break;}
// len=document.myform.description.value.length; // if(len) ch=document.myform.description.value.charAt(len-1); // if(len&&ch!='\n'&&ch!='\r') // text[i]="\n"+text[i];
                        document.myform.description.value+=text[i]+"\n";
                        continue;
                }
                if(text[i].match(/assignee/))
                        document.myform.bugperson.value=text[i].replace(/<assignee>(.*)<\/.*/,'$1');
                else if(text[i].match(/bugtitle/))
                        document.myform.bugtitle.value=text[i].replace(/<bugtitle>(.*)<\/.*/,'$1');
                else if(text[i].match(/bugstatus/))
                        document.myform.bugstatus.value=parseInt(text[i].replace(/<bugstatus>(.*)<\/.*/,'$1'));
                else if(text[i].match(/module/))
                        document.myform.module.value=text[i].replace(/<module>(.*)<\/.*/,'$1');
                else if(text[i].match(/bugpriority/))
                        document.myform.bugpriority.selectedIndex=5-parseInt(text[i].replace(/<bugpriority>(.*)<\/.*/,'$1'));
                else if(text[i].match(/description/)){
                        document.myform.description.value=text[i].replace(/<description>(.*)/,'$1');
                        disp=1;
                }
        }
} function submitform() {
        if(updatecomment()!=false)
                document.myform.submit();
} function doemail() {
        document.getElementById("do_email_notify").checked=true;
        if(bugid.length) fillin();
        else{
              document.myform.description.value="==== OS and version: ====\n \n"
                       +"==== Steps to replicate the bug ===\n#Step 1:\n#Step 1:\n#Step 3:\n"
                       +"==== Anticipated results ===\nif needed, you can give URL to a screenshot\n\n"
                       +"==== Actual results ===\nif needed, you can give URL to a screenshot\n\n"
                       +"==== Comment ===\n\n";
        }
} window.onload=doemail;
Powered by Habitat