From c699135bcebae48e50773233bf3fb32141759b28 Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 22 Jun 2010 16:56:47 +0000 Subject: [PATCH] Added some last tidbits to the UI for selecting team members at a specific event Added functionality in listSelector.js to validate data when it's switched from one list to another --- js/listSelector.js | 24 ++++++++++------ schoolschedule.php | 69 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/js/listSelector.js b/js/listSelector.js index b21dd38..bfc6b8a 100644 --- a/js/listSelector.js +++ b/js/listSelector.js @@ -6,6 +6,8 @@ var leftDiv, rightDiv, leftTitle, rightTitle, leftColours, rightColours; var items; var styleTags, boxStyle, itemStyle, rowStyle; + var leftValidator = null; + var rightValidator = null; this.name = globalName; this.leftColours = []; @@ -160,8 +162,8 @@ for(id in left){ this.items[id] = $('
' + left[id] + '
'); eval(this.name + '.items[' + id + '].click(function(){' + this.name + '.switch(' + id + ');});'); - eval(this.name + '.items[' + id + '].mouseenter(function(){' + this.name + '.highlight(' + id + ', true);});'); - eval(this.name + '.items[' + id + '].mouseleave(function(){' + this.name + '.highlight(' + id + ', false);});'); + eval(this.name + '.items[' + id + '].mouseenter(function(){' + this.name + '.highlight(' + id + ', true); document.body.style.cursor="pointer";});'); + eval(this.name + '.items[' + id + '].mouseleave(function(){' + this.name + '.highlight(' + id + ', false); document.body.style.cursor="default";});'); this.items[id].css(this.itemStyle); this.items[id].appendTo(this.leftDiv); this.items[id].data('column', 'left'); @@ -170,8 +172,8 @@ for(id in right){ this.items[id] = $('
' + right[id] + '
'); eval(this.name + '.items[' + id + '].click(function(){' + this.name + '.switch(' + id + ');});'); - eval(this.name + '.items[' + id + '].mouseenter(function(){' + this.name + '.highlight(' + id + ', true);});'); - eval(this.name + '.items[' + id + '].mouseleave(function(){' + this.name + '.highlight(' + id + ', false);});'); + eval(this.name + '.items[' + id + '].mouseenter(function(){' + this.name + '.highlight(' + id + ', true); document.body.style.cursor="pointer";});'); + eval(this.name + '.items[' + id + '].mouseleave(function(){' + this.name + '.highlight(' + id + ', false); document.body.style.cursor="default";});'); this.items[id].css(this.itemStyle); this.items[id].appendTo(this.rightDiv); this.items[id].data('column', 'right'); @@ -191,14 +193,18 @@ this.switch = function(itemId){ item = this.items[itemId]; if(item.data('column') == 'left'){ - targetDiv = this.rightDiv; - item.data('column', 'right'); + if(this.rightValidator == null || this.rightValidator(itemId)){ + item.data('column', 'right'); + this.items[itemId].appendTo(this.rightDiv); + } }else{ - targetDiv = this.leftDiv; - item.data('column', 'left'); + if(this.leftValidator == null || this.leftValidator(itemId)){ + item.data('column', 'left'); + this.items[itemId].appendTo(this.leftDiv); + } } + this.highlight(itemId, false); - this.items[itemId].appendTo(targetDiv); } this.setStyle = function(newTags){ diff --git a/schoolschedule.php b/schoolschedule.php index b5791c9..7da22fe 100644 --- a/schoolschedule.php +++ b/schoolschedule.php @@ -175,10 +175,10 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ }else if($_GET['action'] == "getteamlist"){ // first we'll get the basic info, and do a quick check that the selected team is in this user's domain if(!array_key_exists('regId', $_POST)){ - echo "error code PEBKAC\n"; + echo "error\n"; return; } - $query = "SELECT sr.* FROM schedule_registrations sr"; + $query = "SELECT sr.*, so_teams.name as name FROM schedule_registrations sr"; $query .= " JOIN so_teams ON so_teams.id = sr.so_teams_id"; $query .= " WHERE sr.id=" . $_POST['regId']; $query .= " AND so_teams.schools_id = " . $_SESSION['schoolid']; @@ -189,6 +189,7 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ return; } $record = mysql_fetch_array($results); + $teamName = $record['name']; // get a list of all students that could be put on this team $query = 'SELECT * FROM users_student'; @@ -218,18 +219,24 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ } } - // get our minimum and maximum number of students for the event - $query = "SELECT sominteamsize, somaxteamsize FROM schedule JOIN" + // get the necessary data about the event itself + $query = "SELECT sominteamsize, somaxteamsize, title FROM schedule JOIN" . " schedule_registrations sr ON sr.schedule_id = schedule.id WHERE" . " sr.id = " . $_POST['regId']; $results = mysql_fetch_array(mysql_query($query)); $minTeamSize = $results['sominteamsize']; $maxTeamSize = $results['somaxteamsize']; - - + $eventName = $results['title']; + + // and let's put out the script to pass this data back to the browser echo '