Guest User

Untitled

a guest
Jul 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. //ObjectList for TV programs.
  2.  
  3. var Channel_list = [];
  4. var Program_list = [];
  5.  
  6.  
  7. /**Object for Channels*/
  8. function Channel(chan_name)
  9. {
  10. this.chan_name = chan_name;
  11. }
  12.  
  13. /**Object for each program listing */
  14. function Program(displayname,startingtime,progLength,rating,description,genre,picture)
  15. {
  16. this.displayname = displayname;
  17. this.startingtime = startingtime;
  18. this.progLength = progLength;
  19. this.rating = rating;
  20. this.description = description;
  21.  
  22. // this.programLength = this.endingtime - this.startingtime;
  23. }
  24.  
  25. /**Initial function that populates the data into arrays */
  26. function init()
  27. {
  28. <?php
  29.  
  30. $server = "209.237.150.200";
  31. $username = "116539_web2";
  32. $password = "alpaca88";
  33. $conn = mysql_connect($server, $username, $password);
  34.  
  35. mysql_select_db("116539_web2spring2010", $conn);
  36. // $result = mysql_query("SELECT * ", $conn);
  37. //$num_rows = mysql_num_rows($result);
  38. $result = mysql_query("SELECT pid, name, descrip, rating, channel, startTime, lengthMinutes FROM TivoAlan ORDER BY channel, startTime");
  39. $channel = mysql_query("SELECT DISTINCT channel FROM TivoAlan ORDER BY channel");
  40. $channel2 = mysql_result($channel, 1, "channel");
  41. $num_rows = mysql_num_rows($channel);
  42.  
  43. $query = "SELECT channel FROM TivoAlan WHERE channel='$channel2'";
  44. $prog = mysql_query($query);
  45. $progcount = mysql_num_rows($prog);
  46. $totalPrograms = 0;
  47.  
  48. for($i = 0; $i < $num_rows; $i++)
  49. {
  50. ?>
  51. Channel_list[<?php print($i) ?>] = new Channel("<?php print mysql_result($channel, $i, "channel");?>");
  52. Program_list[<?php print($i) ?>] = [];
  53. // There are <?php print $progcount; ?> items for this channel
  54. <?php
  55. for($h = 0; $h < $progcount; $h++)
  56. {
  57. $progNum = $totalPrograms + $h;
  58. ?>
  59. Program_list[<?php print($i) ?>][<?php print($h) ?>] = new Program("<?php print mysql_result($result, $prognum, "name") ?>",<?php print mysql_result($result, $prognum, "startTime") ?>,<?php print mysql_result($result, $prognum, "lengthMinutes") ?>,"<?php print mysql_result($result, $prognum, "rating") ?>","<?php print mysql_result($result, $prognum, "descrip") ?>");
  60. <?php
  61. }
  62. $totalPrograms += $progcount;
  63. }
  64. ?>
  65.  
  66. loadtable();
  67.  
  68. }
  69.  
  70. /**Creates all the rows and cells for the interface and loads the information from init(). */
  71. function loadtable()
  72. {
  73.  
  74. var table = document.getElementById("tivoTable");
  75.  
  76. //Removes extra rows when the table is being loaded.
  77. var existingProgRows = document.getElementsByClassName('programRow');
  78. for (var r = existingProgRows.length - 1 ; r >= 0; r --)
  79. {
  80. table.removeChild(existingProgRows[r]);
  81. }
  82.  
  83. //each channel in our listing
  84. for (var i = 0; i < Channel_list.length; i ++)
  85. {
  86.  
  87. //the Channel object for this channel
  88. var curChannel = Channel_list[i];
  89.  
  90. //create the row for this channel
  91. var row = document.createElement('tr');
  92. row.setAttribute('class', 'programRow');
  93. table.appendChild(row);
  94.  
  95. //add the channel name on the left
  96. var channelNameCell = document.createElement('td');
  97. channelNameCell.appendChild(document.createTextNode(curChannel.chan_name));
  98. channelNameCell.setAttribute('class', 'interfaceColors');
  99. row.appendChild(channelNameCell);
  100.  
  101. //each program for this channel
  102. for (var j = 0; j < Program_list[i].length; j ++)
  103. {
  104.  
  105. var curProgram = Program_list[i][j];
  106.  
  107. //creates the 'td' for each program
  108. var pNameCell = document.createElement('td');
  109. // pNameCell.setAttribute('class', 'Prog' + i + j + '');
  110. pNameCell.setAttribute('style','background-color:yellow');
  111. pNameCell.setAttribute('style','width:250px');
  112. pNameCell.setAttribute('onMouseOver' , "this.style.background='#A34F00'");
  113. pNameCell.setAttribute('onMouseOut' , "this.style.background='wheat'");
  114. pNameCell.setAttribute('onclick', 'displayProgram(' + i + ', ' + j + ');');
  115. pNameCell.setAttribute('ondblclick','editProgram(' + i + ', ' + j + ');');
  116.  
  117. //creates the Text Link for each cell
  118. var pNameLink = document.createElement('a');
  119. pNameLink.setAttribute('onclick', 'displayProgram(' + i + ', ' + j + ');');
  120. pNameLink.setAttribute('ondblclick','editProgram(' + i + ', ' + j + ');');
  121. pNameLink.setAttribute('href', '#');
  122. pNameLink.appendChild(document.createTextNode(curProgram.displayname));
  123.  
  124. pNameCell.appendChild(pNameLink);
  125.  
  126. //checks for multiple slot spanning programs
  127. if (curProgram.progLength == 60)
  128. pNameCell.setAttribute("colspan", 2);
  129. else if (curProgram.progLength == 90)
  130. pNameCell.setAttribute("colspan", 3);
  131.  
  132.  
  133. row.appendChild(pNameCell);
  134. }
  135.  
  136. }
  137.  
  138. }
Add Comment
Please, Sign In to add comment