login only with pond now

This commit is contained in:
Jeena 2014-02-21 11:01:11 +01:00
parent 69c5c270ad
commit 5a0950a8ee
6 changed files with 39 additions and 36 deletions

View file

@ -165,6 +165,7 @@ canvas {
list-style-type: none; list-style-type: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
word-wrap: break-word;
} }
#list p { #list p {
@ -284,10 +285,14 @@ canvas {
float: left; float: left;
} }
#full article header p:nth-child(3) { #full article header p:nth-child(2) {
float: right; float: right;
} }
#full article header p:nth-child(3) {
clear: both;
}
#full .article { #full .article {
clear: both; clear: both;
padding-top: 1em; padding-top: 1em;

View file

@ -64,14 +64,7 @@
<p class="smallogo"> <p class="smallogo">
<img src="img/icon-128.png" alt="Logo, an ape head"> <img src="img/icon-128.png" alt="Logo, an ape head">
</p> </p>
<p class="backends">
<label class="button"><input type="radio" name="backend" value="TinyTinyRSS" checked="checked" /> Tiny Tiny RSS</label>
<label class="button"><input type="radio" name="backend" value="OwnCloud" /> ownCloud News</label>
<label class="button"><input type="radio" name="backend" value="Pond" /> Pond</label>
</p>
<p> <p>
<label for="url">URL:</label>
<input class="button" type="text" name="url" id="url" value="" placeholder="http://example.com/tt-rss/" />
<label for="un">Username:</label> <label for="un">Username:</label>
<input class="button" type="text" name="user" id="un" value="" placeholder="username" /> <input class="button" type="text" name="user" id="un" value="" placeholder="username" />
<label for="pw">Password:</label> <label for="pw">Password:</label>

View file

@ -7,6 +7,16 @@ function App() {
if(!color) color = "red"; if(!color) color = "red";
this.setColor(color); this.setColor(color);
this.fontChange(); 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() { App.prototype.authenticate = function() {
@ -15,10 +25,13 @@ App.prototype.authenticate = function() {
App.prototype.after_login = function(backend) { App.prototype.after_login = function(backend) {
/*
var request = window.navigator.mozApps.getSelf(); var request = window.navigator.mozApps.getSelf();
request.onsuccess = function() { request.onsuccess = function() {
if(request.result) {
$("#version").innerHTML = request.result.manifest.version; $("#version").innerHTML = request.result.manifest.version;
} }
}*/
var _this = this; 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(); $(page_id + " .date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000)).toLocaleString();
var title = $(page_id + " .title"); var title = $(page_id + " .link");
title.innerHTML = article.title; title.innerHTML = article.link;
title.href = article.link; title.href = article.link;
$(page_id + " .feed_title").innerHTML = article.feed_title; $(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) if(article.author && article.author.length > 0)
$(page_id + " .author").innerHTML = "&ndash; " + article.author; $(page_id + " .author").innerHTML = "&ndash; " + 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) { $$(page_id + " .article a").forEach(function(o, i) {
o.target = "_blank"; o.target = "_blank";
}); });

View file

@ -17,19 +17,6 @@ Login.prototype.is_logged_in = function() {
Login.prototype.log_in = function() { Login.prototype.log_in = function() {
this.app.changeToPage("#login"); 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)); $("#login form").addEventListener('submit', this.authenticate.bind(this));
}; };
@ -38,11 +25,10 @@ Login.prototype.authenticate = function(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
var backend = "TinyTinyRSS"; var backend = "Pond";
if($("#login form").backend[1].checked) backend = "OwnCloud";
else if($("#login form").backend[2].checked) 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 user = $("#un").value;
var password = $("#pw").value; var password = $("#pw").value;

View file

@ -46,7 +46,7 @@ Pond.prototype.doOperation = function(method, operation, new_options, callback)
body = a.join("&"); body = a.join("&");
} }
var xhr = new XMLHttpRequest({mozSystem: true}); var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if(xhr.readyState == 4) { if(xhr.readyState == 4) {
if(xhr.status == 200) { if(xhr.status == 200) {
@ -76,7 +76,7 @@ Pond.prototype.reload = function(callback) {
Pond.prototype.getUnreadFeeds = function(callback, skip) { Pond.prototype.getUnreadFeeds = function(callback, skip) {
var options = { var options = {
status: "all", status: "unread",
limit: 100 limit: 100
}; };
@ -134,8 +134,6 @@ Pond.prototype.normalizeArticle = function(article) {
var timestamp = new Date(article.published_at).getTime() / 1000; var timestamp = new Date(article.published_at).getTime() / 1000;
console.log(article.read)
return { return {
id: article.id, id: article.id,
guid_hash: article.url + article.id, guid_hash: article.url + article.id,
@ -195,7 +193,7 @@ Pond.prototype.setArticleUnstarred = function(articles, callback) {
} }
Pond.prototype.logOut = function() { Pond.prototype.logOut = function() {
this.doOperation("auth/sessions/" + this.session_token ); this.doOperation("DELETE", "auth/sessions/" + this.session_token );
localStorage.feeds = null; localStorage.feeds = null;
} }
@ -209,7 +207,7 @@ Pond.login = function(server_url, user, password, callback) {
var password_hash = md5(user + ':' + password) var password_hash = md5(user + ':' + password)
var options = "username=" + user.toLowerCase() + "&" + "password=" + password_hash; var options = "username=" + user.toLowerCase() + "&" + "password=" + password_hash;
var xhr = new XMLHttpRequest({mozSystem: true}); var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if(xhr.readyState == 4) { if(xhr.readyState == 4) {
if(xhr.status == 201) { if(xhr.status == 201) {

View file

@ -63,5 +63,10 @@ String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1); 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,"<a href='$1'>$1</a>");
}
if(!window.app) window.app = new App(); if(!window.app) window.app = new App();