Permalink
Browse files

Added a basic index.html starter page with login and logout buttons. …

…Started the system connect service resource javascript.
  • Loading branch information...
Tyler Frankenstein
Tyler Frankenstein committed Jan 24, 2012
1 parent 9599c09 commit 14923c3415f50e6d932d91e05699a4c79cc18b81
Showing with 64 additions and 0 deletions.
  1. +8 −0 drupalgap/drupalgap.js
  2. +33 −0 drupalgap/services/system.js
  3. +23 −0 index.html
@@ -0,0 +1,8 @@
var drupalgap_settings = {
"services_endpoint_default":"http://10.0.2.2/drupal-7.10/?q=drupalgap"
}
$('#drupalgap_dashboard').live('pageshow',function(){
drupalgap_services_system_connect();
});
@@ -0,0 +1,33 @@
function drupalgap_services_system_connect () {
var system_connect_url = drupalgap_settings.services_endpoint_default + "/system/connect.json";
console.log(system_connect_url);
try {
$.ajax({
url: system_connect_url,
type: 'post',
dataType: 'json',
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('drupalgap_services_system_connect - failed to connect');
console.log("drupalgap_services_system_connect");
console.log(JSON.stringify(XMLHttpRequest));
console.log(JSON.stringify(textStatus));
console.log(JSON.stringify(errorThrown));
},
success: function (data) {
var drupal_user = data.user;
if (drupal_user.uid == 0) { // user is not logged in, show the login button, hide the logout button
$('#drupalgap_button_user_login').show();
$('#drupalgap_button_user_logout').hide();
}
else { // user is logged in, hide the login button, show the logout button
$('#drupalgap_button_user_login').hide();
$('#drupalgap_button_user_logout').show();
}
}
});
}
catch (error) {
alert("drupalgap_services_system_connect - " + error);
consoloe.log("drupalgap_services_system_connect - " + error);
}
}
@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>DrupalGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
<link rel="stylesheet" href="jquery.mobile-1.0.min.css" />
<script src="jquery-1.6.4.min.js"></script>
<script src="jquery.mobile-1.0.min.js"></script>
<script src="drupalgap/services/system.js"></script>
<script src="drupalgap/drupalgap.js"></script>
</head>
<body>
<div data-role="page" id="drupalgap_dashboard">
<div data-role="header">
<h1>DrupalGap</h1>
</div><!-- /header -->
<div data-role="content">
<p><a href="#" data-role="button" id="drupalgap_button_user_login">Login</a></p>
<p><a href="#" data-role="button" id="drupalgap_button_user_logout">Logout</a></p>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>

0 comments on commit 14923c3

Please sign in to comment.