Browse Source

Made download feature less useless

master
Leonie 3 weeks ago
parent
commit
0453395882
10 changed files with 108 additions and 11072 deletions
  1. 3
    2
      www/app.html
  2. 57
    16
      www/app.js
  3. 2
    2
      www/config.js
  4. 22
    3
      www/download.js
  5. 1
    2
      www/index.html
  6. 0
    11008
      www/jquery-1.12.4.js
  7. 4
    0
      www/jquery.js
  8. 2
    1
      www/style.css
  9. 4
    3
      www/views/mainview.html
  10. 13
    35
      www/welcome.js

+ 3
- 2
www/app.html View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="jquery-ui.css">
<link href="ionicons.css" rel="stylesheet">
<script src="jquery-1.12.4.js"></script>
<script src="jquery.js"></script>
<script src="jquery-ui.js"></script>
<script src="base64.js"></script>
<script src="config.js"></script>
@@ -36,7 +36,8 @@
<input type="text" id="qq" placeholder="Search term" />
</div>
</div><br />
<video id="player" src="" loop></video>
<video id="player" src="" loop width="1" heigh="1"></video>
<video id="player2" src="" loop muted preload width="1" heigh="1"></video>
<p><i id="snclose" class="ion-md-close"></i></p>
<div id="view__main">

+ 57
- 16
www/app.js View File

@@ -19,11 +19,6 @@ var kicker = false;
var loading = false;

