7.diff (22441B)
1 diff --git a/.gitignore b/.gitignore 2 index c6a79c6..a199a30 100644 3 --- a/.gitignore 4 +++ b/.gitignore 5 @@ -25,6 +25,7 @@ build/Release 6 build 7 prebuild 8 cache 9 +dist 10 11 # Dependency directory 12 node_modules 13 @@ -33,5 +34,4 @@ node_modules 14 .npm 15 16 # Optional REPL history 17 -.node_repl_history 18 -LS.ico 19 \ No newline at end of file 20 +.node_repl_history 21 \ No newline at end of file 22 diff --git a/app/.gitignore b/app/.gitignore 23 index e19b3a4..d75a403 100644 24 --- a/app/.gitignore 25 +++ b/app/.gitignore 26 @@ -32,5 +32,4 @@ node_modules 27 .npm 28 29 # Optional REPL history 30 -.node_repl_history 31 -LS.ico 32 \ No newline at end of file 33 +.node_repl_history 34 \ No newline at end of file 35 diff --git a/app/LS.ico b/app/LS.ico 36 new file mode 100644 37 index 0000000..ed8414e 38 Binary files /dev/null and b/app/LS.ico differ 39 diff --git a/app/index.html b/app/index.html 40 index 0ea679c..e5c5059 100644 41 --- a/app/index.html 42 +++ b/app/index.html 43 @@ -7,6 +7,7 @@ 44 <!-- Material Design fonts --> 45 <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700"> 46 <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons"> 47 + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/css/bootstrap.min.css" integrity="sha384-MIwDKRSSImVFAZCVLtU0LMDdON6KVCrZHyVQQj6e8wIEJkW4tvwqXrbMIya1vriY" crossorigin="anonymous"> 48 <link rel="stylesheet" href="https://cdn.rawgit.com/FezVrasta/bootstrap-material-design/dist/dist/bootstrap-material-design.min.css"> 49 <title>Lornsenschule Vertretungsplan</title> 50 </head> 51 @@ -17,13 +18,13 @@ 52 <h1 id="school"></h1></br> 53 54 <ul class="nav nav-tabs" id="Tabs"> 55 - <li class="active"><a data-target="#vertretungen" data-toggle="tab">Profile</a></li> 56 - <li><a data-target="#messages" data-toggle="tab">Messages</a></li> 57 + <li class="nav-item"><a class="nav-link active" data-target="#vertretungen" data-toggle="tab">Vertretungen</a></li> 58 + <li class="nav-item"><a class="nav-link" data-target="#messages" data-toggle="tab">Messages</a></li> 59 </ul> 60 61 <div class="tab-content"> 62 - <div class="tab-pane active" id="vertretungen"></div> 63 - <div class="tab-pane" id="messages"></div> 64 + <div class="tab-pane fade in active" id="vertretungen"></div> 65 + <div class="tab-pane fade" id="messages"></div> 66 </div> 67 68 </div> 69 @@ -32,11 +33,10 @@ <h1 id="school"></h1></br> 70 71 <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 72 <script> 73 - /* 74 - Refresh Button Snippets: 75 - var remote = require('electron').remote 76 - remote.getCurrentWindow().reload() 77 - */ 78 + function reloadPage() { 79 + var remote = require('electron').remote 80 + remote.getCurrentWindow().reload() 81 + } 82 window.$ = window.jQuery = require('./js/jquery-3.1.0.min.js'); 83 var request = require('request') 84 , cachedRequest = require('cached-request')(request) 85 @@ -53,7 +53,9 @@ <h1 id="school"></h1></br> 86 json: true, 87 ttl: 1800000 88 }, function (error, response, body) { 89 + console.log("Response Code: " + response.statusCode) 90 if (!error && response.statusCode === 200) { 91 + console.log("Parsing") 92 document.all.school.innerHTML = body.schoolId.replace(/_/g, ' ') + ' Vertretungsplan'; // Print the json response 93 for (var key in body.days) { 94 if (body.days.hasOwnProperty(key)) { 95 @@ -65,50 +67,73 @@ <h1 id="school"></h1></br> 96 // // 97 ////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////// 99 - if (key == 0) { 100 + if (key == 1) { 101 date = body.days[key].dateString 102 substitutions = body.days[key].substitutions 103 - substitutions.sort(function(a, b){ 104 - if (a.classes < b.classes) return -1; 105 - if (b.classes < a.classes) return 1; 106 - return 0; 107 - }) 108 + messages = body.days[key].messages 109 + console.log("Day found") 110 + for (var key in messages) { 111 + if (messages.hasOwnProperty(key)) { 112 + $("#messages").append('<div class="card card-block" style="height: 10%; background-color: #EEEEEE; color: #000"><p>' + messages[key].replace(/\n/g, ' ') + '</p></div>') 113 + } 114 + } 115 for (var key in substitutions) { 116 if (substitutions.hasOwnProperty(key)) { 117 - klasse = substitutions[key].classes 118 - if ($("#klasse").attr("klasse") != klasse) { 119 - $("#vertretungen").append('<h3 id="klasse" klasse="' + klasse + '">' + klasse + '</h3>') 120 - } 121 - var reg = new RegExp('[-]'); 122 - lesson = substitutions[key].lesson 123 - substitutions_type = substitutions[key].type 124 - text = substitutions[key].text 125 - if (substitutions_type == "Vertretung") { 126 - if (lesson.match(reg)) { 127 - $("#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>') 128 - }else{ 129 - $("#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>') 130 - } 131 - }else{ 132 - if (substitutions_type == "Betreuung") { 133 - if (lesson.match(reg)) { 134 - $("#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>') 135 - }else{ 136 - $("#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>') 137 - } 138 - }else{ 139 - if (substitutions_type == "Unterricht geändert") { 140 - if (lesson.match(reg)) { 141 - $("#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>') 142 + console.log("Substitutions found") 143 + substitutions_now = substitutions[key] 144 + klassen = substitutions_now.classes 145 + for (var key in klassen) { 146 + if (klassen.hasOwnProperty(key)) { 147 + console.log("Class found") 148 + klasse = klassen[key] 149 + console.log(klasse) 150 + console.log($("h3").filter("[klasse='" + klasse + "']", "#klasse").length) 151 + if ($("h3").filter("[klasse='" + klasse + "']", "#klasse").length == 0) { 152 + console.log("Found new Class") 153 + $("#vertretungen").append('<div id="klasse" klasse="' + klasse + '"><h3 id="klasse" klasse="' + klasse + '">' + klasse + '</h3>') 154 + }else{} 155 + var reg = new RegExp('[-]'); 156 + lesson = substitutions_now.lesson 157 + substitutions_type = substitutions_now.type 158 + text = substitutions_now.text 159 + console.log("Appending") 160 + console.log("Multiple Subjects: " + reg.test(lesson)) 161 + if (substitutions_type == "Vertretung") { 162 + if (reg.test(lesson)) { 163 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 164 }else{ 165 - $("#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>') 166 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 167 } 168 }else{ 169 - if (substitutions_type == "Lehrertausch") { 170 - if (lesson.match(reg)) { 171 - $("#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>') 172 + if (substitutions_type == "Betreuung") { 173 + if (reg.test(lesson)) { 174 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 175 }else{ 176 - $("#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>') 177 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 178 + } 179 + }else{ 180 + if (substitutions_type == "Unterricht geändert") { 181 + if (reg.test(lesson)) { 182 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 183 + }else{ 184 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 185 + } 186 + }else{ 187 + if (substitutions_type == "Lehrertausch") { 188 + if (reg.test(lesson)) { 189 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 190 + }else{ 191 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 192 + } 193 + }else{ 194 + if (substitutions_type == "anderer Raum") { 195 + if (reg.test(lesson)) { 196 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 197 + }else{ 198 + $("h3").filter("[klasse='" + klasse + "']", "#klasse").after('<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>') 199 + } 200 + } 201 + } 202 } 203 } 204 } 205 @@ -119,16 +144,25 @@ <h1 id="school"></h1></br> 206 } 207 } 208 } 209 + $.fn.sortDivs = jQuery.fn.sortDivs = function sortDivs() { 210 + $("> div", this[0]).sort(dec_sort).appendTo(this[0]); 211 + function dec_sort(a, b){ return ($(b).attr("klasse")) < ($(a).attr("klasse")) ? 1 : -1; } 212 + } 213 + $('#vertretungen').sortDivs(); 214 }else{ 215 + console.log(error) 216 $("#Main").append('<p class="bg-danger">Scheinbar geht dein Internet nicht :/</p>') 217 } 218 }) 219 220 - $('#Tabs a:last').tab('show') 221 + $('#Tabs a').click(function (e) { 222 + e.preventDefault() 223 + $(this).tab('show') 224 + }) 225 </script> 226 <!-- Include all compiled plugins (below), or include individual files as needed --> 227 - <script src="js/bootstrap/bootstrap.min.js"></script> 228 - <script src="https://cdn.rawgit.com/HubSpot/tether/v1.3.4/dist/js/tether.min.js"></script> 229 + <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js" integrity="sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB" crossorigin="anonymous"></script> 230 + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/js/bootstrap.min.js" integrity="sha384-ux8v3A6CPtOTqOzMKiuo3d/DomGaaClxFYdCu2HPMBEkf6x2xiDyJ7gkXU0MWwaD" crossorigin="anonymous"></script> 231 <script src="https://cdn.rawgit.com/FezVrasta/bootstrap-material-design/dist/dist/bootstrap-material-design.iife.min.js"></script> 232 <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> 233 <script src="https://maxcdn.bootstrapcdn.com/js/ie10-viewport-bug-workaround.js"></script> 234 diff --git a/app/main.js b/app/main.js 235 index c514a0a..79c3fd2 100644 236 --- a/app/main.js 237 +++ b/app/main.js 238 @@ -28,7 +28,7 @@ function update () { 239 240 function createWindow () { 241 // Create the browser window. 242 - win = new BrowserWindow({width: 800, height: 600}) 243 + win = new BrowserWindow({width: 800, height: 600, icon: __dirname + '/LS.ico', title: 'Lornsenschule Vertretungsplan'}) 244 245 // and load the index.html of the app. 246 win.loadURL(`file://${__dirname}/index.html`) 247 diff --git a/app/package.json b/app/package.json 248 index ac09df0..cfbdf88 100644 249 --- a/app/package.json 250 +++ b/app/package.json 251 @@ -1,5 +1,6 @@ 252 { 253 "name": "ls_vertretungsplan_desktop", 254 + "productName": "Lornsenschule Vertretungsplan", 255 "version": "0.0.3", 256 "description": "Eine Anwendung die den Vertretungsplan auf dem Desktop anzeigt", 257 "main": "./main.js", 258 @@ -8,5 +9,6 @@ 259 "dependencies": { 260 "cached-request": "^1.0.0", 261 "request": "^2.69.0" 262 - } 263 + }, 264 + "homepage": "https://github.com/MTRNord/ls-vertretungsplan-desktop" 265 } 266 diff --git a/build.cmd b/build.cmd 267 deleted file mode 100644 268 index 280a236..0000000 269 --- a/build.cmd 270 +++ /dev/null 271 @@ -1,2 +0,0 @@ 272 -electron-packager app --all --out prebuild/ 273 -node build.js 274 \ No newline at end of file 275 diff --git a/build.js b/build.js 276 deleted file mode 100644 277 index e459fad..0000000 278 --- a/build.js 279 +++ /dev/null 280 @@ -1,9 +0,0 @@ 281 -var electronInstaller = require('electron-winstaller'); 282 -resultPromise = electronInstaller.createWindowsInstaller({ 283 - appDirectory: 'prebuild/ls_vertretungsplan_desktop-win32-x64', 284 - outputDirectory: 'build', 285 - authors: 'Marcel Radzio', 286 - exe: 'ls_vertretungsplan_desktop.exe' 287 - }); 288 - 289 -resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice: ${e.message}`)); 290 \ No newline at end of file 291 diff --git a/package.json b/package.json 292 index d3646a0..2d5249c 100644 293 --- a/package.json 294 +++ b/package.json 295 @@ -1,11 +1,48 @@ 296 { 297 "name": "ls_vertretungsplan_desktop", 298 - "version": "0.0.2", 299 + "version": "0.0.3", 300 "description": "Eine Anwendung die den Vertretungsplan auf dem Desktop anzeigt", 301 "author": "Marcel Radzio <info@nordgedanken.de>", 302 "license": "", 303 "devDependencies": { 304 "electron": "^1.3.4", 305 - "electron-winstaller": "^2.3.4" 306 + "electron-builder": "^6.4.0" 307 + }, 308 + "scripts": { 309 + "pack": "build --dir", 310 + "dist": "build", 311 + "release": "build" 312 + }, 313 + "build": { 314 + "asar": true, 315 + "appId": "de.nordgedanken.ls_vertretungsplan_desktop", 316 + "category": "public.app-category.education", 317 + "dmg": { 318 + "contents": [ 319 + { 320 + "x": 410, 321 + "y": 150, 322 + "type": "link", 323 + "path": "/Applications" 324 + }, 325 + { 326 + "x": 130, 327 + "y": 150, 328 + "type": "file" 329 + } 330 + ] 331 + }, 332 + "win": { 333 + "iconUrl": "https://github.com/MTRNord/ls-vertretungsplan-desktop/tree/master/app/LS.ico?raw=true", 334 + "remoteReleases": "https://github.com/MTRNord/ls-vertretungsplan-desktop" 335 + }, 336 + "linux": { 337 + "target": [ 338 + "deb", 339 + "AppImage", 340 + "zip", 341 + "rpm" 342 + ] 343 + } 344 } 345 }