Skip to content

Commit

Permalink
Added a basic index.html starter page with login and logout buttons. …
Browse files Browse the repository at this point in the history
…Started the system connect service resource javascript.
  • Loading branch information
Tyler Frankenstein committed Jan 24, 2012
1 parent 9599c09 commit 14923c3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drupalgap/drupalgap.js
@@ -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();
});

33 changes: 33 additions & 0 deletions drupalgap/services/system.js
@@ -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);
}
}
23 changes: 23 additions & 0 deletions index.html
@@ -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.