Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ObjectList for TV programs.
- var Channel_list = [];
- var Program_list = [];
- /**Object for Channels*/
- function Channel(chan_name)
- {
- this.chan_name = chan_name;
- }
- /**Object for each program listing */
- function Program(displayname,startingtime,progLength,rating,description,genre,picture)
- {
- this.displayname = displayname;
- this.startingtime = startingtime;
- this.progLength = progLength;
- this.rating = rating;
- this.description = description;
- // this.programLength = this.endingtime - this.startingtime;
- }
- /**Initial function that populates the data into arrays */
- function init()
- {
- <?php
- $server = "209.237.150.200";
- $username = "116539_web2";
- $password = "alpaca88";
- $conn = mysql_connect($server, $username, $password);
- mysql_select_db("116539_web2spring2010", $conn);
- // $result = mysql_query("SELECT * ", $conn);
- //$num_rows = mysql_num_rows($result);
- $result = mysql_query("SELECT pid, name, descrip, rating, channel, startTime, lengthMinutes FROM TivoAlan ORDER BY channel, startTime");
- $channel = mysql_query("SELECT DISTINCT channel FROM TivoAlan ORDER BY channel");
- $channel2 = mysql_result($channel, 1, "channel");
- $num_rows = mysql_num_rows($channel);
- $query = "SELECT channel FROM TivoAlan WHERE channel='$channel2'";
- $prog = mysql_query($query);
- $progcount = mysql_num_rows($prog);
- $totalPrograms = 0;
- for($i = 0; $i < $num_rows; $i++)
- {
- ?>
- Channel_list[<?php print($i) ?>] = new Channel("<?php print mysql_result($channel, $i, "channel");?>");
- Program_list[<?php print($i) ?>] = [];
- // There are <?php print $progcount; ?> items for this channel
- <?php
- for($h = 0; $h < $progcount; $h++)
- {
- $progNum = $totalPrograms + $h;
- ?>
- 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") ?>");
- <?php
- }
- $totalPrograms += $progcount;
- }
- ?>
- loadtable();
- }
- /**Creates all the rows and cells for the interface and loads the information from init(). */
- function loadtable()
- {
- var table = document.getElementById("tivoTable");
- //Removes extra rows when the table is being loaded.
- var existingProgRows = document.getElementsByClassName('programRow');
- for (var r = existingProgRows.length - 1 ; r >= 0; r --)
- {
- table.removeChild(existingProgRows[r]);
- }
- //each channel in our listing
- for (var i = 0; i < Channel_list.length; i ++)
- {
- //the Channel object for this channel
- var curChannel = Channel_list[i];
- //create the row for this channel
- var row = document.createElement('tr');
- row.setAttribute('class', 'programRow');
- table.appendChild(row);
- //add the channel name on the left
- var channelNameCell = document.createElement('td');
- channelNameCell.appendChild(document.createTextNode(curChannel.chan_name));
- channelNameCell.setAttribute('class', 'interfaceColors');
- row.appendChild(channelNameCell);
- //each program for this channel
- for (var j = 0; j < Program_list[i].length; j ++)
- {
- var curProgram = Program_list[i][j];
- //creates the 'td' for each program
- var pNameCell = document.createElement('td');
- // pNameCell.setAttribute('class', 'Prog' + i + j + '');
- pNameCell.setAttribute('style','background-color:yellow');
- pNameCell.setAttribute('style','width:250px');
- pNameCell.setAttribute('onMouseOver' , "this.style.background='#A34F00'");
- pNameCell.setAttribute('onMouseOut' , "this.style.background='wheat'");
- pNameCell.setAttribute('onclick', 'displayProgram(' + i + ', ' + j + ');');
- pNameCell.setAttribute('ondblclick','editProgram(' + i + ', ' + j + ');');
- //creates the Text Link for each cell
- var pNameLink = document.createElement('a');
- pNameLink.setAttribute('onclick', 'displayProgram(' + i + ', ' + j + ');');
- pNameLink.setAttribute('ondblclick','editProgram(' + i + ', ' + j + ');');
- pNameLink.setAttribute('href', '#');
- pNameLink.appendChild(document.createTextNode(curProgram.displayname));
- pNameCell.appendChild(pNameLink);
- //checks for multiple slot spanning programs
- if (curProgram.progLength == 60)
- pNameCell.setAttribute("colspan", 2);
- else if (curProgram.progLength == 90)
- pNameCell.setAttribute("colspan", 3);
- row.appendChild(pNameCell);
- }
- }
- }
Add Comment
Please, Sign In to add comment