var req; function loadXMLDoc(url) { // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = processReqChange; req.open("GET", url, true); req.send(null); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = processReqChange; req.open("GET", url, true); req.send(); } } } function processReqChange() { // only if req shows "complete" if (req.readyState == 4) { // only if "OK" if (req.status == 200 && req.responseXML != null && typeof req.responseXML != 'undefined') { response = req.responseXML.documentElement; issues = response.getElementsByTagName('issue'); // this is an issue request issueSelect = document.getElementById('submittalname'); // clear while (issueSelect.options.length > 0) { issueSelect.options[0] = null; } issueSelect.options[issueSelect.options.length]=new Option("",""); issuesLength = issues.length; // add for (i = 0; i < issues.length; i++) { var nm = issues[i].getAttribute('issuename'); var status = issues[i].getAttribute('status'); issueSelect.options[issueSelect.options.length]=new Option(nm+" ("+status+")",nm); } // add handling for resubmitted content that we don't have our system issueSelect.options[issueSelect.options.length]=new Option(resubmittalUnknownCode, resubmittalUnknownCode ); if (issuesLength == 0) { document.getElementById("submittalnamespan").className = "hidden"; document.getElementById("submittalnamespan2").className = "show"; } else { document.getElementById("submittalnamespan").className = "show"; document.getElementById("submittalnamespan2").className = "hidden"; } document.getElementById("supplementnamespan").className = "hidden"; } else { alert("There was a problem retrieving the XML data.\n" + "Please fill Publisher, Journal and Year information :\n" + req.statusText); } } } function makeIssueRequestURL() { var fullurl= window.location.href; var subUrlIndex1 = fullurl.indexOf("//"); var subUrlIndex2 = fullurl.indexOf("/", subUrlIndex1+2); var urlString = fullurl.substring(0, subUrlIndex2); urlString = urlString + "/jowweb/controller?action=getissuesbyshortcode&shortcode="; return urlString; } function getIssues(shortcode,year) { var url = makeIssueRequestURL(); url = url + shortcode+'&year='+year; loadXMLDoc(url); } function submittalClicked(fm) { if (fm.submittal.checked) { getIssues(fm.shortcode.value, fm.year.value); fm.supplement.checked = false; } return true; } function supplementClicked(fm) { if (fm.supplement.checked) { document.getElementById("supplementnamespan").className = "show"; document.getElementById("submittalnamespan2").className = "hidden"; document.getElementById("submittalnamespan").className = "hidden"; fm.submittal.checked = false; } return true; } function journalAndYearSelected(fm) { if (fm.shortcode.value != "" && validateYear(fm.year.value) ) { document.getElementById("supplement").disabled = false; document.getElementById("submittal").disabled = false; } else { document.getElementById("supplement").disabled = true; document.getElementById("submittal").disabled = true; } return true; } function disableSubmittal(fm) { document.getElementById("supplementnamespan").className = "hidden"; document.getElementById("submittalnamespan").className = "hidden"; document.getElementById("submittalnamespan2").className = "hidden"; document.getElementById("supplement").checked = false; document.getElementById("submittal").checked = false; document.getElementById("supplement").disabled = true; document.getElementById("submittal").disabled = true; return true; } // this is the name of the option that ips should choose when they are submitting an issue not in documentum. //var resubmittalUnknownCode = "PREVIOUS (in Orion)"; var resubmittalUnknownCode = "New Submittal"; var issuesLength = 0; function submittalSelected(fm) { if (fm.submittalname.value == resubmittalUnknownCode) { document.getElementById("submittalnamespan2").className = "show"; } else { document.getElementById("submittalnamespan2").className = "hidden"; } return true; } function validateForm(fm,ispap) { if (fm.shortcode.value == "") { alert("Please select a journal."); return false; } if (! validateYear(fm.year.value)) { alert("Please enter a valid four digit year."); return false; } if (ispap == "PAP") { if (fm.year.value != "9000") { alert("For PAP issue, please enter 9000 as the year."); return false; } } else { if (fm.year.value == "9000") { alert("For live issue, please enter the issue's year."); return false; } } if (fm.file.value == "") { alert("Please select a file."); return false; } issuename = ""; if (fm.supplement.checked) { issuename = fm.supplementname.value; } else if (fm.submittal.checked) { issuename = fm.submittalname.value; if (issuename == resubmittalUnknownCode) { issuename = fm.freeformresubmittal.value; fm.manuallyEntered.value = true; } else if (issuename == "") { issuename = fm.freeformresubmittal.value; fm.manuallyEntered.value = true; } else { fm.manuallyEntered.value = false; } } if (issuename != "") { val = validateIssueName(issuename); if (!val) { alert("Please enter a valid issue name (########.#)"); return false; } } else { alert("Please select an issue name."); return false; } issueNameYear = issuename.substring(0, 4); if (ispap == "PAP") { if ( issueNameYear != "9000") { alert("The year does not match the issuename."); return false; } } else { if ( fm.year.value != issueNameYear) { alert("The year does not match the issuename."); return false; } } var filename = fm.file.value; var zipparts = filename.match(/([A-Za-z]{3,8})(\d{4})(\d{2})(\d{2})\.(\d).zip$/im); if ( fm.year.value != zipparts[2] ) { alert("The year does not match the zip filename"); return false; } return true; } function validateYear(str) { if (str == "" || ! validateNumber(str) || str.length != 4) { return false; } else { return true; } } function validateNumber(strNum) { return ! isNaN(parseInt(strNum)); } function validateIssueName(strName) { if (strName.length <8 || strName.length > 11) { return false; } for(var j=0; j