Browse Source

Add notifications

tags/1.8.9
Leonie 2 weeks ago
parent
commit
961e2c7ae9
9 changed files with 124 additions and 13 deletions
  1. +25
    -0
      admin.html
  2. +21
    -0
      backend.py
  3. +0
    -0
      data/ca/notifications
  4. +0
    -0
      data/de/notifications
  5. +9
    -2
      www/app.html
  6. +50
    -10
      www/app.js
  7. +3
    -1
      www/player.js
  8. +10
    -0
      www/style.css
  9. +6
    -0
      www/views/notificationsview.html

+ 25
- 0
admin.html View File

@@ -35,6 +35,12 @@
$.get("https://api.nordcast.app/api/v1/getcustomsection/ca", function(data) {
$("textarea#getcustom_en").val(data);
});
$.get("https://api.nordcast.app/api/v1/getnotifications/de", function(data) {
$("textarea#getcustom_de").val(data);
});
$.get("https://api.nordcast.app/api/v1/getnotifications/ca", function(data) {
$("textarea#getcustom_en").val(data);
});
$.get("https://api.nordcast.app/api/v1/getreversed", function(data) {
$("textarea#getreversed").val(data);
});
@@ -96,6 +102,25 @@
});
});

$("#submit_notifications").click(function() {
$("#submit_notifications").attr("disabled", "");
$("#submit_notifications").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/notifications/"+$("#admin_id").val()+"/de", {content: $("#getnotifications_de").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_notifications").removeAttr("disabled");
$("#submit_notifications").html("Submit");
}
});
$("#submit_notifications").attr("disabled", "");
$("#submit_notifications").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");
$.post("https://api.nordcast.app/api/v1/admin/notifications/"+$("#admin_id").val()+"/ca", {content: $("#getnotifications_en").val()}, function(data) {
if (data["action"] === "success") {
$("#submit_notifications").removeAttr("disabled");
$("#submit_notifications").html("Submit");
}
});
});

