Move JS into HTML and add NOT_LOGGED_IN handling
For some reason the JS never got loaded when it was in it's own file, therefor I moved it into the HTML where it gets called. Also when a session id on the server was expired or something, you weren't able to log out, there is now code which fixes that.
This commit is contained in:
parent
2c263f77db
commit
0a195f8a8f
5 changed files with 99 additions and 88 deletions
|
@ -4,7 +4,93 @@
|
|||
<meta charset="utf-8">
|
||||
<title>TTRSS</title>
|
||||
<link href="content.css" media="all" rel="stylesheet">
|
||||
<script type="text/javascript" src="content.js"></script>
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
* This file is part of FeedTheMonkey.
|
||||
*
|
||||
* Copyright 2015 Jeena
|
||||
*
|
||||
* FeedTheMonkey is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* FeedTheMonkey is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with FeedTheMonkey. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function $(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function setArticle(article) {
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
$("date").innerHTML = "";
|
||||
$("title").innerHTML = "";
|
||||
$("title").href = "";
|
||||
$("title").title = "";
|
||||
$("feed_title").innerHTML = "";
|
||||
$("author").innerHTML = "";
|
||||
$("article").innerHTML = "";
|
||||
|
||||
if(article === "empty") {
|
||||
|
||||
$("article").innerHTML = "No unread articles to display.";
|
||||
|
||||
} else if(article === "loading") {
|
||||
|
||||
$("article").innerHTML = "Loading <blink>…</blink>";
|
||||
|
||||
} else if (article === "logout") {
|
||||
|
||||
} else if(article) {
|
||||
|
||||
$("date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000));
|
||||
$("title").innerHTML = article.title;
|
||||
$("title").href = article.link;
|
||||
$("title").title = article.link;
|
||||
$("feed_title").innerHTML = article.feed_title;
|
||||
$("title").className = article.marked ? "starred" : "";
|
||||
$("author").innerHTML = "";
|
||||
if(article.author && article.author.length > 0)
|
||||
$("author").innerHTML = "– " + article.author
|
||||
$("article").innerHTML = article.content;
|
||||
|
||||
var as = $("article").getElementsByTagName("a");
|
||||
for(var i = 0; i < as.length; i++) {
|
||||
as[i].target = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setFont(font, size) {
|
||||
document.body.style.fontFamily = font;
|
||||
document.body.style.fontSize = size + "pt";
|
||||
}
|
||||
|
||||
function setNightmode(nightmode) {
|
||||
if(nightmode) document.body.className = "nightmode";
|
||||
else document.body.className = "";
|
||||
}
|
||||
|
||||
document.onkeydown = checkKey;
|
||||
|
||||
function checkKey(e) {
|
||||
e = e || window.event;
|
||||
if (e.keyCode === '37') {
|
||||
window.location.href = "feedthemonkey:previous";
|
||||
}
|
||||
else if (e.keyCode === '39') {
|
||||
window.location.href = "feedthemonkey:next";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
|
||||
</head>
|
||||
<body class=''>
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* This file is part of FeedTheMonkey.
|
||||
*
|
||||
* Copyright 2015 Jeena
|
||||
*
|
||||
* FeedTheMonkey is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* FeedTheMonkey is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with FeedTheMonkey. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function $(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function setArticle(article) {
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
$("date").innerHTML = "";
|
||||
$("title").innerHTML = "";
|
||||
$("title").href = "";
|
||||
$("title").title = "";
|
||||
$("feed_title").innerHTML = "";
|
||||
$("author").innerHTML = "";
|
||||
$("article").innerHTML = "";
|
||||
|
||||
if(article === "empty") {
|
||||
|
||||
$("article").innerHTML = "No unread articles to display.";
|
||||
|
||||
} else if(article === "loading") {
|
||||
|
||||
$("article").innerHTML = "Loading <blink>…</blink>";
|
||||
|
||||
} else if (article === "logout") {
|
||||
|
||||
} else if(article) {
|
||||
|
||||
$("date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000));
|
||||
$("title").innerHTML = article.title;
|
||||
$("title").href = article.link;
|
||||
$("title").title = article.link;
|
||||
$("feed_title").innerHTML = article.feed_title;
|
||||
$("title").className = article.marked ? "starred" : "";
|
||||
$("author").innerHTML = "";
|
||||
if(article.author && article.author.length > 0)
|
||||
$("author").innerHTML = "– " + article.author
|
||||
$("article").innerHTML = article.content;
|
||||
|
||||
var as = $("article").getElementsByTagName("a");
|
||||
for(var i = 0; i < as.length; i++) {
|
||||
as[i].target = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setFont(font, size) {
|
||||
document.body.style.fontFamily = font;
|
||||
document.body.style.fontSize = size + "pt";
|
||||
}
|
||||
|
||||
function setNightmode(nightmode) {
|
||||
if(nightmode) document.body.className = "nightmode";
|
||||
else document.body.className = "";
|
||||
}
|
||||
|
||||
document.onkeydown = checkKey;
|
||||
|
||||
function checkKey(e) {
|
||||
e = e || window.event;
|
||||
if (e.keyCode == '37') {
|
||||
window.location.href = "feedthemonkey:previous";
|
||||
}
|
||||
else if (e.keyCode == '39') {
|
||||
window.location.href = "feedthemonkey:next";
|
||||
}
|
||||
}
|
|
@ -2,6 +2,5 @@
|
|||
<qresource prefix="/html">
|
||||
<file>content.css</file>
|
||||
<file>content.html</file>
|
||||
<file>content.js</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -60,7 +60,6 @@ ApplicationWindow {
|
|||
__contentItem.visible: visible
|
||||
}
|
||||
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
category: "window"
|
||||
|
|
|
@ -99,6 +99,18 @@ void TinyTinyRSSLogin::reply()
|
|||
qWarning() << mLoginError;
|
||||
emit loginErrorChanged(mLoginError);
|
||||
|
||||
if(mLoginError == "NOT_LOGGED_IN") {
|
||||
mSessionId = nullptr;
|
||||
mServerUrl = nullptr;
|
||||
|
||||
QSettings settings;
|
||||
settings.remove("sessionId");
|
||||
settings.remove("serverUrl");
|
||||
settings.sync();
|
||||
|
||||
emit sessionIdChanged(mSessionId);
|
||||
}
|
||||
|
||||
} else {
|
||||
mSessionId = json.object().value("content").toObject().value("session_id").toString();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue