-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoursesLib.min.js
12 lines (9 loc) · 3.47 KB
/
CoursesLib.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*
,-----. ,--. ,--.,--.
' .--./ ,---. ,--.,--.,--.--. ,---. ,---. ,---. | | `--'| |-.
| | | .-. || || || .--'( .-' | .-. :( .-' | | ,--.| .-. '
' '--'\' '-' '' '' '| | .-' `)\ --..-' `)| '--.| || `-' |
`-----' `---' `----' `--' `----' `----'`----' `-----'`--' `---'
© 2016 CoursesPlus Development Team
*/
window.coursesLib={},window.coursesLib.baseUrl="https://courses2016.dalton.org",window.coursesLib.checkLoggedIn=function(e){$.get(window.coursesLib.baseUrl+"/login/index.php",function(i){var r=$(i),n={};n.isLoggedIn=0==r.find(".loginform").length,e(n)})},window.coursesLib.getCourseEvents=function(e,i){$.get(window.coursesLib.baseUrl+"/course/view.php?id="+e,function(r){var n=$(r),t={};t.id=e,t.title=n.children("#page-content").children("#region-main-box").children("#region-post-box").children("#region-main-wrap").children("#region-main").children("#region-main-box").children(".region-content").children(".course-content").text(),i(t)})},window.coursesLib.getCourseInfo=function(e,i){$.get(window.coursesLib.baseUrl+"/course/view.php?id="+e,function(r){var n=$(r),t={};t.id=e,t.title=n.children("#page-header").children(".headermain").text(),i(t)})},window.coursesLib.getCourseList=function(e){$.get(window.coursesLib.baseUrl+"/index.php?redirect=0",function(i){var r=$(i),n={};n.classes=[],r.find(".coursename > a").each(function(){n.classes.push({courseId:parseInt($(this).attr("href").replace(window.coursesLib.baseUrl+"/course/view.php?id=","")),name:$(this).text(),url:$(this).attr("href")})}),e(n)})},window.coursesLib.getUpcomingCourseEvents=function(e,i){$.get(window.coursesLib.baseUrl+"/calendar/view.php?course="+e,function(r){var n=$(r),t={};t.id=e,t.events=[],n.find(".eventlist").children(".event").each(function(){var e=$(this).children(".referer").children("a").text().replace(/\s{2,}/g," ");0==$(this).children(".referer").length&&(e=$(this).children(".name").text().replace(/\s{2,}/g," "));var i=$(this).children(".course").children("a").text().replace(/\s{2,}/g," "),r=$(this).children(".description").html(),n=$(this).children(".description").text(),s=n.replace(/\r/g,"").replace(/\n/g," "),c=$(this).children(".referer").children("a").attr("href"),o={title:e,course:i,text:n,normText:s,html:r,link:c};t.events.push(o)}),i(t)})},window.coursesLib.getUpcomingEvents=function(e){$.get(window.coursesLib.baseUrl+"/calendar/view.php",function(i){var r=$(i),n={};n.events=[],r.find(".eventlist").children(".event").each(function(){var e=$(this).children(".referer").children("a").text().replace(/\s{2,}/g," ");0==$(this).children(".referer").length&&(e=$(this).children(".name").text().replace(/\s{2,}/g," "));var i=$(this).children(".course").children("a").text().replace(/\s{2,}/g," "),r=$(this).children(".description").html(),t=$(this).children(".description").text(),s=t.replace(/\r/g,"").replace(/\n/g," "),c=$(this).children(".referer").children("a").attr("href"),o={title:e,course:i,text:t,normText:s,html:r,link:c};n.events.push(o)}),e(n)})},window.coursesLib.getProfile=function(e){$.get(window.coursesLib.baseUrl+"/user/profile.php",function(i){var r=$(i),n={};n.fullName=r.find(".userprofile").children("h2").text(),n.firstName=n.fullName.split(" ")[0],n.lastName=n.fullName.split(" ")[1],n.avatarUrl=r.find(".userpicture").attr("src"),e(n)})},console.log("CoursesLib ready!");