-
Notifications
You must be signed in to change notification settings - Fork 0
/
allInfo.html
74 lines (54 loc) · 2.43 KB
/
allInfo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html>
<head>
<style>
body
{
white-space: pre;
}
</style>
<body>
Paste the results from visiting <a href="https://buffportal.colorado.edu/usews/api/v1/schedule/v2/term/2191/from/2019-04-24/days/7">https://buffportal.colorado.edu/usews/api/v1/schedule/v2/term/2191/from/2019-04-24/days/7</a> and this site will further query classes.colorado.edu to collect all information for a given course. This information will be presented below:
<script>
var courseDetailsComplete = {};
document.body.onpaste = function( e ) // thanks https://stackoverflow.com/a/6804718
{
e.stopPropagation();
e.preventDefault();
var pasteText = ( e.clipboardData || window.clipboardData ).getData( "text" );
withBuffportalData( JSON.parse( pasteText ) );
// console.log( JSON.parse( pasteText ) )
}
function withBuffportalData( jsonData )
{
for( var date of jsonData.data )
for( course of [ ...date.courses, ...date.online ] )
{
var courseName = course.courseSubject.toLowerCase() + course.courseNumber + "-" + course.courseSection;
if( !( courseName in courseDetailsComplete ) ) courseDetailsComplete[ courseName ] = {};
courseDetailsComplete[ courseName ] = { ...courseDetailsComplete[ course ], ...course };
}
// console.log( courseDetailsComplete );
collectClassescoloradoData();
}
async function collectClassescoloradoData()
{
for( course of Object.keys( courseDetailsComplete ) )
{
var classesResponse = JSON.parse( await ( await fetch( "https://cors-anywhere.herokuapp.com/https://classes.colorado.edu/api/?page=fose&route=details", {"body":`{"group":"code:${courseDetailsComplete[course].courseSubject + " " + courseDetailsComplete[course].courseNumber}","key":"","srcdb":"2191","matched":""}`,"method":"POST"} ) ).text() );
var fullClassesResponse = {};
for( var section of classesResponse.allInGroup )
if( section.no == courseDetailsComplete[ course ].courseSection )
{
fullClassesResponse = JSON.parse( await ( await fetch( "https://cors-anywhere.herokuapp.com/https://classes.colorado.edu/api/?page=fose&route=details", {"body":`{"group":"crn:${section.crn}","key":"crn:${section.crn}","srcdb":"2191","matched":""}`,"method":"POST"} ) ).text() );
break;
}
// console.log( fullClassesResponse );
courseDetailsComplete[ course ] = { ...courseDetailsComplete[ course ], ...fullClassesResponse };
}
presentData();
}
function presentData()
{
document.body.innerText += JSON.stringify( courseDetailsComplete, null, 4 );
}
</script>