Created
August 15, 2011 17:44
-
-
Save bittersweetryan/1147293 to your computer and use it in GitHub Desktop.
old, messy code
This file contains hidden or 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
$(document).ready(function(){ | |
$("#saveContract").validate({ | |
messages:{ | |
highwayName:{ | |
required: "Enter a highway name." | |
} | |
} | |
}); | |
$("#projectNumber").mask("9999-99-99"); | |
//Party pay validation | |
$.validator.addClassRules("partyrange", {range:[2,3]}); | |
var partyValue = Number($('#partyId').val()); | |
if(partyValue == "3"){ | |
$(".payclass").fadeIn(); | |
} | |
else{ | |
$(".payclass").fadeOut(); | |
} | |
$("#partyId").change(function(){ | |
var partyValue = Number($('#partyId').val()); | |
if(partyValue == "3"){ | |
$(".payclass").fadeIn(); | |
} | |
else{ | |
var payValue = Number($('#payId').val()); | |
$('#payId').val(""); | |
$(".payclass").fadeOut(); | |
} | |
}); | |
//CBA Validation | |
$("#cbReq").change(function(){ | |
(this.value == "true") ? $(".cb").fadeIn():$(".cb").fadeOut(); | |
(this.value == "true") ? $(".cb").fadeIn():$('#costBenefitAdminAmount,#costBenefitDotAmount,#costBenefitConsultantAmount,#costBenefitAdminHours,#costBenefitWorkHours').attr('value',''); | |
}).change(); | |
$.validator.addMethod("NumberOnly", function(value, element) { | |
return this.optional(element) || /^[0-9]+$/i.test(value); | |
}, "Please enter numbers only"); | |
$.validator.addMethod("FloatOnly", function(value, element) { | |
return this.optional(element) || /^[0-9\.]+$/i.test(value); | |
}, "Please enter numbers only"); | |
$.validator.addClassRules("percentrange", {range:[0,100]}); | |
$('.combobox').combobox(); | |
$('.ui-autocomplete-input').focus(function(){this.select()}); | |
$('#contractType').change(function() { | |
var selectedText = $("#" + this.id + " option:selected").text().toLowerCase(); | |
$(this).children().each(function(){ | |
if($(this).text().toLowerCase() == selectedText && selectedText !== ''){ | |
$("p#" + selectedText).fadeIn(); | |
} | |
else if($(this).text() !== ""){ | |
$("p#" + $(this).text().toLowerCase()).fadeOut(); | |
} | |
}); | |
}).change(); | |
$("#dbe").change(function(){ | |
(this.value == "true") ? $(".dbe").fadeIn():$(".dbe").fadeOut(); | |
(this.value == "true") ? $(".waive").fadeIn():$(".waive").fadeOut(); | |
(this.value == "true") ? $(".dbe").fadeIn():$("#dbepctId").val(""); | |
}).change(); | |
statusType = { | |
'' : $([]), | |
'110' : $('#solicitation'), | |
'120' : $('#selection, #solicitation'), | |
'130' : $('#selection, #contractdetail, #open, #budgetdetail, #solicitation'), | |
'140' : $('#open, #selection, #contractdetail, #budgetdetail, #solicitation'), | |
'150' : $('#closure, #selection, #contractdetail, #open,#budgetdetail, #solicitation'), | |
'160' : $('#closure, #selection, #contractdetail, #open,#budgetdetail, #solicitation, #evaluation'), | |
'310' : $('#wosolicitation, #selection, #contractdetail, #budgetdetail, #solicitation'), | |
'320' : $('#wobudget, #selection, #contractdetail, #budgetdetail, #solicitation'), | |
'330' : $('#wocontractdetail, #selection, #contractdetail, #budgetdetail, #solicitation, #evaluateion') | |
}; | |
//we need to make the required and unrequired fields into a smarter object | |
$('#status').change(function() { | |
// hide all | |
$.each(statusType, function() { this.hide(); }); | |
// show current | |
statusType[$(this).val()].show(); | |
if($(this).val()==110){ | |
$("input[name='contract.selectionDateString']").removeClass("required"); | |
$("select[name='contract.vendorID']").removeClass("required"); | |
$("select[name='contractDetail.totalAmount']").removeClass("required"); | |
} | |
if($(this).val() == 120){ | |
$("input[name='contract.selectionDateString']").addClass("required"); | |
$("select[name='contract.vendorID']").addClass("required"); | |
$("select[name='contractDetail.totalAmount']").removeClass("required"); | |
} | |
if($(this).val() == 160){ | |
$("select[name='contractDetail.totalAmount']").addClass("required"); | |
} | |
}).change(); | |
//keyup triggers these events | |
$(".primeVendorCost").sumFields($("#totalPrimeVendorCosts")).keyup(); | |
$(".originalCost").sumFields($("#calcContractCosts")).keyup(); | |
$(".revisedCost").sumFields($("#totalRevisedCosts")).keyup(); | |
Number($("#manHours").val()) > 0 ? $("#costPerHour").val((Number($("#totalRevisedCosts").val())/Number($("#manHours").val())).toFixed(2)):Number($("#costPerHour").val(0)); | |
var values1 = $('#directSalCostAmt,#overheadCostAmt,#fixedfeeAmt').change(function() { | |
Number($("#directSalCostAmt").val()) + Number($("#overheadCostAmt").val()) > 0 ? | |
$("#profitPercentage").val( (Number($("#fixedfeeAmt").val())/(Number($("#directSalCostAmt").val()) + Number($("#overheadCostAmt").val()))).toFixed(2)) : | |
$("#profitPercentage").val(0); | |
$("#manHours").change(function(){ | |
Number($("#manHours").val()) > 0 ? $("#costPerHour").val((Number($("#totalRevisedCosts").val())/Number($("#manHours").val())).toFixed(2)):Number($("#costPerHour").val(0)); | |
}).change(); | |
}); | |
//Project placeholder | |
$('input[name*="contract.consultantProjectID"]').mask('9999-99-99',{placeholder:' '}); | |
//Solicitation dropdown change | |
$("#solicitationID").change(function(){ | |
var description = $("#solDescription"); | |
for(var i = 0; i < solicitationJSON.length; i++){ | |
if(solicitationJSON[i].solicitationID == $(this).val()){ | |
description.html('<span><label>Solicitation Type </label>' + solicitationJSON[i].solicitationTypLkupDesc + '</span>'); | |
return false; | |
} | |
} | |
}).change(); | |
$("#newCAUForm").dialog({ | |
autoOpen: false, | |
height: 200, | |
width: 350, | |
modal: true, | |
buttons: { | |
"Create CAU": function() { | |
var cauNumber = $("#cauNumber").val(); | |
$.ajax({ | |
url: 'newCAU.do?method=newContractCAUAjax&cauNumber=' + cauNumber, | |
success: function(retData){ | |
retData = $.trim(retData); | |
var xmlDoc = $.parseXML(retData); | |
$xml = $(xmlDoc); | |
var cauNumber = $xml.find("cau").children("cauNumber").text(); | |
var cauID = $xml.find("cau").children("cauID").text(); | |
var option = $("<option value=" + cauID + " selcted='true'>" + cauNumber + "</option>"); | |
$("#cauID").prepend(option); | |
$("#cauContainer").find(".ui-autocomplete-input").val(cauNumber).animate({'color':'#009900'},'slow'); | |
$("select[name='contract.consultantContractID']").val(cauID); | |
}, | |
error: function(){ | |
alert("Error"); | |
} | |
}); | |
$( this ).dialog( "close" ); | |
}, | |
Cancel: function() { | |
$( this ).dialog( "close" ); | |
} | |
}, | |
close: function() { | |
} | |
}); | |
$("#newCAU").click(function() { | |
$( "#newCAUForm" ).dialog( "open" ); | |
}); | |
$("#newProjectForm").dialog({ | |
autoOpen: false, | |
height: 200, | |
width: 350, | |
modal: true, | |
buttons: { | |
"Create Project": function() { | |
var projectNumber = $("#projectNumber").val(); | |
$.ajax({ | |
url: 'newProject.do?method=newProjectAjax&projectNumber=' + projectNumber, | |
success: function(retData){ | |
retData = $.trim(retData); | |
var xmlDoc = $.parseXML(retData); | |
$xml = $(xmlDoc); | |
var projectID = $xml.find("project").children("projectID").text(); | |
var projectNumber = $xml.find("project").children("projectNumber").text(); | |
var option = $("<option value=" + projectID + " selcted='true'>" + projectNumber + "</option>"); | |
$("#projectID").prepend(option); | |
$("#projectContainer").find(".ui-autocomplete-input").val(projectNumber); | |
$("select[name='contract.consultantProjectID']").val(projectID); | |
}, | |
error: function(){ | |
alert("Error"); | |
} | |
}); | |
$( this ).dialog( "close" ); | |
}, | |
Cancel: function() { | |
$( this ).dialog( "close" ); | |
} | |
}, | |
close: function() { | |
} | |
}); | |
$("#newProject").click(function() { | |
$( "#newProjectForm" ).dialog( "open" ); | |
}); | |
$("select[name='contract.projectAuthorityID']").change(function(){ | |
var countyID = $(this).val(); | |
var regionID = 0; | |
for(i = 0; i < countyJSON.length; i++){ | |
if(countyID == countyJSON[i].projectAuthID) | |
regionID = countyJSON[i].regionID; | |
} | |
$("select[name='contract.dotRegionID'] option,select[name='_removed'] option").each(function(){ | |
if($(this).val() == regionID){ | |
regionID = $(this).val(); | |
$(this).attr("selected",true).parent().attr("disabled",false); | |
$(this).parent().attr("name","_removed"); | |
var hiddenInput = $("input[name='contract.dotRegionID']"); | |
if(hiddenInput.length == 0) | |
{ | |
var inputnew = $("<input type='hidden'>"); | |
inputnew.val(regionID); | |
inputnew.attr("name","contract.dotRegionID"); | |
$("#saveContract").append(inputnew); | |
} | |
else{ | |
hiddenInput.val(regionID); | |
} | |
} | |
return true; | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment