mobile: split local .js
This commit is contained in:
parent
64bce1dae4
commit
6101b0e1a1
4 changed files with 100 additions and 22 deletions
43
mobile/backend.php
Normal file
43
mobile/backend.php
Normal file
|
@ -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;
|
||||
}
|
||||
?>
|
||||
|
|
@ -303,17 +303,6 @@
|
|||
$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'/>";
|
||||
|
@ -325,6 +314,20 @@
|
|||
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>";
|
||||
|
||||
}
|
||||
|
|
|
@ -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">
|
||||
|
@ -60,16 +61,6 @@
|
|||
}
|
||||
</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>
|
||||
|
|
41
mobile/mobile.js
Normal file
41
mobile/mobile.js
Normal file
|
@ -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) {
|
||||
//
|
||||
} });
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue