pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Javascript pastebin - collaborative debugging tool View Help


Posted by Hurpe on Wed 15 Oct 21:34
report abuse | View followups from SLT | download | new post

  1. <html>
  2.   <head>
  3.     <script type="text/javascript">
  4.       /**
  5.        *Constant Variables used to identify array locations ie. room[breakfast];
  6.        *First Dimmension
  7.        **/
  8.       var breakfast = 0;
  9.       var lunch = 1;
  10.       var dinner = 2;
  11.       var special = 3;
  12.       var full = 4;
  13.      
  14.       /**
  15.        *More constant variables used to identify array locations
  16.        *Second Dimmension: ie. room[breakfast][roomString];
  17.        **/
  18.       var roomString = 0;
  19.       var midweekcost = 1;
  20.       var weekendcost = 2;
  21.      
  22.       var room = 0;
  23.       var podium = 1;
  24.       var piano = 2
  25.       var podiumPPA = 3;
  26.       var PPA = 4;
  27.       var scr = 5;
  28.       var AV = 6;
  29.       var cat = 7;
  30.       var dancefloor = 8;
  31.      
  32.       /**
  33.        *Constructor:
  34.        *Creates a new BilliardRoom Object and sets all variables to their default value
  35.        *This includes room costs for various times, and equipment rental costs.
  36.        **/
  37.       function billiard() {
  38.        
  39.         this.time = new Array(new Array(),new Array(),new Array(),new Array(),new Array());
  40.        
  41.         this.time[breakfast][roomString] = "Breakfast - 7:00 AM through 10:00 AM";
  42.         this.time[lunch][roomString] = "Lunch - 11:00 AM through 2:00 PM";
  43.         this.time[dinner][roomString] = "Dinner - 5:00 PM through PM";
  44.         this.time[special][roomString] = "Special Event - 5:00 PM through  12:00 AM";
  45.         this.time[full][roomString] = "7AM-4PM Business Meeting";
  46.        
  47.         this.time[breakfast][midweekcost] = 75;
  48.         this.time[lunch][midweekcost] = 75;
  49.         this.time[dinner][midweekcost] = 150;
  50.         this.time[special][midweekcost] = 195;
  51.         this.time[full][midweekcost] = 100;
  52.        
  53.         this.time[breakfast][weekendcost] = 100;
  54.         this.time[lunch][weekendcost] = 100;
  55.         this.time[dinner][weekendcost] = 195;
  56.         this.time[special][weekendcost] = 250;
  57.         this.time[full][weekendcost] = 150;
  58.        
  59.         this.pointPartOfDay = 1;
  60.         this.pointPartOfWeek = 1;
  61.  
  62.         this.allCosts = new Array(9);
  63.         for (i = 0; i < 9; i++) { this.allCosts[i] = 0; }
  64.         this.cost = 0;
  65.       }
  66.      
  67.       /**
  68.        *Updates cost variable
  69.        *Should be called after any changes to values.  
  70.        *All instance methods call this method when necessary.  
  71.        *There should not be any need to change instance variables directly
  72.        **/
  73.       billiard.prototype.calculate = function() {
  74.         this.cost = 0;
  75.         for (i = 0; i < 9; i++) {
  76.           this.cost += this.allCosts[i];
  77.           }
  78.       }
  79.      
  80.       /**
  81.        *Sets the room cost to the appropriate room cost
  82.        *@param partOfDay (integer) - use the constant variables for part of day ie.
  83.        *breakfast, lunch, dinner, special, full
  84.        *
  85.        *@param partOfWeek (integer) - use the constant variables for part of week ie.
  86.        *weekendCost, midWeekCost
  87.        **/
  88.       billiard.prototype.setRoom = function(partOfDay,partOfWeek) {
  89.         this.allCosts[room] = this.time[partOfDay][partOfWeek];
  90.         this.pointPartOfDay = partOfDay;
  91.         this.pointPartOfWeek = partOfWeek;
  92.         this.calculate();      
  93.        
  94.       }
  95.      
  96.       /**
  97.        * Adds piano rental to the object
  98.        **/
  99.       billiard.prototype.addPiano = function() {
  100.         this.allCosts[piano] = 20;
  101.         this.calculate();
  102.       }
  103.      
  104.       /**
  105.        * Adds podium rental to the object
  106.        **/
  107.       billiard.prototype.addPodium = function() {
  108.         this.allCosts[podium] = 10;
  109.         this.calculate();
  110.       }
  111.      
  112.       /**
  113.        * Adds Podium/PA Package deal to the object
  114.        **/
  115.       billiard.prototype.addPodiumPPA = function() {
  116.         this.allCosts[podiumPPA] = 35;
  117.         this.calculate();
  118.       }
  119.      
  120.       /**
  121.        *Adds PA system to object
  122.        **/
  123.       billiard.prototype.addPPA = function() {
  124.         this.allCosts[podium] = 30;
  125.         this.calculate();
  126.       }
  127.      
  128.       /**
  129.        * Adds portable screen to the object
  130.        **/
  131.       billiard.prototype.addScr = function() {
  132.         this.allCosts[scr] = 10;
  133.         this.calculate();
  134.       }
  135.      
  136.       /**
  137.        * Changes all values to holiday pricing
  138.        **/
  139.       billiard.prototype.holiday = function() {
  140.         this.time[breakfast][midweekcost] = 100;
  141.         this.time[lunch][midweekcost] = 100;
  142.         this.time[dinner][midweekcost] = 200;
  143.         this.time[special][midweekcost] = 250;
  144.         this.time[full][midweekcost] = 150;
  145.        
  146.         this.time[breakfast][weekendcost] = 125;
  147.         this.time[lunch][weekendcost] = 125;
  148.         this.time[dinner][weekendcost] = 250;
  149.         this.time[special][weekendcost] = 295;
  150.         this.time[full][weekendcost] = 350;
  151.        
  152.         this.setRoom(this.pointPartOfDay,this.pointPartOfWeek);
  153.       }
  154.      
  155.       /**
  156.        * Changes all values to normal year pricing
  157.        **/
  158.       billiard.prototype.unholiday = function() {
  159.         this.time[breakfast][midweekcost] = 75;
  160.         this.time[lunch][midweekcost] = 75;
  161.         this.time[dinner][midweekcost] = 150;
  162.         this.time[special][midweekcost] = 195;
  163.         this.time[full][midweekcost] = 100;
  164.        
  165.         this.time[breakfast][weekendcost] = 100;
  166.         this.time[lunch][weekendcost] = 100;
  167.         this.time[dinner][weekendcost] = 195;
  168.         this.time[special][weekendcost] = 250;
  169.         this.time[full][weekendcost] = 150;
  170.        
  171.         this.setRoom(this.pointPartOfDay,this.pointPartOfWeek);
  172.       }
  173.      
  174.       /**
  175.        * Adds off-site catering fee
  176.        **/
  177.       billiard.prototype.catering = function() {
  178.         value = 350;
  179.         if (this.allCosts[cat] != value) {
  180.           this.allCosts[cat] = value;
  181.         } else {
  182.           this.allCosts[cat] = 0;
  183.        
  184.         }
  185.         this.calculate();
  186.       }
  187.      
  188.       /**
  189.        * Calculates cost of dance floor, and adds cost to object
  190.        **/
  191.       billiard.prototype.addDanceFloor = function(height,width) {
  192.         if ((height+width)%3 != 0) {
  193.           alert("Error occured while calculating dance floor cost.  Dance flooring must be in increments of 3'x3' tiles.  The change was not made.");
  194.         } else {
  195.           sqft = height*width;
  196.           if (sqft < 144)
  197.             costperft = .52;
  198.           else if (sqft < 225)
  199.             costperft = .44;
  200.           else if (sqft < 324)
  201.             costperft = .37;
  202.           else
  203.             costperft = .29
  204.           this.allCosts[dancefloor] = costperft*sqft;
  205.           this.calculate();
  206.         }
  207.       }
  208.      
  209.       /**
  210.        * Instantiates the billard class for use throughout the page.
  211.        **/
  212.       bill = new billiard();
  213.     </script>
  214.    
  215.     <script>
  216.       function updateFields() {
  217.         document.getElementById('bf').innerHTML = bill.time[breakfast][bill.pointPartOfWeek];
  218.         document.getElementById('ln').innerHTML = bill.time[lunch][bill.pointPartOfWeek];
  219.         document.getElementById('dn').innerHTML = bill.time[dinner][bill.pointPartOfWeek];
  220.         document.getElementById('se').innerHTML = bill.time[special][bill.pointPartOfWeek];
  221.         document.getElementById('fdr').innerHTML = bill.time[full][bill.pointPartOfWeek];
  222.         document.getElementById('cost').innerHTML = bill.cost;
  223.         return 1;
  224.       }
  225.  
  226.     </script>
  227.   </head>
  228.   <body>
  229.     <form action='index.php?link=price&post=lodge' method='post'>
  230.       <b>"The Lodge"</b> <br />
  231.       So far your quote is: $ <font id="cost">0</font> <br />
  232.       About when will the event be?
  233.       <select onchange='if(this.selectedIndex == 0) {bill.unholiday();updateFields()} else { bill.holiday();updateFields()}' id='date' name='date'>
  234.         <option value='else'>Jan. 02 - Nov. 20</option>
  235.         <option value='christmas'>Nov. 20 - Jan. 01</option>
  236.       </select>
  237.       <br />
  238.       What part of the week will the event occur?
  239.       <select onchange='if(this.selectedIndex == 0) {bill.pointPartOfWeek = 1;} else { bill.pointPartOfWeek = 2;}updateFields();alert(updateFields());' id='day' name='day'>
  240.         <option value='0'>Monday thru Thursday</option>
  241.         <option value='1'>Friday, Saturday, or Sunday</option>
  242.       </select>
  243.       <br />
  244.       <input type='hidden' name='cost' id='hide' /><br />
  245.       <b>Please select which of these best describes your event:</b>
  246.       <br />
  247.       <input onclick="bill.setRoom(breakfast,bill.pointPartOfWeek);updateFields()" type="radio" name="time" id="bfl" value="bf" />Breakfeast (7:00-10:00am) $<font id="bf"></font><br />
  248.       <input onclick="bill.setRoom(lunch,bill.pointPartOfWeek);updateFields()" type="radio" name="time" id="lnl" value="ln" />Lunch (11:00-2:00pm) $<font id="ln"></font><br />
  249.       <input onclick="bill.setRoom(dinner,bill.pointPartOfWeek);updateFields()" type="radio" name="time" id="dnl" value="dn" />Dinner (5:00-10:00pm) $<font id="dn"></font><br />
  250.       <input onclick="bill.setRoom(special,bill.pointPartOfWeek);updateFields()" type="radio" name="time" id="sel" value="se" />Special Event - (5:00-12:00pm) $<font id="se"></font><br />
  251.       <input onclick="bill.setRoom(full,bill.pointPartOfWeek);updateFields()" type="radio" name="time" id="fdrl" value="fdr" />7-4 Business Meeting $<font id="fdr"></font><br />
  252.       <script>updateFields()</script>
  253.       <br /><b>Check that which apply:</b> <br />
  254.       <input name='offsite' onclick='bill.catering();updateFields();' id='offsite' type='checkbox' /> Off-site catering ($350) - required for events that serve food other than what is offered by Brick29 and Elisabeta Europian Market.<br />
  255.       <input onclick='bill.addPodium();updateFields();' type='checkbox' name='podium' /> Podium ($20).<br />
  256.       <input onclick='bill.addPiano();updateFields();' type='checkbox' name='piano' /> Piano ($25).<br />
  257.       <input onclick='bill.addPPA();updateFields();' type='checkbox' name='ppa' /> Portable PA system. ($10)<br />
  258.       <input onclick='bill.addPPA();updateFields();' type='checkbox' name='podiumppa' /> Package Deal: Portbale PA System and Podium ($35)<br />  
  259.       <input onclick='bill.addPPA();updateScr();' type='checkbox' name='scr' /> Portable Screen ($ 10.00)<br />  
  260.          
  261.       <b>
  262.       <br />
  263.       Dance Flooring: <i>Floor tiles come in 3'x3' tiles.  These can be arranged in any manner you choose. </i><br />
  264.       <input onclick='bill.addDanceFloor(12,12);updateFields();' type='checkbox'  id='1212' name='1212' /> Under 144 ft˛ (12'x12')- $.52/ft˛<br />
  265.       <input onclick='bill.addDanceFloor(15,15);updateFields();' type='checkbox'  id='1515' name='1515' /> Under 225 ft˛ (15'x15')- $.44/ft˛ <br />
  266.       <input onclick='bill.addDanceFloor(18,18);updateFields();' type='checkbox'  id='1818' name='1818' /> Under 324 ft˛ (18'x18')- $.37/ft˛<br />
  267.       <input onclick='bill.addDanceFloor(21,21);updateFields();' type='checkbox'  id='2121' name='2121' /> Over 441 ft˛ (21'x21')- $.29/ft˛ <br />
  268.       <input type='submit' value='Book This Event!' />  
  269.     </form>
  270.   </body>
  271. </html>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post