Created
January 13, 2017 16:07
-
-
Save thepsion5/ef3eb7a8284c72ed00db0c675db83733 to your computer and use it in GitHub Desktop.
Legacy Javascript from a SPA written in 2007
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Vintage Jquery 1.3 | |
$.post("DataFiles/Registration.ashx", | |
{ | |
//Actual values sent to the server are formatted are broken into 3 segments, separated by a tilde | |
//The first is the type to which the value should be cast at the server, the second the actual value | |
//The third segment, "fin" specifies the server should not validate or update those fields | |
//We have the best code. Tremendous code, people tell me all the time. | |
new_ncoqfrname: $("#txtRegNo").attr("type") + "~" + $("#txtRegNo").val() + "~fin", | |
new_federalidfein: $("#new_federalidfein").attr("type") + "~" + $("#new_federalidfein").val() + "~fin", | |
new_ncoqfrfinancialperiodstartdate: "datetime" + "~" + $("#new_ncoqfrfinancialperiodstartdate").val() + "~fin", | |
new_ncoqfrfinancialperiodenddate: "datetime" + "~" + $("#new_ncoqfrfinancialperiodenddate").val() + "~fin", | |
/* Not pictured: an additional hundred lines of this */ | |
//Apparently, at some point the client wanted a snapshot of what the customer sees when filling out the form. | |
//Why not send the entire HTML file to the server via AJAX? | |
htmldocument: "HTMLdoc" + "~" + getHTML() | |
}, function(msg) { | |
//We can redirect the user to an arbitrary URL fragment supplied after the tilde | |
if (msg.toString().match("success~")) { | |
$('#btnSubmit').attr("disabled", true); | |
if (msg.toString().match("pgnotsetto1")) { | |
//This will be super helpful to our end users | |
alert('Payment Gateway Option in webconfig is not set to 1.'); | |
location.href = "edit.aspx"; | |
} | |
else if (msg.toString().match("nofeepaid")) { | |
alert('The application was submitted. There will be no fee paid with this transaction. You will receive email confirmation within one day. Thank you.'); | |
location.href = "edit.aspx"; | |
} | |
else { | |
var ReturnString; | |
ReturnString = msg.toString().split('~'); | |
location.href = ReturnString[1]; | |
} | |
} | |
else if (msg == "Timeout") { | |
alert("Sorry, your connection to the server has timed out"); | |
location.href = "login.aspx"; | |
} | |
else if (msg != "Saved") { | |
alert('Error saving data , ' + msg + " Taking you back to Main page."); | |
location.href = "edit.aspx"; | |
} | |
else { | |
//I don't know. | |
if (document.getElementById("AppType").value == "New") | |
location.href = "Change.aspx"; | |
else | |
location.href = "FinancialSummary.aspx"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment