diff --git a/scripts/scheduleInput.js b/scripts/scheduleInput.js --- a/scripts/scheduleInput.js +++ b/scripts/scheduleInput.js @@ -1,10 +1,9 @@ - //-------------------------------------------------- // General Notes //-------------------------------------------------- - /* classNum is declared in the to enable loading of saved classes */ - /* sectionsOfClass is declared in the to enable loading of saved sections */ +var classNum = 0; +var sectionsOfClass = new Array(); //-------------------------------------------------- @@ -69,79 +68,103 @@ //-------------------------------------------------- // Returns the common inputs for each new section. //-------------------------------------------------- - function genSectionHtml(cnum){ - genSectionHtml(cnum,'','','','','',''); + function genSectionHtml(cnum) + { + genSectionHtml_n(cnum,'','','','','',''); } /* @TODO: This should select & set items based on args, if the args != '' */ - function genSectionHtml(cnum,name,synonym,stime,etime,days,prof) { + function genSectionHtml_n(cnum,name,synonym,stime,etime,days,prof) + { var snum = sectionsOfClass[cnum]; var result = ''; - result = result + ''; + result = result + ''; - result = result + '\ - \ - \ - \ - \ - \ - '; + result = result + '\ + \ + \ + \ + \ + \ + '; result = result + '
'; return result; } +/** + * Outputs an \n"; +} + //-------------------------------------------------- // Add a section to a class //-------------------------------------------------- - function add_section(cnum) { - jQuery('.pclass'+cnum).after(genSectionHtml(cnum)); + function add_section_n(cnum,name,synonym,stime,etime,days,prof) + { + jQuery('.pclass'+cnum).after(genSectionHtml_n(cnum,name,synonym,stime,etime,days,prof)); + sectionsOfClass[cnum] ++; + } + function add_section(cnum) + { + return add_section_n(cnum, '', '', '', '', {'m':false, 't':false, 'w':false, 'h':false, 'f':false}, ''); } - function add_section(cnum,name,synonym,stime,etime,days,prof) { - jQuery('.pclass'+cnum).after(genSectionHtml(cnum,name,synonym,stime,etime,days,prof)); - } //-------------------------------------------------- // Adds a new class to the input. //-------------------------------------------------- - function add_class(){ + function add_class_n(name) + { sectionsOfClass[classNum] = 0; // Initialize at 0 - jQuery('#jsrows').append('
'); + jQuery('#jsrows').append('
'); jQuery('.className' + classNum).autocomplete({ source: "auto.php" }); classNum++; + + return (classNum - 1); }; +function add_class() +{ + return add_class_n(''); +} //-------------------------------------------------- @@ -185,7 +208,6 @@ //-------------------------------------------------- jQuery('.addSection').live('click', function() { add_section(jQuery(this).parent().parent().attr("title"), sectionsOfClass[jQuery(this).parent().parent().attr("title")]); - sectionsOfClass[jQuery(this).parent().parent().attr("title")]++; // Increases sectionsOfClass[classNum] }); //-------------------------------------------------- @@ -217,10 +239,4 @@ jQuery('#showadvanced').hide(); jQuery('.advanced').slideToggle(); }); - - //-------------------------------------------------- - // Add initial class - //-------------------------------------------------- - add_class(); - });