Skip to content

Commit

Permalink
Files added to main
Browse files Browse the repository at this point in the history
  • Loading branch information
dieselleo committed Nov 22, 2021
1 parent 3fa84a9 commit 0938187
Show file tree
Hide file tree
Showing 3 changed files with 417 additions and 0 deletions.
204 changes: 204 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<!DOCTYPE html
PUBLIC "XSLT-compat">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Paddy's Cafe Menu</title><style>
body{font-family:Arial,Helvetica,sans-serif;background-color:#fff;margin:5px;text-align:left;color:#523819}
h2{font-size:140%;color:#0d3427;margin-top:10px}
p{font-size:80%;color:#523819}
table{background-color:#dacfe5;border-color:#000;border-width:thin;border-collapse:collapse;width:75%}
th{border-color:#000;font-size:120%;color:#0d3427}
td{border-color:#000;font-size:100%;color:#523819;padding:5px}
img{float:left;margin-left:10px;margin-right:10px;border:0}
.indent{margin-left:78px}
</style><script>
var gEntreeCount = 0;
// returns a number that represents the sum of all the selected menu
// item prices.
function calculateBill(idMenuTable) {
var fBillTotal = 0.0;
var i = 0;
// find the table tag
var oTable = document.getElementById(idMenuTable);
// go through the table and add up the prices of all
// the selected items. The code takes advantage of the
// fact that each checkbox has a corresponding row in
// the table, and the only INPUT tags are the checkboxes.
var aCBTags = oTable.getElementsByTagName('INPUT');
for (i = 0; i < aCBTags.length; i++) {
// is this menu item selected? it is if the checkbox is checked
if (aCBTags[i].checked) {
// get the checkbox' parent table row
var oTR = getParentTag(aCBTags[i], 'TR');
// retrieve the price from the price column, which is the third column in the table
var oTDPrice = oTR.getElementsByTagName('TD')[2];
// the first child text node of the column contains the price
fBillTotal += parseFloat(oTDPrice.firstChild.data);
};
};
// return the price as a decimal number with 2 decimal places
return Math.round(fBillTotal * 100.0) / 100.0;
};

// This function either turns on or off the row highlighting for vegetarian
// items (depending on the value of bShowVeg)
function highlightVegetarian(idTable, bShowVeg) {
// if bShowVeg is true, then we're highlighting vegetarian
// meals, otherwise we're unhighlighting them.
var i = 0;
var oTable = document.getElementById(idTable);
var oTBODY = oTable.getElementsByTagName('TBODY')[0];
var aTRs = oTBODY.getElementsByTagName('TR');
// walk through each of the table rows and see if it has a
// "vegetarian" attribute on it.
for (i = 0; i < aTRs.length; i++) {
if (aTRs[i].getAttribute('vegetarian') && aTRs[i].getAttribute('vegetarian') == "true") {
if (bShowVeg) {
aTRs[i].style.backgroundColor = "lightGreen";
} else {
aTRs[i].style.backgroundColor = "";
};
};
};
};

// Utility function for getting the parent tag of a given tag
// but only of a certain type (i.e. a TR, a TABLE, etc.)
function getParentTag(oNode, sParentType) {
var oParent = oNode.parentNode;
while (oParent) {
if (oParent.nodeName == sParentType)
return oParent;
oParent = oParent.parentNode;
};
return oParent;
};
window.addEventListener("load", function() {
document.forms[0].txtBillAmt.value = calculateBill('menuTable');
document.querySelector("#calcBill").addEventListener("click", function() {
document.forms[0].txtBillAmt.value = calculateBill('menuTable');
});
document.querySelector("#showVeg").addEventListener("click", function() {
highlightVegetarian('menuTable', this.checked);
});
});
</script></head>
<body>
<h2><img src="data:image/gif;base64,R0lGODlhOgBkANUAAP///7TWer3bi5rO0NHmr+Xx0QGEibW6tymWhsrm57zY2ZHGfdzswYeQi0yorMLdkubn52a1uPH35t/w8Nfa2G22hL3aeVOqgsbeefDy8sfhnvn78w6Kj/H4+BiOh/b67h2RljCbn6vSe/j8/AB/irjYgfv9+LjYev7+/bXXffz++vv9/bTWe/b4+Oz13ZzLfPz8/KKopT2ghP///rbXerXWejmfo4nGyHq/wbDUepifm/7//v7//7XWe4TBfv3+/CH5BAAAAAAALAAAAAA6AGQAAAb/QIBwSCwCTAzGzshsOp9QYUFQ+kSv2KuJEAgQsuAwcaPpBlziNNb0MFfVcCeq7N7E70WGuVuy4/EfJXsBKVZ/d1yDAQWHcRuCihqNcAWKfH6TYYmWDJlhJgKWXQImnlkSLKJdnaZXLqqjpa1QlbBes7S2hGi4TbW2D7K9Rb+2X8NFr7pdjMhDEst8Es5Cj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IaifHD3g1ZfYfSgUcidRpCFY7NPJQoTjbjcNTjuBkaHA4HCoAHTgDXjSSeUN+HjN0Qya1YExPSh3guigAMQO4J1kZroJRDUFtuWQooligkQQEFSIAtNQDQ9ADwToh+D/FNzBEJ8r4oMjzzRpAUsevMG4868QiBDj0AKVG+PRMFzM7U93nscT3xO2wi8vYzMJDK8+Qb4cIDAvwePxEuMGD/LEEAADs=" alt="Javaco Tea Logo" width="58" height="100">Welcome to Paddy's Cafe
</h2>
<p>Select your entrees from the menu below. To calculate the amount of the bill, click
the Calculate Bill button. Check the "Highlight Vegetarian Meals" box to highlight
vegetarian dishes.
</p>
<table id="menuTable" border="1" class="indent">
<thead>
<tr>
<th colspan="3">Paddy's Cafe Menu</th>
</tr>
<tr>
<th>Select</th>
<th>Item</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">Drinks</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Coke</td>
<td align="right">3.00</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Sprite</td>
<td align="right">3.00</td>
</tr>
<tr vegetarian="true">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Kombucha</td>
<td align="right">2.00</td>
</tr>
<tr>
<td colspan="3">Side Dishes</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Wings</td>
<td align="right">8.45</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Sausages</td>
<td align="right">6.25</td>
</tr>
<tr vegetarian="true">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Fries</td>
<td align="right">4.00</td>
</tr>
<tr>
<td colspan="3">Breakfast</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Omelette</td>
<td align="right">10.65</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Full Irish</td>
<td align="right">12.95</td>
</tr>
<tr vegetarian="true">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Avocado Toast</td>
<td align="right">8.75</td>
</tr>
<tr>
<td colspan="3">Lunch</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Soup of the Day</td>
<td align="right">9.25</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>5oz Steak Sandwich</td>
<td align="right">19.85</td>
</tr>
<tr vegetarian="true">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Eggs and Avocado Salad</td>
<td align="right">13.50</td>
</tr>
<tr>
<td colspan="3">Dinner</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Pork Ribs</td>
<td align="right">16.85</td>
</tr>
<tr vegetarian="false">
<td align="center"><input name="item0" type="checkbox"></td>
<td>10oz Center Filet Steak</td>
<td align="right">25.50</td>
</tr>
<tr vegetarian="true">
<td align="center"><input name="item0" type="checkbox"></td>
<td>Vegetarian Burger</td>
<td align="right">15.55</td>
</tr>
</tbody>
</table>
<form class="indent">
<p><input type="button" name="btnCalcBill" value="Calculate Bill" id="calcBill">
Total: €
<input type="text" name="txtBillAmt"><input type="checkbox" name="cbOpts" value="isVeg" id="showVeg"><label for="showVeg">Highlight Vegetarian Meals</label></p>
</form>
</body>
</html>
73 changes: 73 additions & 0 deletions test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0"?>
<menu>
<section name="Drinks">
<option>
<item>Coke</item>
<price>3.00</price>
</option>
<option>
<item>Sprite</item>
<price>3.00</price>
</option>
<option vegetarian="true">
<item>Kombucha</item>
<price>2.00</price>
</option>
</section>
<section name="Side Dishes">
<option>
<item>Wings</item>
<price>8.45</price>
</option>
<option>
<item>Sausages</item>
<price>6.25</price>
</option>
<option vegetarian="true">
<item>Fries</item>
<price>4.00</price>
</option>
</section>
<section name="Breakfast">
<option>
<item>Omelette</item>
<price>10.65</price>
</option>
<option>
<item>Full Irish</item>
<price>12.95</price>
</option>
<option vegetarian="true">
<item>Avocado Toast</item>
<price>8.75</price>
</option>
</section>
<section name="Lunch">
<option>
<item>Soup of the Day</item>
<price>9.25</price>
</option>
<option>
<item>5oz Steak Sandwich</item>
<price>19.85</price>
</option>
<option vegetarian="true">
<item>Eggs and Avocado Salad</item>
<price>13.50</price>
</option>
</section>
<section name="Dinner">
<option>
<item>Pork Ribs</item>
<price>16.85</price>
</option>
<option>
<item>10oz Center Filet Steak</item>
<price>25.50</price>
</option>
<option vegetarian="true">
<item>Vegetarian Burger</item>
<price>15.55</price>
</option>
</section>
</menu>
Loading

0 comments on commit 0938187

Please sign in to comment.