Created
March 6, 2013 16:09
-
-
Save alexeightsix/5100425 to your computer and use it in GitHub Desktop.
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
<script type="text/javascript"> | |
function generateFaceValues() { | |
var rows = $('.ticketDetail-table li'); | |
$.each(rows, function (index, value) { | |
var row = new Object(); | |
row.status = $(this).data('status'); | |
row.row = $(this).data('row'); | |
row.section = $(this).data('section'); | |
switch (row.section) { | |
case 101: | |
if (row.row == 'P' || row.row == 'M' || row.row == 'O' || row.row == 'J') { | |
row.faceValue = ["$100.00", "$110", "$175"]; | |
} | |
break; | |
case 102: | |
if (row.row == 'M') { | |
row.faceValue = ["$100.00", "$110.00", "$175.00"]; | |
} | |
break; | |
case 103: | |
if (row.row == 'O') { | |
row.faceValue = ["$100.00", "$110.00", "$175.00"]; | |
} | |
break; | |
case 109: | |
if (row.row == 'K' || row.row == 'J' || row.row == 'O' || row.row == 'B') { | |
row.faceValue = ["$100.00.00", "$110.00", "$200.00"]; | |
} | |
break; | |
case 110: | |
if (row.row == 'L' || row.row == 'K') { | |
row.faceValue = ["$100.00", "$110.00", "$200.00"]; | |
} | |
break; | |
case 111: | |
if (row.row == 'R' || row.row == 'N' || row.row == 'P') { | |
row.faceValue = ["$100.00", "$110.00", "$200.00"]; | |
} | |
break; | |
case 112: | |
if (row.row == 'N' || row.row == 'M') { | |
row.faceValue = ["$100.00", "$110.00", "$200.00"]; | |
} | |
break; | |
case 113: | |
if (row.row == 'N' || row.row == 'K') { | |
row.faceValue = ["$100.00", "$110.00", "$200.00"]; | |
} | |
if (row.row == 'A') { | |
row.faceValue = ["$155.00", "$225.00", "$300.00"]; | |
} | |
break; | |
case 115: | |
if (row.row == 'C') { | |
row.faceValue = ["$135.00", "$174.00", "$250.00"]; | |
} | |
break; | |
case 120: | |
if (row.row == 'M' || row.row == 'O' || row.row == 'N') { | |
row.faceValue = ["$100.00", "$110.00", "$175.00"]; | |
} | |
break; | |
case 204: | |
if (row.row == 'B') { | |
row.faceValue = ["$75.00", "$95.00", "$150.00"]; | |
} | |
break; | |
case 205: | |
if (row.row == 'F') { | |
row.faceValue = ["$75.00", "$95.00", "$150.00"]; | |
} | |
break; | |
case 225: | |
if (row.row == 'F') { | |
row.faceValue = ["$75.00", "$95.00", "$150.00"]; | |
} | |
break; | |
case 226: | |
if (row.row == 'C') { | |
row.faceValue = ["$75.00", "$95.00", "$150.00"]; | |
} | |
break; | |
} | |
}); | |
} | |
function removeDuplicates() { | |
var seen = {}; | |
$('option').each(function () { | |
var txt = $(this).text(); | |
if (seen[txt]) $(this).remove(); | |
else seen[txt] = true; | |
}); | |
} | |
function sortSelect() { | |
var my_options = $("#section-filter option"); | |
my_options.sort(function (a, b) { | |
if (a.text > b.text) return 1; | |
else if (a.text < b.text) return -1; | |
else return 0 | |
}) | |
$('#section-filter').empty().append(my_options); | |
var priceFilter = $("#filtering-price option"); | |
priceFilter.sort(function (a, b) { | |
if (a.text < b.text) return 1; | |
else if (a.text > b.text) return -1; | |
else return 0 | |
}) | |
$("#filtering-price").empty().append(priceFilter); | |
} | |
function generateSectionDropdown(tickets, select) { | |
$.each(tickets, function () { | |
var ticketRow = $(this).attr('data-row'); | |
var ticketSection = $(this).attr('data-section') | |
if (ticketSection) { | |
select.append('<option value="' + ticketSection + '">' + ticketSection + '</option>') | |
} | |
}) | |
} | |
function generatePriceDropdown(tickets) { | |
$.each(tickets, function () { | |
var thisPrice = $(this).attr('data-ppt'); | |
var thisPriceFormatted = $(this).attr('data-pptm'); | |
var isVisable = $(this).css('display'); | |
var isAvailable = $(this).attr('data-status'); | |
if (isAvailable == 'available') { | |
$('#filtering-price').append('<option value="' + thisPrice + '">' + thisPriceFormatted + '</option>'); | |
} | |
}) | |
} | |
$(document).ready(function () { | |
var tickets = $(".ticketDetail-table ul li:not(:first)"); | |
var select = $('.filtering select'); | |
generateSectionDropdown(tickets, select); | |
generatePriceDropdown(tickets); | |
removeDuplicates(); | |
$('#section-filter').on('change', function () { | |
var selectedSection = $(this).attr('value'); | |
$('#filtering-price option:nth-child(1)').attr('selected', ''); | |
if (selectedSection == 'All Sections') { | |
tickets.show(); | |
} | |
else { | |
tickets.hide(); | |
$('[data-section="' + selectedSection + '"]').show(); | |
} | |
}) | |
$('#hide-sold').mousedown(function () { | |
if (!$(this).is(':checked')) { | |
$('[data-status="sold"]').hide(); | |
} | |
else { | |
$('[data-status="sold"]').show(); | |
} | |
}); | |
$('#filtering-price').on('change', function () { | |
//$('#section-filter option:nth-child(1)') | |
$('option[value="All Sections"]').attr('selected', ''); | |
var thisPrice = $(this).attr('value'); | |
if (thisPrice == 'All Prices') { | |
tickets.show(); | |
} | |
else { | |
tickets.hide(); | |
$('[data-ppt="' + thisPrice + '"]').show(); | |
} | |
}) | |
sortSelect(); | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment