Permalink
Browse files

Add user login

  • Loading branch information...
1 parent d49365c commit 3d7f9151a4c46d5c2ef3e9d9e454648faf4541cf @hamen committed Nov 20, 2011
Showing with 32 additions and 1 deletion.
  1. +6 −1 assets/www/index.html
  2. +26 −0 assets/www/js/main.js
View
7 assets/www/index.html
@@ -39,6 +39,10 @@
saveUserData();
})
+ $('#login_button').click(function(){
+ login();
+ })
+
$('.swipehome').live('swiperight',function(event){
if (event.type == "swiperight") {
$.mobile.changePage("#home", { transition: "slide", reverse: "true" } ,true);
@@ -68,8 +72,8 @@
<p><a href="#myitasa" data-role="button">MyItasa</a></p>
<p><a id="recentButton" href="#recent" data-role="button">Recent Subs</a></p>
<p><a href="#settings" data-role="button">Settings</a></p>
- <p><a href="#about" data-role="button">About</a></p>
<p><a id="series_list_button" href="#series_list_page" data-role="button">Show List</a></p>
+ <p><a href="#about" data-role="button">About</a></p>
</div>
</div>
<!-- MYITASA PAGE -->
@@ -116,6 +120,7 @@
<input type="password" id="password" name="password" value="" />
<input type="submit" id="save_button" name="save_button" value="Save" />
</div>
+ <p><a id="login_button" href="#" data-role="button">Login</a></p>
</div>
</div>
<!-- ABOUT PAGE -->
View
26 assets/www/js/main.js
@@ -112,3 +112,29 @@ function getShowList() {
}
});
}
+
+function login() {
+ var username = window.localStorage.getItem("username");
+ var password = window.localStorage.getItem("password");
+ if( username !== "" && password !== "") {
+ $.ajax({
+ type: "GET",
+ url: "https://api.italiansubs.net/api/rest/users/login?apikey=632e846bc06f90a91dd9ff000b99ef87",
+ data: {username : username, password: password},
+ dataType: "xml",
+ success: function(xml) {
+ $(xml).find('user').each(function(){
+ var authcode = $(this).find('authcode').text();
+ //alert(authcode);
+ return authcode;
+ });
+ },
+ error: function(data) {
+ alert("error: " + data);
+ }
+ });
+ }
+ else {
+ fail("No user found");
+ }
+}

0 comments on commit 3d7f915

Please sign in to comment.