ls-vertretungsplan-desktop.meta

Issues/PRs archive for MTRNord/ls-vertretungsplan-desktop
git clone git://archive.git.mtrnord.blog/MTRNord/ls-vertretungsplan-desktop.meta.git
Log | Files | Refs

4.diff (17930B)


      1 diff --git a/.codeclimate.yml b/.codeclimate.yml
      2 index 049d01f..0ae2e96 100644
      3 --- a/.codeclimate.yml
      4 +++ b/.codeclimate.yml
      5 @@ -12,7 +12,8 @@ engines:
      6    fixme:
      7      enabled: true
      8  ratings:
      9 -  paths: []
     10 -exclude_paths: 
     11 +  paths:
     12 +  - app/**
     13 +exclude_paths:
     14  - "app/js/**"
     15  - "app/css/**"
     16 diff --git a/README.md b/README.md
     17 index 2442dc1..f817f28 100644
     18 --- a/README.md
     19 +++ b/README.md
     20 @@ -1,12 +1,12 @@
     21  # ls-vertretungsplan-desktop
     22  UNOFFICIAL Desktop App for the schedule of Lornsenschule, Schleswig
     23  
     24 -# NOT WORKING FOR YOU YET!!!!!!
     25 -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.
     26 +# Info about the API
     27 +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
     28  
     29  # How to Build (If you find the URL to the API ^^)
     30  
     31  1. Clone the Repository
     32  2. Run `npm install`
     33  3. If You use Windows run `build.cmd` otherwise go to 4
     34 -4. Everybody else go into the app directory and run `npm install` and now run `node build.js` in the root
     35 \ No newline at end of file
     36 +4. Everybody else go into the app directory and run `npm install` and now run `node build.js` in the root
     37 diff --git a/app/index.html b/app/index.html
     38 index 31739b7..0ea679c 100644
     39 --- a/app/index.html
     40 +++ b/app/index.html
     41 @@ -11,38 +11,52 @@
     42      <title>Lornsenschule Vertretungsplan</title>
     43    </head>
     44    <body>
     45 -    <div class="bmd-layout-container">
     46 +    <div class="bmd-layout-container" id="Main">
     47        <main class="bmd-layout-content">
     48 -        <div class="container" id="representations">
     49 +        <div class="container">
     50            <h1 id="school"></h1></br>
     51  
     52 +          <ul class="nav nav-tabs" id="Tabs">
     53 +            <li class="active"><a data-target="#vertretungen" data-toggle="tab">Profile</a></li>
     54 +            <li><a data-target="#messages" data-toggle="tab">Messages</a></li>
     55 +          </ul>
     56 +
     57 +          <div class="tab-content">
     58 +            <div class="tab-pane active" id="vertretungen"></div>
     59 +            <div class="tab-pane" id="messages"></div>
     60 +          </div>
     61 +
     62          </div>
     63        </main>
     64       </div>
     65  
     66      <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
     67      <script>
     68 +      /*
     69 +      Refresh Button Snippets:
     70 +      var remote = require('electron').remote
     71 +      remote.getCurrentWindow().reload()
     72 +      */
     73        window.$ = window.jQuery = require('./js/jquery-3.1.0.min.js');
     74 -      var request = require("request")
     75 -      //<!-- http://THIS_IS_AN_SECRET_DOMAIN -->
     76 -      var url = "http://THIS_IS_AN_SECRET_DOMAIN/vertretungsplan?" +
     77 -        "school=Schleswig_Lornsenschule" +
     78 -        "&v=1337"
     79 +      var request = require('request')
     80 +      ,   cachedRequest = require('cached-request')(request)
     81 +      ,   cacheDirectory = "cache";
     82 +      var url = "https://api.vertretungsplan.me/" +
     83 +        "v2/" +
     84 +        "substitutionschedules/" +
     85 +        "Schleswig_Lornsenschule/" +
     86 +        "schulervertretungsplan" +
     87 +        "?client=desktop_marcel"
     88  
     89 -      if (typeof jQuery == 'undefined') {  
     90 -        console.warn("JQUERY NOT LOADED!!!");
     91 -      }
     92 -
     93 -      request({
     94 +      cachedRequest({
     95          url: url,
     96 -        json: true
     97 +        json: true,
     98 +        ttl: 1800000
     99        }, function (error, response, body) {
    100 -
    101          if (!error && response.statusCode === 200) {
    102 -          //var lsJson = JSON.parse(body);
    103 -          document.all.school.innerHTML = body.schoolName + ' Vertretungsplan'; // Print the json response
    104 -          for (var key in body.tage) {
    105 -            if (body.tage.hasOwnProperty(key)) {
    106 +          document.all.school.innerHTML = body.schoolId.replace(/_/g, ' ') + ' Vertretungsplan'; // Print the json response
    107 +          for (var key in body.days) {
    108 +            if (body.days.hasOwnProperty(key)) {
    109                //////////////////////////////////////////////////////////////
    110                //////////////////////////////////////////////////////////////
    111                //                                                          //
    112 @@ -51,49 +65,50 @@ <h1 id="school"></h1></br>
    113                //                                                          //
    114                //////////////////////////////////////////////////////////////
    115                //////////////////////////////////////////////////////////////
    116 -              if (key == 1) {
    117 -                classes = body.tage[key].klassen
    118 -                for (var key in classes) {
    119 -                  if (classes.hasOwnProperty(key)) {
    120 -                    klassen = classes[key]
    121 -                    klasse = klassen.klasse
    122 -                    $("#representations").append('<h3>' + klasse + '</h3>')
    123 -                    representations = classes[key].vertretung
    124 -                    for (var key in representations) {
    125 -                      if (representations.hasOwnProperty(key)) {
    126 -                        representations_details = representations[key]
    127 -                        var reg = new RegExp('[-]');
    128 -                        lesson = representations_details.lesson
    129 -                        representation_type = representations_details.type
    130 -                        text = representations_details.text
    131 -                        if (representation_type == "Vertretung") {
    132 +              if (key == 0) {
    133 +                date = body.days[key].dateString
    134 +                substitutions = body.days[key].substitutions
    135 +                substitutions.sort(function(a, b){
    136 +                  if (a.classes < b.classes) return -1;
    137 +                  if (b.classes < a.classes) return 1;
    138 +                  return 0;
    139 +                })
    140 +                for (var key in substitutions) {
    141 +                  if (substitutions.hasOwnProperty(key)) {
    142 +                    klasse = substitutions[key].classes
    143 +                    if ($("#klasse").attr("klasse") != klasse) {
    144 +                      $("#vertretungen").append('<h3 id="klasse" klasse="' + klasse + '">' + klasse + '</h3>')
    145 +                    }
    146 +                    var reg = new RegExp('[-]');
    147 +                    lesson = substitutions[key].lesson
    148 +                    substitutions_type = substitutions[key].type
    149 +                    text = substitutions[key].text
    150 +                    if (substitutions_type == "Vertretung") {
    151 +                      if (lesson.match(reg)) {
    152 +                        $("#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>')
    153 +                      }else{
    154 +                        $("#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>')
    155 +                      }
    156 +                    }else{
    157 +                      if (substitutions_type == "Betreuung") {
    158 +                        if (lesson.match(reg)) {
    159 +                          $("#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>')
    160 +                        }else{
    161 +                          $("#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>')
    162 +                        }
    163 +                      }else{
    164 +                        if (substitutions_type == "Unterricht geändert") {
    165                            if (lesson.match(reg)) {
    166 -                            $("#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>')
    167 +                            $("#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>')
    168                            }else{
    169 -                            $("#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>')
    170 +                            $("#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>')
    171                            }
    172                          }else{
    173 -                          if (representation_type == "Betreuung") {
    174 +                          if (substitutions_type == "Lehrertausch") {
    175                              if (lesson.match(reg)) {
    176 -                              $("#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>')
    177 -                            }else{
    178 -                              $("#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>')
    179 -                            }
    180 -                          }else{
    181 -                            if (representation_type == "Unterricht geändert") {
    182 -                              if (lesson.match(reg)) {
    183 -                                $("#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>')
    184 -                              }else{
    185 -                                $("#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>')
    186 -                              }
    187 +                              $("#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>')
    188                              }else{
    189 -                              if (representation_type == "Lehrertausch") {
    190 -                                if (lesson.match(reg)) {
    191 -                                  $("#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>')
    192 -                                }else{
    193 -                                  $("#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>')
    194 -                                }
    195 -                              }
    196 +                              $("#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>')
    197                              }
    198                            }
    199                          }
    200 @@ -103,11 +118,13 @@ <h1 id="school"></h1></br>
    201                  }
    202                }
    203              }
    204 -          } 
    205 +          }
    206          }else{
    207 -            $("#representations").append('<p class="bg-danger">Scheinbar gehtdein Internet nicht :/</p>')
    208 +            $("#Main").append('<p class="bg-danger">Scheinbar geht dein Internet nicht :/</p>')
    209            }
    210        })
    211 +
    212 +      $('#Tabs a:last').tab('show')
    213      </script>
    214      <!-- Include all compiled plugins (below), or include individual files as needed -->
    215      <script src="js/bootstrap/bootstrap.min.js"></script>
    216 diff --git a/app/main.js b/app/main.js
    217 index 84c4afb..c514a0a 100644
    218 --- a/app/main.js
    219 +++ b/app/main.js
    220 @@ -7,9 +7,9 @@ let win
    221  function update () {
    222    var feedUrl = 'https://ls-desktop.herokuapp.com/update/win32/:' + app.getVersion();
    223    autoUpdater.setFeedURL(feedUrl);
    224 - 
    225 +
    226    autoUpdater.on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) {
    227 - 
    228 +
    229      var index = dialog.showMessageBox(mainWindow, {
    230        type: 'info',
    231        buttons: [i18n.__('Restart'), i18n.__('Later')],
    232 @@ -17,11 +17,11 @@ function update () {
    233        message: i18n.__('The new version has been downloaded. Please restart the application to apply the updates.'),
    234        detail: releaseName + "\n\n" + releaseNotes
    235      });
    236 -   
    237 +
    238      if (index === 1) {
    239        return;
    240      }
    241 -   
    242 +
    243      quitAndUpdate();
    244    });
    245  }
    246 @@ -69,4 +69,4 @@ app.on('activate', () => {
    247  })
    248  
    249  // In this file you can include the rest of your app's specific main process
    250 -// code. You can also put them in separate files and require them here.
    251 \ No newline at end of file
    252 +// code. You can also put them in separate files and require them here.
    253 diff --git a/app/package.json b/app/package.json
    254 index fa0d33f..ac09df0 100644
    255 --- a/app/package.json
    256 +++ b/app/package.json
    257 @@ -1,11 +1,12 @@
    258  {
    259    "name": "ls_vertretungsplan_desktop",
    260 -  "version": "0.0.2",
    261 +  "version": "0.0.3",
    262    "description": "Eine Anwendung die den Vertretungsplan auf dem Desktop anzeigt",
    263    "main": "./main.js",
    264    "author": "Marcel Radzio <info@nordgedanken.de>",
    265    "license": "",
    266    "dependencies": {
    267 +    "cached-request": "^1.0.0",
    268      "request": "^2.69.0"
    269    }
    270  }