From 5a0950a8ee59d049a6a40e76055631cd1701afc6 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:01:11 +0100 Subject: [PATCH] login only with pond now --- css/screen.css | 7 ++++++- index.html | 7 ------- js/App.js | 26 +++++++++++++++++++++----- js/Login.js | 20 +++----------------- js/Pond.js | 10 ++++------ js/application.js | 5 +++++ 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/css/screen.css b/css/screen.css index d1b2fe4..6fbf34a 100644 --- a/css/screen.css +++ b/css/screen.css @@ -165,6 +165,7 @@ canvas { list-style-type: none; margin: 0; padding: 0; + word-wrap: break-word; } #list p { @@ -284,10 +285,14 @@ canvas { float: left; } -#full article header p:nth-child(3) { +#full article header p:nth-child(2) { float: right; } +#full article header p:nth-child(3) { + clear: both; +} + #full .article { clear: both; padding-top: 1em; diff --git a/index.html b/index.html index feaa4f4..9686112 100644 --- a/index.html +++ b/index.html @@ -64,14 +64,7 @@ -

- - - -

- - diff --git a/js/App.js b/js/App.js index bbcc0dd..b577d17 100644 --- a/js/App.js +++ b/js/App.js @@ -7,6 +7,16 @@ function App() { if(!color) color = "red"; this.setColor(color); this.fontChange(); + + var _this = this; + + window.onkeydown = function(e) { + if(e.keyCode == 39) { + _this.showNext(); + } else if(e.keyCode == 37) { + _this.showPrevious(); + } + } }; App.prototype.authenticate = function() { @@ -15,10 +25,13 @@ App.prototype.authenticate = function() { App.prototype.after_login = function(backend) { + /* var request = window.navigator.mozApps.getSelf(); request.onsuccess = function() { - $("#version").innerHTML = request.result.manifest.version; - } + if(request.result) { + $("#version").innerHTML = request.result.manifest.version; + } + }*/ var _this = this; @@ -276,8 +289,8 @@ App.prototype.showFull = function(article, slide_back) { $(page_id + " .date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000)).toLocaleString(); - var title = $(page_id + " .title"); - title.innerHTML = article.title; + var title = $(page_id + " .link"); + title.innerHTML = article.link; title.href = article.link; $(page_id + " .feed_title").innerHTML = article.feed_title; @@ -286,7 +299,10 @@ App.prototype.showFull = function(article, slide_back) { if(article.author && article.author.length > 0) $(page_id + " .author").innerHTML = "– " + article.author; - $(page_id + " .article").innerHTML = article.content; + + var content = article.content + if(content.replace(/^\s+|\s+$/g,'').length == 0) content = article.title; + $(page_id + " .article").innerHTML = content.urlify(); $$(page_id + " .article a").forEach(function(o, i) { o.target = "_blank"; }); diff --git a/js/Login.js b/js/Login.js index 72a9490..bc05ba8 100644 --- a/js/Login.js +++ b/js/Login.js @@ -17,19 +17,6 @@ Login.prototype.is_logged_in = function() { Login.prototype.log_in = function() { this.app.changeToPage("#login"); - $("#login form").backend.forEach(function(o, i) { - o.addEventListener("change", function(e) { - if(e.target.checked) { - if(e.target.value == "OwnCloud") { - $("#url").placeholder = "http://example.com/owncloud/"; - } else if(e.target.value == "Pond") { - $("#url").placeholder = "http://example.com/pond/"; - } else { - $("#url").placeholder = "http://example.com/tt-rss/"; - } - } - }); - }); $("#login form").addEventListener('submit', this.authenticate.bind(this)); }; @@ -38,11 +25,10 @@ Login.prototype.authenticate = function(e) { e.preventDefault(); e.stopPropagation(); - var backend = "TinyTinyRSS"; - if($("#login form").backend[1].checked) backend = "OwnCloud"; - else if($("#login form").backend[2].checked) backend = "Pond"; + var backend = "Pond"; - var server_url = $("#url").value; + var server_url = window.location.href.split("#")[0].replace(/\/FeedMonkey\//, ''); + console.log(server_url) var user = $("#un").value; var password = $("#pw").value; diff --git a/js/Pond.js b/js/Pond.js index cdea2b0..5991620 100644 --- a/js/Pond.js +++ b/js/Pond.js @@ -46,7 +46,7 @@ Pond.prototype.doOperation = function(method, operation, new_options, callback) body = a.join("&"); } - var xhr = new XMLHttpRequest({mozSystem: true}); + var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 200) { @@ -76,7 +76,7 @@ Pond.prototype.reload = function(callback) { Pond.prototype.getUnreadFeeds = function(callback, skip) { var options = { - status: "all", + status: "unread", limit: 100 }; @@ -134,8 +134,6 @@ Pond.prototype.normalizeArticle = function(article) { var timestamp = new Date(article.published_at).getTime() / 1000; - console.log(article.read) - return { id: article.id, guid_hash: article.url + article.id, @@ -195,7 +193,7 @@ Pond.prototype.setArticleUnstarred = function(articles, callback) { } Pond.prototype.logOut = function() { - this.doOperation("auth/sessions/" + this.session_token ); + this.doOperation("DELETE", "auth/sessions/" + this.session_token ); localStorage.feeds = null; } @@ -209,7 +207,7 @@ Pond.login = function(server_url, user, password, callback) { var password_hash = md5(user + ':' + password) var options = "username=" + user.toLowerCase() + "&" + "password=" + password_hash; - var xhr = new XMLHttpRequest({mozSystem: true}); + var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 201) { diff --git a/js/application.js b/js/application.js index 5e38312..e20c39b 100644 --- a/js/application.js +++ b/js/application.js @@ -63,5 +63,10 @@ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } +String.prototype.urlify = function() { + var exp = /^\>(\b(http):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + return this.replace(exp,"$1"); +} + if(!window.app) window.app = new App();