commit 65359b7b9c5449e24bb44a655c14373afeafada0
parent e176c7361765e6e60b38652b875c2da3e860ab87
Author: Marcel <MTRNord@users.noreply.github.com>
Date: Fri, 2 Sep 2016 13:42:19 +0200
Merge pull request #4 from MTRNord/develop
Update API and .codeclimate.yml
Diffstat:
5 files changed, 87 insertions(+), 70 deletions(-)
diff --git a/.codeclimate.yml b/.codeclimate.yml
@@ -12,7 +12,8 @@ engines:
fixme:
enabled: true
ratings:
- paths: []
-exclude_paths:
+ paths:
+ - app/**
+exclude_paths:
- "app/js/**"
- "app/css/**"
diff --git a/README.md b/README.md
@@ -1,12 +1,12 @@
# ls-vertretungsplan-desktop
UNOFFICIAL Desktop App for the schedule of Lornsenschule, Schleswig
-# NOT WORKING FOR YOU YET!!!!!!
-This Desktop App uses an API by @johan12345 that is NOT managed by me! I don't have the right to use it here so I don't provide the link to it or an compiled version of it.
+# Info about the API
+This Desktop App uses an API by @johan12345 that is NOT managed by me. I am allowed to use it and to have it in the Git Source. To see the APP made by @johan12345 take a look at https://ls.vertretungsplan.me
# How to Build (If you find the URL to the API ^^)
1. Clone the Repository
2. Run `npm install`
3. If You use Windows run `build.cmd` otherwise go to 4
-4. Everybody else go into the app directory and run `npm install` and now run `node build.js` in the root
-\ No newline at end of file
+4. Everybody else go into the app directory and run `npm install` and now run `node build.js` in the root
diff --git a/app/index.html b/app/index.html
@@ -11,38 +11,52 @@
<title>Lornsenschule Vertretungsplan</title>
</head>
<body>
- <div class="bmd-layout-container">
+ <div class="bmd-layout-container" id="Main">
<main class="bmd-layout-content">
- <div class="container" id="representations">
+ <div class="container">
<h1 id="school"></h1></br>
+ <ul class="nav nav-tabs" id="Tabs">
+ <li class="active"><a data-target="#vertretungen" data-toggle="tab">Profile</a></li>
+ <li><a data-target="#messages" data-toggle="tab">Messages</a></li>
+ </ul>
+
+ <div class="tab-content">
+ <div class="tab-pane active" id="vertretungen"></div>
+ <div class="tab-pane" id="messages"></div>
+ </div>
+
</div>
</main>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script>
+ /*
+ Refresh Button Snippets:
+ var remote = require('electron').remote
+ remote.getCurrentWindow().reload()
+ */
window.$ = window.jQuery = require('./js/jquery-3.1.0.min.js');
- var request = require("request")
- //<!-- http://THIS_IS_AN_SECRET_DOMAIN -->
- var url = "http://THIS_IS_AN_SECRET_DOMAIN/vertretungsplan?" +
- "school=Schleswig_Lornsenschule" +
- "&v=1337"
+ var request = require('request')
+ , cachedRequest = require('cached-request')(request)
+ , cacheDirectory = "cache";
+ var url = "https://api.vertretungsplan.me/" +
+ "v2/" +
+ "substitutionschedules/" +
+ "Schleswig_Lornsenschule/" +
+ "schulervertretungsplan" +
+ "?client=desktop_marcel"
- if (typeof jQuery == 'undefined') {
- console.warn("JQUERY NOT LOADED!!!");
- }
-
- request({
+ cachedRequest({
url: url,
- json: true
+ json: true,
+ ttl: 1800000
}, function (error, response, body) {
-
if (!error && response.statusCode === 200) {
- //var lsJson = JSON.parse(body);
- document.all.school.innerHTML = body.schoolName + ' Vertretungsplan'; // Print the json response
- for (var key in body.tage) {
- if (body.tage.hasOwnProperty(key)) {
+ document.all.school.innerHTML = body.schoolId.replace(/_/g, ' ') + ' Vertretungsplan'; // Print the json response
+ for (var key in body.days) {
+ if (body.days.hasOwnProperty(key)) {
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// //
@@ -51,49 +65,50 @@
// //
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
- if (key == 1) {
- classes = body.tage[key].klassen
- for (var key in classes) {
- if (classes.hasOwnProperty(key)) {
- klassen = classes[key]
- klasse = klassen.klasse
- $("#representations").append('<h3>' + klasse + '</h3>')
- representations = classes[key].vertretung
- for (var key in representations) {
- if (representations.hasOwnProperty(key)) {
- representations_details = representations[key]
- var reg = new RegExp('[-]');
- lesson = representations_details.lesson
- representation_type = representations_details.type
- text = representations_details.text
- if (representation_type == "Vertretung") {
+ if (key == 0) {
+ date = body.days[key].dateString
+ substitutions = body.days[key].substitutions
+ substitutions.sort(function(a, b){
+ if (a.classes < b.classes) return -1;
+ if (b.classes < a.classes) return 1;
+ return 0;
+ })
+ for (var key in substitutions) {
+ if (substitutions.hasOwnProperty(key)) {
+ klasse = substitutions[key].classes
+ if ($("#klasse").attr("klasse") != klasse) {
+ $("#vertretungen").append('<h3 id="klasse" klasse="' + klasse + '">' + klasse + '</h3>')
+ }
+ var reg = new RegExp('[-]');
+ lesson = substitutions[key].lesson
+ substitutions_type = substitutions[key].type
+ text = substitutions[key].text
+ if (substitutions_type == "Vertretung") {
+ if (lesson.match(reg)) {
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
+ }else{
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
+ }
+ }else{
+ if (substitutions_type == "Betreuung") {
+ if (lesson.match(reg)) {
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
+ }else{
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
+ }
+ }else{
+ if (substitutions_type == "Unterricht geändert") {
if (lesson.match(reg)) {
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #FFA000; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
}else{
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #FFA000; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
}
}else{
- if (representation_type == "Betreuung") {
+ if (substitutions_type == "Lehrertausch") {
if (lesson.match(reg)) {
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
- }else{
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #2196F3; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
- }
- }else{
- if (representation_type == "Unterricht geändert") {
- if (lesson.match(reg)) {
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #FFA000; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
- }else{
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #FFA000; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
- }
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #9C27B0; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
}else{
- if (representation_type == "Lehrertausch") {
- if (lesson.match(reg)) {
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #9C27B0; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 300%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
- }else{
- $("#representations").append('<div class="card card-block" style="height: 10%; background-color: #9C27B0; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + representation_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
- }
- }
+ $("#vertretungen").append('<div class="card card-block" style="height: 10%; background-color: #9C27B0; color: #fff">' + '<div class="row">' + '<div class="col-md-4" style="position: relative; margin: 0;"><p style="font-size: 350%; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">' + lesson + '</p></div>' + '<div class="col-md-8"><h4>' + substitutions_type + '</h4></br><h7>' + text + '</h7></div>' + '</div>' + '</div>')
}
}
}
@@ -103,11 +118,13 @@
}
}
}
- }
+ }
}else{
- $("#representations").append('<p class="bg-danger">Scheinbar gehtdein Internet nicht :/</p>')
+ $("#Main").append('<p class="bg-danger">Scheinbar geht dein Internet nicht :/</p>')
}
})
+
+ $('#Tabs a:last').tab('show')
</script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap/bootstrap.min.js"></script>
diff --git a/app/main.js b/app/main.js
@@ -7,9 +7,9 @@ let win
function update () {
var feedUrl = 'https://ls-desktop.herokuapp.com/update/win32/:' + app.getVersion();
autoUpdater.setFeedURL(feedUrl);
-
+
autoUpdater.on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) {
-
+
var index = dialog.showMessageBox(mainWindow, {
type: 'info',
buttons: [i18n.__('Restart'), i18n.__('Later')],
@@ -17,11 +17,11 @@ function update () {
message: i18n.__('The new version has been downloaded. Please restart the application to apply the updates.'),
detail: releaseName + "\n\n" + releaseNotes
});
-
+
if (index === 1) {
return;
}
-
+
quitAndUpdate();
});
}
@@ -69,4 +69,4 @@ app.on('activate', () => {
})
// In this file you can include the rest of your app's specific main process
-// code. You can also put them in separate files and require them here.
-\ No newline at end of file
+// code. You can also put them in separate files and require them here.
diff --git a/app/package.json b/app/package.json
@@ -1,11 +1,12 @@
{
"name": "ls_vertretungsplan_desktop",
- "version": "0.0.2",
+ "version": "0.0.3",
"description": "Eine Anwendung die den Vertretungsplan auf dem Desktop anzeigt",
"main": "./main.js",
"author": "Marcel Radzio <info@nordgedanken.de>",
"license": "",
"dependencies": {
+ "cached-request": "^1.0.0",
"request": "^2.69.0"
}
}