$(document).ready(function() {
window.setInterval(function() {
$.get("https://api.nordcast.app", function() { }).fail(function() {
location.href = "index.html";
});
}, 500);
if (localStorage.getItem("darkmode") === "true") {
$("head").append("<link rel=\"stylesheet\" href=\"dark.css\">");
$("#logo__nav").attr("src", "logo_dark.png");
@@ -33,6 +28,10 @@ $(document).ready(function() {
}
var timeout = 1200;
$("#logo__intro").attr("src", "loading2.svg");
$("#view__cast").hide();
$("#view__search").hide();
$("#view_settings").hide();
$("#view__main").hide();
window.setInterval(function() {
if (!$("#view__"+findGetParameter("view")).is(":visible")) {
$("#logo__intro").show();
@@ -41,7 +40,7 @@ $(document).ready(function() {
$("#logo__intro").hide();
loading = false;
}
}, 10)
}, 200)
$("#player__controls").hide();
$.get(backend+"/api/v1/login2/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/"+localStorage.getItem("instance"), function(data) {
if (localStorage.getItem("uuid") !== "dummy") {
@@ -51,14 +50,7 @@ $(document).ready(function() {
location.reload();
}
}
}).error(function() {
if (localStorage.getItem("uuid") !== "dummy") {
localStorage.clear();
window.setTimeout(function() {
location.href = "index.html";
}, 200);
}
});
})
var searchtoggle = false;
$("#wrapper__search").hide();
$("#profile__picture").hide();
@@ -114,6 +106,9 @@ $(document).ready(function() {
$("#button__follow").show();
}
}
}).error(function() {
$("#button__follow").hide();
$("#button__unfollow").hide();
});
window.setTimeout(function() {
$.get(backend+"/api/v1/getpodcast?q="+feed, function(callback) {
@@ -197,7 +192,15 @@ $(document).ready(function() {
if (shownotes === "") {
shownotes = item.summary;
}
$("#podtable tbody").append("<tr><td><i onclick=\"playcast('"+podurl+"', '"+secret+"', '"+Base64.encode(item.title.replaceAll("'", ""))+"', '"+Base64.encode(callback.feed.author.split(" | ")[0].split(" - ")[0].split(" – ")[0])+"', '"+callback.feed.image.href+"', '"+feed+"', '"+Base64.encode(feedtitle)+"')\" id=\"cast-"+secret+"\" class=\"playbutton ion-md-play\"></i></td><td>"+twemoji.parse(item.title)+"</td><td><a onclick=\"shownotes('"+Base64.encode(shownotes)+"')\"><i class=\"ion-md-information-circle-outline\" id=\"snbutton\"></i></a></td><td><i class=\"ion-md-cloud-download dlbutton\" onclick=\"download('"+secret+"')\"></td></tr>");
try {
if (!localStorage.getItem("downloaded").includes(secret)) {
$("#podtable tbody").append("<tr><td><i onclick=\"playcast('"+podurl+"', '"+secret+"', '"+Base64.encode(item.title.replaceAll("'", ""))+"', '"+Base64.encode(callback.feed.author.split(" | ")[0].split(" - ")[0].split(" – ")[0])+"', '"+callback.feed.image.href+"', '"+feed+"', '"+Base64.encode(feedtitle)+"')\" id=\"cast-"+secret+"\" class=\"playbutton ion-md-play\"></i></td><td>"+twemoji.parse(item.title)+"</td><td><a onclick=\"shownotes('"+Base64.encode(shownotes)+"')\"><i class=\"ion-md-information-circle-outline\" id=\"snbutton\"></i></a></td><td id=\"dlbtn-"+secret+"\"><i class=\"ion-md-cloud-download dlbutton\" onclick=\"download('"+podurl+"', '"+secret+"')\"></td></tr>");
} else {
$("#podtable tbody").append("<tr><td><i onclick=\"playcast('"+podurl+"', '"+secret+"', '"+Base64.encode(item.title.replaceAll("'", ""))+"', '"+Base64.encode(callback.feed.author.split(" | ")[0].split(" - ")[0].split(" – ")[0])+"', '"+callback.feed.image.href+"', '"+feed+"', '"+Base64.encode(feedtitle)+"')\" id=\"cast-"+secret+"\" class=\"playbutton ion-md-play\"></i></td><td>"+twemoji.parse(item.title)+"</td><td><a onclick=\"shownotes('"+Base64.encode(shownotes)+"')\"><i class=\"ion-md-information-circle-outline\" id=\"snbutton\"></i></a></td><td><i class=\"ion-md-checkmark-circle downloaded\"></i></td></tr>");
}
} catch (e) {
$("#podtable tbody").append("<tr><td><i onclick=\"playcast('"+podurl+"', '"+secret+"', '"+Base64.encode(item.title.replaceAll("'", ""))+"', '"+Base64.encode(callback.feed.author.split(" | ")[0].split(" - ")[0].split(" – ")[0])+"', '"+callback.feed.image.href+"', '"+feed+"', '"+Base64.encode(feedtitle)+"')\" id=\"cast-"+secret+"\" class=\"playbutton ion-md-play\"></i></td><td>"+twemoji.parse(item.title)+"</td><td><a onclick=\"shownotes('"+Base64.encode(shownotes)+"')\"><i class=\"ion-md-information-circle-outline\" id=\"snbutton\"></i></a></td><td id=\"dlbtn-"+secret+"\"><i class=\"ion-md-cloud-download dlbutton\" onclick=\"download('"+podurl+"', '"+secret+"')\"></td></tr>");
}
if (!donator) {
$(".dlbutton").hide();
}
@@ -305,6 +308,7 @@ $(document).ready(function() {
},100);
$.get("views/mainview.html", function(data) {
$("#view__main").html(data.replaceAll("<style>\n#view__main {\n padding: 40px 20px 0px !important;\n}\n</style>", ""));
$("#offline__message").hide();
window.setTimeout(function() {
$.get(backend+"/api/v1/getlist/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/"+localStorage.getItem("instance"), function(data) {
if (data["login"] === "error") {
@@ -316,9 +320,16 @@ $(document).ready(function() {
$("#section__list").html("<br /><br /><p style=\"text-align:center;width:60%;margin:0 auto;\" id=\"error__nocasts\">There are no podcasts in your list.</p><br /><br />")
$("#view__"+findGetParameter("view")).show();
} else {
localStorage.setItem("podlist", data["podlist"]);
if (debug) {
console.log(timeout);
}
var podlist = "";
if (localStorage.getItem("podlist") !== "undefined") {
podlist = localStorage.getItem("podlist");
} else {
podlist = data["podlist"];
}
window.setTimeout(function() {
$("#view__main").show();
$(".fa__nav").show();
@@ -328,7 +339,7 @@ $(document).ready(function() {
}
}, timeout);
$("#section__list").html($("#section__list").html()+"<p>");
data["podlist"].split(",").forEach(function(feed) {
podlist.split(",").forEach(function(feed) {
$.get(backend+"/api/v1/getpodcast?q="+feed, function(callback) {
try {
$("#section__list").html($("#section__list").html()+"<a class=\"cardlink\" data-cast=\""+Base64.encode(callback.href)+"\"><img src=\""+callback.feed.image.href+"\" class=\"card__small\" /></a>");
@@ -338,6 +349,29 @@ $(document).ready(function() {
$("#section__list").html($("#section__list").html()+"</p>");
}
}
}).error(function() {
if (localStorage.getItem("username") !== "dummy" && donator) {
$("#offline__message").show();
$("#view__main").show();
if (localStorage.getItem("podlist")) {
podlist = localStorage.getItem("podlist");
} else {
podlist = data["podlist"];
}
$("#section__list").html($("#section__list").html()+"<p>");
podlist.split(",").forEach(function(feed) {
$.get(backend+"/api/v1/getpodcast?q="+feed, function(callback) {
try {
$("#section__list").html($("#section__list").html()+"<a class=\"cardlink\" data-cast=\""+Base64.encode(callback.href)+"\"><img src=\""+callback.feed.image.href+"\" class=\"card__small\" /></a>");
} catch (e) {}
});
});
$("#section__list").html($("#section__list").html()+"</p>");
} else {
$("#offline__message").hide();
$("#text__list").hide();
$("#view__main").show();
}
});
$.get(backend+"/api/v1/getoriginals", function(data) {
if (data["podlist"] !== "") {
@@ -349,6 +383,9 @@ $(document).ready(function() {
});
$("#section__originals").html($("#section__originals").html()+"</p>");
}
}).error(function() {
$("#section__originals").hide();
$("#text__originals").hide();
});

$.get(backend+"/api/v1/getfeatured", function(data) {
@@ -362,6 +399,9 @@ $(document).ready(function() {
}
});
},200);
}).error(function() {
$("#section__featured").hide();
$("#text__featured").hide();
});

$.get(backend+"/api/v1/getname/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/"+localStorage.getItem("instance"), function(data) {
@@ -593,6 +633,7 @@ $(document).ready(function() {
$("#feed__summary").html("Von hier kannst du RSS-Feeds manuell in die App reinladen.");
$("#addfeed__rss").attr("placeholder", "RSS-Feed");
$("#addfeed__submit").html("RSS-Feed hinzufügen");
$(".msg-download").html("Herunterladen");
window.setTimeout(function() {
$("#text__results").html("Suchergebnisse für");
$("#error__nocasts").html("Es befinden sich keine Podcasts in deiner Liste.");

+ 2
- 2
www/config.js View File

@@ -1,6 +1,6 @@
var backend = "https://api.nordcast.app";
var debug = false;
var donator = false;
var debug = true;
var donator = true;

function onDeviceReady() {
if (device.platform === "Android" || device.platform === "iOS") {

+ 22
- 3
www/download.js View File

@@ -1,5 +1,24 @@
function download(secret) {
if (debug) {
console.log("Download: " + secret);
downloading = false;
function download(file, secret) {
if (!downloading) {
if (debug) {
console.log("Download: " + secret + "\n" + file);
}
downloading = true;
$("#dlbtn-"+secret).html("<span class=\"msg-download\">Downloading</span>...");
$("#player2").attr("src", file);
$.get(file, function(data) {
localStorage.setItem("file-"+secret, data);
$("#dlbtn-"+secret).html("<i class=\"ion-md-checkmark-circle downloaded\"></ion-icon>");
window.setTimeout(function() {
if (!localStorage.getItem("downloaded")) {
localStorage.setItem("downloaded", secret);
} else {
localStorage.setItem("downloaded", localStorage.getItem("downloaded") + "," + secret);
}
downloading = false;
$("#player2").attr("src", "");
}, 800);
})
}
}

+ 1
- 2
www/index.html View File

@@ -7,7 +7,7 @@
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline'; media-src *">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="jquery-ui.css">
<script src="jquery-1.12.4.js"></script>
<script src="jquery.js"></script>
<script src="jquery-ui.js"></script>
<link href="ionicons.css" rel="stylesheet">
<link rel="stylesheet" href="bootstrap.min.css">
@@ -19,7 +19,6 @@
</head>
<body>
<img src="logo.png" height="128" alt="Logo" id="logo__intro" />
<h1><span id="text__offline">Offline</span></h1>
<div id="view__welcome">
<h1 id="header__welcome">Welcome to Nordcast</h1>
<p id="text__welcome">Please log in with your koyu.space, Mastodon or Pleroma account. If you don't have an account, you can sign up <a href="#" onclick="window.open('https://koyu.space/auth/sign_up', '_system'); return false;">here</a>.</p>

+ 0
- 11008
www/jquery-1.12.4.js
File diff suppressed because it is too large
View File


+ 4
- 0
www/jquery.js
File diff suppressed because it is too large
View File


+ 2
- 1
www/style.css View File

@@ -284,7 +284,8 @@ h1 .emoji {
#snclose,
#plclose,
.dlbutton,
.playbutton {
.playbutton,
.downloaded {
font-size: 24px;
height: 24px;
width: 24px;

+ 4
- 3
www/views/mainview.html View File

@@ -1,10 +1,11 @@
<br /><br /><small id="text__username"><span id="text__hello">Hello</span>, <span class="placeholder__username"></span></small>
<br /><br /><h1 id="text__featured">Featured</h1>
<span id="offline__message"><p>You are currently offline. Below is your list with some podcasts you already downloaded.</p></span>
<h1 id="text__featured">Featured</h1>
<div id="section__featured">
</div>
<br /><br /><h2 id="text__originals">Nordcast Originals</h3>
<h2 id="text__originals">Nordcast Originals</h3>
<div id="section__originals"></div>
<br /><br /><h3 id="text__list">Your list</h3>
<h3 id="text__list">Your list</h3>
<div id="section__list"></div>
<style>
#view__main {

+ 13
- 35
www/welcome.js View File

@@ -13,44 +13,22 @@ $(document).ready(function() {
$("#nav").hide();
$("#logo__intro").attr("style", "top: 50%;");
window.setTimeout(function() {
$.get("https://api.nordcast.app", function() {
$("#logo__intro").hide();
$("#view__welcome").show();
$("#nav").show();
try {
if (!error) {
$.get(backend+"/api/v1/login2/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/"+localStorage.getItem("instance"), function(data) {
if (data["login"] === "ok" && data["uuid"] === localStorage.getItem("uuid")) {
location.href = "app.html#view=main";
}
});
if (localStorage.getItem("uuid") === "dummy") {
$("#logo__intro").hide();
$("#view__welcome").show();
$("#nav").show();
try {
if (!error) {
$.get(backend+"/api/v1/login2/"+localStorage.getItem("username")+"/"+localStorage.getItem("uuid")+"/"+localStorage.getItem("instance"), function(data) {
if (data["login"] === "ok" && data["uuid"] === localStorage.getItem("uuid")) {
location.href = "app.html#view=main";
}
}
} catch (e) {}
}).fail(function() {
error = true;
$("#logo__intro").attr("style", "top: calc(50% - 50px)");
$("#text__offline").show();
$("#view__welcome").hide();
$("#logo__intro").attr("src", "offline.svg");
window.setInterval(function() {
if (es) {
$("#logo__intro").show();
es = false;
} else {
$("#logo__intro").hide();
es = true;
}
$.get("https://api.nordcast.app", function() { }).done(function() {
if (error) {
location.reload();
}
});
}, 500)
});
}, 2000);
if (localStorage.getItem("uuid") === "dummy") {
location.href = "app.html#view=main";
}
}
} catch (e) {}
}, 200);
$("#kslogin").click(function() {
//Blocking gab, don't judge me
if ($("#instance").val().toLowerCase().includes("gab.com") || $("#instance").val().toLowerCase().includes("gab.ai")) {

Loading…
Cancel
Save