/* use tools/minify_js.pl to create min.js for this file */ /* create namespaces for our container and wait panel */ FONALITY.namespace('container'); FONALITY.namespace('panel'); var supportalOpen = 0; var openSupport = document.location.search.indexOf('opensupport=1') == -1 ? 0 : 1; var complete; /* do this when submission of ticket is successful */ function submitCallback(obj) { var response = document.getElementById('if_supportal_submit').contentWindow.document.body.innerHTML; document.getElementById('if_supportal_submit').contentWindow.document.body.innerHTML; if(response.indexOf('error:')>-1){ var err = response.substring(6); var txt = err.split("::end::"); err = txt[0]; submitFailure(err); } else{ /* make the "wait" disappear */ FONALITY.panel.wait.hide(); alert("Thank you! Your ticket has been submitted."); supportalOpen = 0; /* if we're on the login page, show the login */ if (openSupport) { if (document.getElementById('mainpage')) document.getElementById("mainpage").style.visibility = "visible"; if (!document.getElementById('supportal_username').disabled) placeFocus2('f','username'); } } } /* do this when the submission of ticket fails! */ function submitFailure(response) { /* make the "wait" disappear */ FONALITY.panel.wait.hide(); alert("Unable to submit ticket: " + response); showSupportal(); } /* initialize our supportal box */ function init() { var handleCancel = function() { supportalOpen = 0; this.cancel(); } /* our submit function, occurs when user hits Submit */ var handleSubmit = function() { /* do some validation */ /* if we're asking username/pass */ if (document.getElementById('supportal_username') && document.getElementById('supportal_password')) { if (!checkInput('supportal_username', 'You must enter your username.')) return false; if (!checkInput('supportal_password', 'You must enter your password.')) return false; } /* check name */ if (!checkInput('supportal_name', 'You must enter your name.', 'Your Name')) return false; /* check email */ if (!checkInput('supportal_email', 'You must enter your email address.', 'Email Address')) return false; /* check symptom cat if support ticket */ if ( ( document.getElementById('supportal_request').value == 'support' || document.getElementById('supportal_request').value == 'hud_bug' ) && !checkInput('supportal_symptom_cat', 'You must select a category.')) return false; /* check symptom if support ticket */ if ( ( document.getElementById('supportal_request').value == 'support' || document.getElementById('supportal_request').value == 'hud_bug' ) && !checkInput('supportal_symptom', 'You must select a symptom.')) return false; /* check subject if not support ticket */ if ( ( document.getElementById('supportal_request').value == 'support' || document.getElementById('supportal_request').value == 'hud_bug' ) && !checkInput('supportal_subject', 'You must enter a short description of your problem.', 'Short Description')) return false; /* check body */ if (!checkInput('supportal_text', 'You must enter a message.')) return false; /* check body for default msg */ if (document.getElementById('supportal_text').value == 'Enter your question here!') { alert('Please enter an accurate message.'); document.getElementById('supportal_text').select(); return false; } /* set category text in the backend to send to the ticket */ document.getElementById('supportal_symptom_text').value = document.getElementById('supportal_symptom_cat').options[document.getElementById('supportal_symptom_cat').selectedIndex].text; /* set symptom if we're in support */ if (document.getElementById('supportal_request').value == 'support' || document.getElementById('supportal_request').value == 'hud_bug' ) document.getElementById('supportal_symptom_text').value = document.getElementById('supportal_symptom_text').value + " -- " + document.getElementById('supportal_symptom').options[document.getElementById('supportal_symptom').selectedIndex].value; /* display our wait panel */ FONALITY.panel.wait = new FONALITY.widget.Panel("wait", { width:"240px", fixedcenter:true, close:false, draggable:true, modal:true, effect:{effect:FONALITY.widget.ContainerEffect.FADE, duration:0.5} } ); FONALITY.panel.wait.setHeader("Sending, please wait..."); FONALITY.panel.wait.setBody(""); FONALITY.panel.wait.render(document.body); FONALITY.panel.wait.show(); //this.submit(); //woot // document.getElementById('if_supportal_submit').onload = function(){ // submitCallback(); // } document.dlgForm.submit(); FONALITY.container.dlg.hide(); } if (document.getElementById('dlg')) { document.getElementById('dlg').style.position = "relative"; } FONALITY.container.dlg = new FONALITY.widget.Dialog("dlg", { modal:true, visible:false, width:"632px", fixedcenter:true, constraintoviewport:true, draggable:true }); FONALITY.container.dlg.callback.success = submitCallback; FONALITY.container.dlg.callback.failure = submitFailure; var listeners = new FONALITY.util.KeyListener(document, { keys : 27 }, {fn:handleCancel,scope:FONALITY.container.dlg,correctScope:true} ); FONALITY.container.dlg.cfg.queueProperty("keylisteners", listeners); FONALITY.container.dlg.cfg.queueProperty("buttons", [ { text:"Submit", handler:handleSubmit } ]); var handleManual = function(type, args, obj) { alert("Manual submission of " + this.id + " detected"); } FONALITY.container.dlg.beforeHideEvent.subscribe(function() { supportalOpen = 0; }); FONALITY.container.dlg.manualSubmitEvent.subscribe(handleManual, FONALITY.container.dlg, true); FONALITY.container.dlg.render(); } /* This next line causes the CP to look like it's always loading something, however it's necessary. We should investigate a method to prevent this loading */ FONALITY.util.Event.addListener(window, "load", init); /* show the supportal */ function showSupportal(type) { /* I know, this sucks. firefox vs ie margins for the main supportal table */ if (document.all) document.getElementById('supportal_table').style.marginLeft = "3px"; else document.getElementById('supportal_table').style.marginLeft = "2px"; /* set our supportal to open */ supportalOpen = 1; /* get our current page source */ document.getElementById('supportal_html').value = getSource(); /* helps prevent hidden skeleton in IE */ document.getElementById('dlg').style.display = 'block'; /* if we know the type of ticket, select it */ /* no need to do this in js */ if (type) changeSelect('supportal_request', type); /* select our server id if we have one (logged in) */ if (server_id) changeSelect('supportal_sid', server_id); /* if we're on the intro page, hide the flash (otherwise it rolls over) */ /* this only happens for me in firefox, but happens to matt austin in IE */ if (document.getElementById('movie')) document.getElementById('movie').style.visibility = "hidden"; /* enable or disable symptom dropdown based on request */ symptomEnable(); /* show the dialog */ FONALITY.container.dlg.show(); /* get our autocompletion dialog setup */ complete = new BComplete('symptomSearch'); complete.setData(full_symptoms); /* focus on body if logged in */ /* otherwise, focus on username */ if (server_id) document.getElementById('supportal_text').focus(); else { if (document.getElementById('supportal_username').disabled) document.getElementById('supportal_text').focus(); else document.getElementById('supportal_username').focus(); } } function checkInput(ref, text, desc) { if (document.getElementById(ref)) { if (document.getElementById(ref).value && document.getElementById(ref).value != "--" && document.getElementById(ref).value != desc) { document.getElementById(ref).style.color = "black"; return 1; } else { alert(text); document.getElementById(ref).focus(); if (desc) { document.getElementById(ref).value = desc; document.getElementById(ref).style.color = "red"; } return 0; } } return 0; } /* populate symptom and category based off of search */ function setSupportalSymptoms(text) { var strings = text.split(" -- ", 2); for (var i = 0; i < document.dlgForm.symptom_cat.length; i++) { if (document.dlgForm.symptom_cat[i].text == strings[0]) { document.dlgForm.symptom_cat.selectedIndex = i; symptomPopulate(document.dlgForm); break; } } for (var i = 0; i < document.dlgForm.symptom.length; i++) { if (document.dlgForm.symptom[i].text == strings[1]) { document.dlgForm.symptom.selectedIndex = i; break; } } } /* populate symptom search text */ function symptomChoose(frm) { // let's pull the cool dropdown down when they don't specify something if (frm.symptom[frm.symptom.selectedIndex].text == "--") { complete.onKeyPress(0); } else { frm.symptomSearch.value = frm.symptom_cat[frm.symptom_cat.selectedIndex].text + " -- " + frm.symptom[frm.symptom.selectedIndex].text; } } /* populate symptom dropdown */ function symptomPopulate(frm) { var box = frm.symptom_cat; var number = box.options[box.selectedIndex].value; /* be safe */ if (!number) return; var list = symptoms[number]; var box2 = frm.symptom; /* reset symptom box */ box2.options.length = 0; for (var i = 0; i < list.length; i++) { var text = list[i][1]; var origtext = text; var dash = text.indexOf(" -P"); // find the priority if (dash >= 0) { text = text.substr(0, dash); } box2.options[i] = new Option(text, origtext); } } /* enable or disable symptom dropdown based on request */ function symptomEnable() { if (document.getElementById('supportal_request').value == 'support' || document.getElementById('supportal_request').value == 'hud_bug') { document.getElementById('supportal_subject').disabled = true; document.getElementById('supportal_subject').value = "Support Request"; document.getElementById('supportal_symptom').disabled = false; document.getElementById('supportal_symptom_cat').disabled = false; } else { if (document.getElementById('supportal_subject').value == "Support Request") document.getElementById('supportal_subject').value = ""; document.getElementById('supportal_subject').disabled = false; document.getElementById('supportal_symptom').disabled = true; document.getElementById('supportal_symptom_cat').disabled = true; } } function activateSupport() { if (!FONALITY.container.dlg) setTimeout("activateSupport()", 100); else showSupportal(request_type || 'support'); } if (openSupport) { activateSupport(); }