$("#submit_hiddendownloads").click(function() {
$("#submit_hiddendownloads").attr("disabled", "");
$("#submit_hiddendownloads").html("<img src=\"https://koyu.keybase.pub/loading.svg\" style=\"height: 16px !important;\">");

+ 21
- 0
backend.py View File

@@ -584,6 +584,27 @@ def getcustomsection(lang):
response.headers['Access-Control-Allow-Origin'] = '*'
return x

@post("/api/v1/admin/notifications/<adminkey>/<lang>")
def setnotifications(adminkey, lang):
response.headers['Access-Control-Allow-Origin'] = '*'
response.content_type = "application/json"
content = request.forms.get("content") # pylint: disable=no-member
if adminkey == ADMINKEY:
f = open("data/"+lang+"/notifications", "w")
f.write(content)
f.close()
return json.dumps({"login": "ok", "action": "success"})
else:
return "{\"action\": \"error\"}"

@get("/api/v1/getnotifications/<lang>")
def getnotifications(lang):
f = open("data/"+lang+"/notifications", "r")
x = f.read()
f.close()
response.headers['Access-Control-Allow-Origin'] = '*'
return x

@post("/api/v1/register/<locale>/<instance>")
def register(locale, instance):
response.headers['Access-Control-Allow-Origin'] = '*'

+ 0
- 0
data/ca/notifications View File


+ 0
- 0
data/de/notifications View File


+ 9
- 2
www/app.html View File

@@ -42,7 +42,7 @@
<audio id="player2" src="" loop muted width="1" height="1" preload></audio>
<p><i id="snclose" class="ion-md-close"></i></p>
<div id="view__main">
</div>
<div id="view__cast">

@@ -53,6 +53,9 @@
<div id="view__report">

</div>
<div id="view__notifications">

</div>
<div id="bottom__section">
<div id="player__controls">
<i class="ion-ios-arrow-up plchangesize" onclick="plchangesize()"></i><div id="podtitle"></div>
@@ -70,12 +73,16 @@
</div>
<div onclick="location.href='app.html#view=yourlist'" class="menubutton">
<p><i class="icon ion-md-list-box"></i></p>
<small class="text__list">Your list</small>
<small id="text__menulist">Your list</small>
</div>
<div onclick="$('#view__'+findGetParameter('view')).html('');$('#wrapper__search').show();$('#view__'+findGetParameter('view')).show();" class="menubutton">
<p><i class="icon ion-md-search"></i></p>
<small class="text__search">Search</small>
</div>
<div onclick="location.href='app.html#view=notifications'" class="menubutton menubutton-notifications">
<p><i class="icon ion-md-mail"></i></p>
<small class="text__notifications">Inbox</small>
</div>
<div onclick="location.href='app.html#view=settings'" class="menubutton">
<p><i class="icon ion-md-settings"></i></p>
<small class="text__settings">Settings</small>

+ 50
- 10
www/app.js View File

@@ -69,15 +69,6 @@ function drr2() {
$(document).ready(function() {
window.setTimeout(function() {
if (device.platform === "Android") {
$.get("https://updates.koyu.space/nordcast/latest", function(data) {
if ($("#version").html() !== data.split("\n")[0]) {
if (localStorage.getItem("lang") !== "de") {
alert("New version " + data.split("\n")[0] + " available. Please update as soon as possible.");
} else {
alert("Neue Version " + data.split("\n")[0] + " verfügbar. Bitte so schnell wie möglich aktualisieren.");
}
}
});
if (device.model === "Nokia 2") {
disableMediaControls = true;
MusicControls.destroy(function() {
@@ -90,6 +81,25 @@ function drr2() {
}
});
}
$.get(backend+"/api/v1/getnotifications/"+localStorage.getItem("lang"), function(data) {
try {
if (localStorage.getItem("notifications") !== data) {
localStorage.setItem("notifications", data);
$(".notification-button").attr("class", "icon notification-button ion-md-mail-unread");
}
} catch (e) {
localStorage.setItem("notifications", data);
}
});
$.get("https://updates.koyu.space/nordcast/latest", function(data) {
if ($("#version").html() !== data.split("\n")[0]) {
if (localStorage.getItem("lang") !== "de") {
alert("New version " + data.split("\n")[0] + " available. Please update as soon as possible.");
} else {
alert("Neue Version " + data.split("\n")[0] + " verfügbar. Bitte so schnell wie möglich aktualisieren.");
}
}
});
}
}, 3000);
window.setInterval(function() {
@@ -110,6 +120,7 @@ function drr2() {
$(".fa__nav2").hide();
$(".addfeed").hide();
$(".problemreporting").hide();
$(".menubutton-notifications").hide();
}
if (!detectmob()) {
$(".share").hide();
@@ -152,6 +163,11 @@ function drr2() {
$("#text__newforyou").hide();
$("#section__newforyou").hide();
}
if (findGetParameter("view") !== "notifications") {
$("#text__newforyou").hide();
$("#section__newforyou").hide();
$("#view__notifications").hide();
}
window.setTimeout(function() {
if (localStorage.getItem("played") !== "true") {
if (!loading && findGetParameter("view") === "main") {
@@ -220,6 +236,11 @@ function drr2() {
loading = false;
}
}, 200)
window.setInterval(function() {
if (findGetParameter("view") !== "cast") {
$("#view__cast").hide();
}
});
$.get(backend+"/api/v1/login2/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/"+localStorage.getItem("instance"), function(data) {
if (localStorage.getItem("uuid") !== "dummy") {
if (data["login"] !== "ok" && data["uuid"] !== localStorage.getItem("uuid")) {
@@ -1035,6 +1056,20 @@ function drr2() {
location.href = "app.html#view=cast&cast="+Base64.encode($("#addfeed__rss").val());
});
}
if (findGetParameter("view") === "notifications") {
$.get("views/notificationsview.html", function(data) {
$("#view__notifications").html(data);
if (firstload) {
$("#view__notifications").attr("style", "padding: 0px 20px 40px;");
}
$.get(backend+"/api/v1/getnotifications/"+localStorage.getItem("lang"), function(data) {
if (data.split("\n")[0] !== "") {
$("#area__notifications").html(data);
}
$("#view__notifications").show();
});
});
}
if (findGetParameter("view") === "main" || findGetParameter("view") === "yourlist") {
window.setInterval(function() {
if (findGetParameter("view") === "main") {
@@ -1083,8 +1118,10 @@ function drr2() {
}
if (localStorage.getItem("offline") !== "true") {
$("#offline__message").hide();
$("#view__yourlist>h3").attr("style", "margin-top: 0 !important;");
} else {
$("#offline__message").show();
$("#view__yourlist>h3").removeAttr("style");
}
window.setTimeout(function() {
$.get(backend+"/api/v1/getlist/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/"+localStorage.getItem("instance"), function(data) {
@@ -1658,9 +1695,12 @@ function drr2() {
if (navigator.language.includes("de")) {
localStorage.setItem("lang", "de");
$("#text__featured").html("Angesagt");
$(".text__list").html("Deine Liste");
$(".text__notifications").html("Posteingang");
$("#area__notifications__empty").html("Keine neuen Nachrichten.");
$("#text__hello").html("Hallo");
$("#text__by").html("von");
$("#text__menulist").html("Liste");
$(".text__list").html("Deine Liste");
$("#logout").html("Abmelden");
$("#view__settings h1").html("Einstellungen");
$("#text__session").html("Sitzung");

+ 3
- 1
www/player.js View File

@@ -29,7 +29,9 @@ window.setInterval(function() {
if (findGetParameter("view") !== "main") {
$("#view__"+findGetParameter("view")).css("padding-bottom", $("#player__controls").height()+$("#menubuttons").height()+$(".plchangesize").height()-20+"px");
} else {
$("#view__"+findGetParameter("view")).css("padding-bottom", $("#player__controls").height()+$("#menubuttons").height()+$(".plchangesize").height()+"px");
if (findGetParameter("view") !== "notifications") {
$("#view__"+findGetParameter("view")).css("padding-bottom", $("#player__controls").height()+$("#menubuttons").height()+$(".plchangesize").height()+"px");
}
}
} else {
if (!loading) {

+ 10
- 0
www/style.css View File

@@ -387,6 +387,10 @@ h1 .emoji {
padding: 40px 20px 120px;
}

#view__notifications {
padding: 90px 20px 40px;
}

#view__yourlist {
padding-bottom: 60px;
}
@@ -754,6 +758,12 @@ h1 .emoji {
background: rgba(255, 255, 255, .9);
}

#area__notifications__empty {
text-align: center;
margin-top: 120px;
color: #ccc;
}

.spin::before {
-webkit-animation: spin 1s infinite linear;
-moz-animation: spin 1s infinite linear;

+ 6
- 0
www/views/notificationsview.html View File

@@ -0,0 +1,6 @@
<h1 class="text__notifications">Inbox</h1><br />
<div id="area__notifications">
<div id="area__notifications__empty">
No notifications.
</div>
</div>

Loading…
Cancel
Save