From 9d9ed2b32a1a9c2560a43a85c94caecf140974d5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Mar 2013 18:55:57 +0400 Subject: add classic mobile as a system plugin --- plugins/mobile/mobile.js | 163 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 plugins/mobile/mobile.js (limited to 'plugins/mobile/mobile.js') diff --git a/plugins/mobile/mobile.js b/plugins/mobile/mobile.js new file mode 100644 index 000000000..3fed3a1d7 --- /dev/null +++ b/plugins/mobile/mobile.js @@ -0,0 +1,163 @@ +var backend = "backend.php"; + +function toggleMarked(id, elem) { + + var toggled = false; + + if (elem.getAttribute("toggled") == "true") { + toggled = 1; + } else { + toggled = 0; + } + + var query = "op=toggleMarked&id=" + id + "&mark=" + toggled; + + new Ajax.Request(backend, { + parameters: query, + onComplete: function (transport) { + // + } }); +} + +function togglePublished(id, elem) { + + var toggled = false; + + if (elem.getAttribute("toggled") == "true") { + toggled = 1; + } else { + toggled = 0; + } + + var query = "op=togglePublished&id=" + id + "&pub=" + toggled; + + new Ajax.Request(backend, { + parameters: query, + onComplete: function (transport) { + // + } }); + +} + +function toggleUnread(id, elem) { + + var toggled = false; + + if (elem.getAttribute("toggled") == "true") { + toggled = 1; + } else { + toggled = 0; + } + + var query = "op=toggleUnread&id=" + id + "&unread=" + toggled; + + new Ajax.Request(backend, { + parameters: query, + onComplete: function (transport) { + // + } }); + +} + +function setPref(elem) { + var toggled = false; + var id = elem.id; + + if (elem.getAttribute("toggled") == "true") { + toggled = 1; + } else { + toggled = 0; + } + + var query = "op=setPref&id=" + id + "&to=" + toggled; + + new Ajax.Request(backend, { + parameters: query, + onComplete: function (transport) { + // + } }); + +} + +// Go directly to another item in the same feed +function goToSibling(article_id, feed_id, link, step) { + var links = linksInFeed(feed_id); + for (var i=0 ; i= links.length) { + showRestOfFeed(feed_id); + return false; + } + console.log(links[index]); + var match = links[index].href.match(/.*article\.php\?(.*)/); + var qs = match[1]; + var backwards = false; + if (step < 0) backwards = true; + link.setAttribute("selected", "progress"); + function unselect() { link.removeAttribute("selected"); } + iui.showPageByHref("article.php?"+qs, null, null, null, unselect, backwards); + return false; + } + return false; +} +function goPrev(article_id, feed_id, link) { + return goToSibling(article_id, feed_id, link, -1); +} +function goNext(article_id, feed_id, link) { + return goToSibling(article_id, feed_id, link, 1); +} + +// Get all the links in the feed. The all_links variable includes the "get more article" link +function linksInFeed(feed_id, all_links) { + var feed_content = $("feed-"+feed_id); + var links_raw = feed_content.getElementsByTagName("a"); + if (all_links) return links_raw; + var links = []; + // filter the array to remove the "get more articles" link + // and the "search" link (which is always first) + for (var i=1 ; i