]> git.wh0rd.org Git - tt-rss.git/commitdiff
mobile: split local .js
authorAndrew Dolgov <fox@bah.org.ru>
Fri, 18 Dec 2009 08:33:35 +0000 (11:33 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Fri, 18 Dec 2009 08:33:35 +0000 (11:33 +0300)
mobile/backend.php [new file with mode: 0644]
mobile/functions.php
mobile/index.php
mobile/mobile.js [new file with mode: 0644]

diff --git a/mobile/backend.php b/mobile/backend.php
new file mode 100644 (file)
index 0000000..c6b75c5
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+       error_reporting(E_ERROR | E_WARNING | E_PARSE);
+
+       header('Content-Type: text/html; charset=utf-8');
+
+       define('MOBILE_VERSION', true);
+
+       require_once "../config.php";
+       require_once "functions.php";
+       require_once "../functions.php"; 
+
+       require_once "../sessions.php";
+
+       require_once "../version.php"; 
+       require_once "../db-prefs.php";
+
+       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
+
+       init_connection($link);
+
+       login_sequence($link, true);
+
+       $op = $_REQUEST["op"];
+
+       switch ($op) {
+       case "toggleMarked":
+               $cmode = db_escape_string($_REQUEST["mark"]);
+               $id = db_escape_string($_REQUEST["id"]);
+
+               markArticlesById($link, array($id), $cmode);
+               break;
+       case "togglePublished":
+               $cmode = db_escape_string($_REQUEST["pub"]);
+               $id = db_escape_string($_REQUEST["id"]);
+
+               publishArticlesById($link, array($id), $cmode);
+               break;
+       default:
+               print json_encode(array("error", "UNKNOWN_METHOD"));
+               break;
+       }
+?>
+
index a773eb9407c6e3d0655415039ec66a62acc342ca..5f6256dc354aef643e9619b1a9b03887a5c977a9 100644 (file)
                        $is_starred = (sql_bool_to_bool($line["marked"])) ? "true" : "false";
                        $is_published = (sql_bool_to_bool($line["published"])) ? "true" : "false";
        
-                       print "<div class=\"row\">
-                       <label>Starred</label>
-                       <div class=\"toggle\" onclick=\"toggleMarked($id, this)\" toggled=\"$is_starred\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
-                   </div>";
-       
-                       print "<div class=\"row\">
-                       <label>Published</label>
-                       <div class=\"toggle\" onclick=\"togglePublished($id, this)\" toggled=\"$is_published\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
-                   </div>";
-       
-       
                        print "<div class=\"row\">";
                        print "<label id='updated'>Updated:</label>";
                        print "<input enabled='false' name='updated' disabled value='$updated_fmt'/>";
                        print "<p>";
                        print $line["content"];
                        print "</p>";
+
+                       print "<fieldset>";
+
+                       print "<div class=\"row\">
+                       <label>Starred</label>
+                       <div class=\"toggle\" onclick=\"toggleMarked($id, this)\" toggled=\"$is_starred\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
+                   </div>";
        
+                       print "<div class=\"row\">
+                       <label>Published</label>
+                       <div class=\"toggle\" onclick=\"togglePublished($id, this)\" toggled=\"$is_published\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
+                   </div>";
+
+                       print "</fieldset>";
+
                        print "</div>";
 
                }
index 4d5cf1e9cbb1c790a93a0caa79b031d7de59ae88..5a2ed97e6d27679cbaf58b3cd99ae79fdac459cc 100644 (file)
@@ -32,7 +32,8 @@
 <style type="text/css" media="screen">@import "../lib/iui/iui.css";</style>
 <script type="application/x-javascript" src="../lib/iui/iui.js"></script>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-
+<script type="text/javascript" src="../lib/prototype.js"></script>
+<script type="text/javascript" src="mobile.js"></script>
 </head>
 
 <style type="text/css">
        }
 </style>
 
-<script type="text/javascript">
-       function toggleMarked(id, elem) {
-               alert(id + " => " + elem.getAttribute('toggled'));
-       }
-
-       function togglePublished(id, elem) {
-               alert(id + " => " + elem.getAttribute('toggled'));
-       }
-</script>
-
 <body>
     <div class="toolbar">
         <h1 id="pageTitle"></h1>
diff --git a/mobile/mobile.js b/mobile/mobile.js
new file mode 100644 (file)
index 0000000..655987c
--- /dev/null
@@ -0,0 +1,41 @@
+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 + "&mark=" + toggled;
+
+       new Ajax.Request(backend, {
+               parameters: query,
+               onComplete: function (transport) {
+                       //
+               } });
+
+}
+