-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/wip/composable'
- Loading branch information
Showing
5 changed files
with
118 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ref } from 'vue'; | ||
|
||
const baseCampusURL = "https://selfservice.campus-dual.de" | ||
const baseCorsUrl = "https://corsproxy.io/?" | ||
|
||
export function useCampus() { | ||
const username = useCookie("username"); | ||
const password = useCookie("password"); | ||
|
||
async function getCampusData(type: 'room' | 'timeline' | 'credits' | 'semester') { | ||
|
||
const UrlParams = `?userid=${username.value}&hash=${password.value}&t=${Math.floor(Date.now() / 1000)}&_=${Date.now()}` | ||
|
||
switch (type) { | ||
|
||
case 'room': | ||
var urlPath = "/room/json" | ||
break; | ||
case 'timeline': | ||
var urlPath = "/dash/gettimeline" | ||
break; | ||
case 'credits': | ||
var urlPath = "/dash/getcp" | ||
break; | ||
case 'semester': | ||
var urlPath = "/dash/getfs" | ||
break; | ||
|
||
default: | ||
throw new Error('Invalid type'); | ||
} | ||
|
||
const url = baseCorsUrl + encodeURIComponent(baseCampusURL + urlPath + UrlParams) | ||
|
||
return await $fetch(url); | ||
} | ||
|
||
return { | ||
username, | ||
password, | ||
getCampusData | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters