diff --git a/functions.php b/functions.php
index 74c3f8d..7a8f238 100644
--- a/functions.php
+++ b/functions.php
@@ -1,9 +1,79 @@
- admin_url( 'admin-ajax.php' ), 'siteurl' => site_url() ) );
}
add_action( 'wp_enqueue_scripts', 'ece_scripts');
+function ece_get_courses( $discipline ){
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL,"http://web2.uconn.edu/ece/preadvising/pread_course.php");
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, 'discipline='.$discipline);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ $courses = curl_exec($ch);
+ curl_close ($ch);
+
+ return json_decode($courses);
+}
+
+function ajax_ece_discipline_courses(){
+ $discipline = $_POST['discipline'];
+
+ $courses = ece_get_courses( urlencode($discipline) );
+
+ echo wp_json_encode( $courses );
+ wp_die();
+}
+add_action( 'wp_ajax_ece_discipline_courses', 'ajax_ece_discipline_courses' );
+add_action('wp_ajax_nopriv_ece_discipline_courses', 'ajax_ece_discipline_courses');
+
+function ece_get_course_info( $discipline, $course ){
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL,"http://web2.uconn.edu/ece/preadvising/pread_course.php");
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, 'course='.$course.'&discipline='.$discipline);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ $courses = curl_exec($ch);
+ curl_close ($ch);
+
+ return json_decode($courses);
+}
+
+function ajax_ece_course_info(){
+ $discipline = $_POST['discipline'];
+ $course = $_POST['course'];
+
+ $courseInfo = ece_get_course_info( urlencode($discipline), urlencode($course) );
+
+ echo wp_json_encode( $courseInfo );
+ wp_die();
+}
+add_action( 'wp_ajax_ece_course_info', 'ajax_ece_course_info' );
+add_action('wp_ajax_nopriv_ece_course_info', 'ajax_ece_course_info');
+
+function ece_get_major_info( $major ){
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL,"http://web2.uconn.edu/ece/preadvising/pread_major.php");
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, 'major='.$major);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ $info = curl_exec($ch);
+ curl_close ($ch);
+
+ return json_decode($info);
+}
+
+function ajax_ece_major_info(){
+ $major = $_POST['major'];
+
+ $majorInfo = ece_get_major_info( urlencode($major) );
+
+ echo wp_json_encode( $majorInfo );
+ wp_die();
+}
+add_action( 'wp_ajax_ece_major_info', 'ajax_ece_major_info' );
+add_action('wp_ajax_nopriv_ece_major_info', 'ajax_ece_major_info');
?>
\ No newline at end of file
diff --git a/js/custom.js b/js/custom.js
index 8c8b4bb..6f29951 100644
--- a/js/custom.js
+++ b/js/custom.js
@@ -1,37 +1,137 @@
jQuery(document).ready(function($) {
-
+
$( ".social-vimeo > a" ).html( "DONATE" );
-
+
var search = '';
var active = false;
$('.search').on('click',function(e){
if($(e.target).attr('id')=='s') return;
active = true;
search = $(e.target).parent().html();
- $('.search').fadeOut(500,function(){
- $(this).html('
').fadeIn(500);
+ $('.search').fadeOut(500,function(){
+ $(this).html('').fadeIn(500);
$(this).addClass('search-field');
});
});
-
+
$('body').on('click',function(e){
if($(e.target).attr('id')=='s') return;
if($(e.target).parent().html()== search) return;
if(!active) return;
active = false;
- $('.search').fadeOut(500,function(){
- $(this).html(search).fadeIn(500);
+ $('.search').fadeOut(500,function(){
+ $(this).html(search).fadeIn(500);
$('.search').removeClass('search-field');
});
});
-
+
$( "#footers" ).before( "" );
-
-
-});
+ $('select[name="discipline"] option:eq(0)').prop("selected", true);
+ $('select[name="major"] option:eq(0)').prop("selected", true);
+
+ var isCourseSelectActive = false;
+ var selectedDiscipline;
+ $('select[name="discipline"]').change(function(e){
+ var discipline = $(this).find(":selected").text();
+ selectedDiscipline = discipline;
+ $.ajax({
+ type: "POST",
+ url: ece_object.ajaxurl,
+ data: {
+ action: "ece_discipline_courses",
+ discipline : discipline
+ },
+ success: function(response){
+ if( isCourseSelectActive == true ){
+ $('.course-option').remove();
+ }
+ $.each(response, function(i,v){
+ $('select[name="course"]').append(
+ $('', {
+ 'value': v,
+ 'text': v,
+ 'class': "course-option"
+ })
+ );
+ });
+ $('select[name="course"]').show();
+ isCourseSelectActive = true;
+ }, dataType: "json"
+ });
+ });
+
+ var isCourseInfoVisible = false;
+ $('select[name="course"]').change(function(e){
+ if( isCourseSelectActive == false || selectedDiscipline == undefined ){
+ return false;
+ }
+ var course = $(this).find(":selected").text();
+ $.ajax({
+ type: "POST",
+ url: ece_object.ajaxurl,
+ data: {
+ action: "ece_course_info",
+ discipline: selectedDiscipline,
+ course: course
+ },
+ success: function(response){
+ if( isCourseInfoVisible == true ){
+ $('#ece-course-learnmore').empty();
+ $('.major-requiredcourses').remove();
+ }
+
+ var courseInfo = response[0];
+ $('#ece-course-name').text(courseInfo.discipline + " " + courseInfo.course);
+ $('#ece-course-learnmore').html( $('#ece-course-learnmore').text() + ' '+courseInfo.url+'' );
+ $.each(courseInfo.majors, function(i,v){
+ $('#ece-course-required ul').append(
+ $('', {
+ 'text': v.major,
+ 'class': "major-requiredcourses"
+ })
+ );
+ });
+ $('#ece-course').show();
+ isCourseInfoVisible = true;
+ }, dataType: "json"
+ });
+ });
+
+ var isListVisible = false;
+ $('select[name="major"]').change(function(e){
+ var major = $(this).find(":selected").text();
+ $.ajax({
+ type: "POST",
+ url: ece_object.ajaxurl,
+ data: {
+ action: "ece_major_info",
+ major: major,
+ },
+ success: function(response){
+ if( isListVisible == true ){
+ $('.major-courses').remove();
+ }
+
+ var majorInfo = response[0];
+ $('#ece-major-name').text(majorInfo.major);
+ $('#ece-major-url').html(''+majorInfo.url+'');
+ $('ece-major-text').text("UConn ECE offers the following courses which lead to a major in "+majorInfo.major);
+ $.each(majorInfo.courses, function(i,v){
+ $('#ece-major-courses ul').append(
+ $('', {
+ 'text': v.discipline + " " + v.course,
+ 'class': "major-courses"
+ })
+ );
+ });
+ $('#ece-major').show();
+ isListVisible = true;
+ }, dataType: "json"
+ });
+ });
+});
+
+
-
-
-
\ No newline at end of file
diff --git a/preadvising-page.php b/preadvising-page.php
new file mode 100644
index 0000000..5ba37b1
--- /dev/null
+++ b/preadvising-page.php
@@ -0,0 +1,100 @@
+loadHTML($output);
+ $xpath = new DOMXPath($dom);
+ $majorOptions = $xpath->query('//select[@name="discipline"]/option');
+
+ $majors = array();
+ foreach( $majorOptions as $m ){
+ $majors[] = $m->getAttribute('value');
+ }
+
+ return $majors;
+}
+
+function getByMajor(){
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL,"http://web2.uconn.edu/ece/preadvising/pread_major.php");
+ curl_setopt($ch, CURLOPT_HTTPGET, true);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ $output = curl_exec($ch);
+ curl_close ($ch);
+
+ libxml_use_internal_errors(true);
+ $dom = new DOMDocument;
+ $dom->loadHTML($output);
+ $xpath = new DOMXPath($dom);
+ $majorOptions = $xpath->query('//select[@name="major"]/option');
+
+ $majors = array();
+ foreach( $majorOptions as $m ){
+ $majors[] = $m->getAttribute('value');
+ }
+
+ return $majors;
+}
+
+get_header();
+
+$majors = getByCourse();
+echo '';
+?>
+
+
+
+
+
+
Learn more about the department at:
+
+
This course is also a required course for the following majors:
+
+
+
+
+
+
+';
+foreach( $getByMajor as $k=>$m ){
+ if( empty($m) ){
+ $m = "Select a major";
+ }
+ echo '';
+}
+echo '';
+?>
+
+
+
+
+
To see if your schools offers these courses, see the Guidance Director at your high school.
+
+
\ No newline at end of file