Hi Guys,
Im learning JQM and playing with Parse.com to make a customer database. This is the starting structure of my code which is working but I just wanted to ask if im doing things correctly at the moment or if anyone can give me some tips...
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title></title>
- <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.css" />
- <link rel="stylesheet" href="assets/css/main.css" />
- <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.js"></script>
-
- <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.0.min.js"></script>
-
- <script src="assets/js/jquery.toastmessage.js" type="text/javascript"></script>
- <link href="assets/css/jquery.toastmessage.css" rel="stylesheet" type="text/css" />
-
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <meta name="apple-mobile-web-app-capable" content="yes">
- <link href="assets/images/apple-touch-icon-57x57.png" sizes="57x57" rel="apple-touch-icon">
- <link href="assets/images/apple-touch-icon-72x72.png" sizes="72x72" rel="apple-touch-icon">
- <link href="assets/images/apple-touch-icon-114x114.png" sizes="114x114" rel="apple-touch-icon">
- <link href="assets/images/apple-touch-icon-144x144.png" sizes="144x144" rel="apple-touch-icon">
- <link href="assets/images/apple-touch-startup-image-320x460.png" media="(device-width: 320px)" rel="apple-touch-startup-image">
- <link href="assets/images/apple-touch-startup-image-640x920.png" media="(device-width: 320px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image">
- <link href="assets/images/apple-touch-startup-image-768x1004.png" media="(device-width: 768px) and (orientation: portrait)" rel="apple-touch-startup-image">
- <link href="assets/images/apple-touch-startup-image-748x1024.png" media="(device-width: 768px) and (orientation: landscape)" rel="apple-touch-startup-image">
- <link href="assets/images/apple-touch-startup-image-1536x2008.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) and (-webkit-min-device-pixel-ratio: 2)" rel="apple-touch-startup-image" />`
- <link href="assets/images/apple-touch-startup-image-1496x2048.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) and (-webkit-min-device-pixel-ratio: 2)" rel="apple-touch-startup-image" />
- </head>
- <body>
- <!-- Blank Initial Page. Jquery will change to either the Login Page or Home Page depending on User Login State -->
-
- <div data-role="page" id="startPage">
- <div data-role="content">
- </div><!-- End Content -->
- </div><!-- End startPage -->
-
- <div data-role="page" id="loginPage">
- <div data-role="header">
- <h1>Login</h1>
- </div><!-- End Header -->
- <div data-role="content">
-
- <form onSubmit="userLogin();" method="POST">
- <div data-role="fieldcontain">
- <label for="username" >Username:</label>
- <input type="text" name="username" id="username" />
- </div>
- <div data-role="fieldcontain">
- <label for="password" >Password:</label>
- <input type="password" name="password" id="password" />
- </div>
- <input id='btLogin' type="submit" name="Login" value="Login"/>
- </form>
-
- </div><!-- End Content -->
- </div><!-- End loginPage -->
-
- <div data-role="page" id="homePage">
-
- <div data-role="panel" id="pnlSettings">
- <h2>My Settings</h2>
- <button data-role="button" data-icon="bars" onclick="userLogout();">Log Out</button>
- </div><!-- End Panel -->
-
- <div data-role="header" data-position="fixed">
- <h1>INSITE touch</h1>
- <a href="#pnlSettings" data-icon="info" data-role="button" id="btSettings" >Settings</a>
- </div><!-- End Header -->
- <div data-role="content">
- <label for="search-basic" class="ui-hidden-accessible">Search Jobs:</label>
- <input type="search" name="search" id="search-basic" value="" placeholder="Search Jobs" />
- <br>
- <br>
- </div><!-- End Content -->
-
- <div data-role="footer" data-position="fixed">
- <div data-role="navbar">
- <ul>
- <li><a href="#page-CustomerList" data-role="button" data-icon="gear">Customers</a></li>
- <li><a href="#" onClick="createCustomer();" data-role="button" data-icon="bars">Jobs</a></li>
- <li><a href="#" onClick="showPartsList();" data-role="button" data-icon="gear">Parts</a></li>
- </ul>
- </div><!-- End NavBar -->
- </div><!-- End Footer -->
- </div><!-- End homePage -->
-
-
- <script type="text/javascript">
-
- Parse.initialize("of0fIcF9zlpGEwVVAUH7Sq10nwhvcGASDrwt4trU", "C8KLwbKPjzsBf4xCX0Z90hfkz6lvN0gXePHYadIp");
-
- /*
- *
- * Check that the startPage has loaded and re-direct to either the #loginPage or #homePage
- * based on whether the user is logged into Parse
- *
- *
- * NOTE: this doesn't check other pages yet. There might not be a need as Parse wont give
- * any data if not logged in.
- *
- */
-
- $('#startPage').bind('pageshow', function() {
-
- var LoggedIn = Parse.User.current(); // * Get the current User state from Parse.
-
- if (LoggedIn) {
- $.mobile.changePage("#homePage"); // User logged in, go to #homePage
- } else {
- $.mobile.changePage("#loginPage"); // User not logged in, go to #loginPage
- }
-
- });
-
- /*
- *
- * Authenticate against Parse.
- *
- */
-
- function userLogin() {
-
- // Throw up a spinner message that we are checking login
-
- $.mobile.loading( 'show', {
- text: 'Authenticating Login',
- textVisible: true,
- theme: 'a',
- html: ""
- });
-
- // Attempt to log into Parse using supplied credentials.
-
- Parse.User.logIn($("#username").val(), $("#password").val(), {
-
- success: function(user) {
-
- // Successful login.
-
- $.mobile.loading( 'hide' ); // Hide the Spinner
- $().toastmessage('showSuccessToast', "Login Successful!"); // Show Success Message
- $.mobile.changePage('#homePage'); // Change to #homePage
-
- },
-
- error: function(user, error) {
- // Unsuccessful login.
- $.mobile.loading( 'hide' ); // Hide the Spinner
- $().toastmessage('showSuccessToast', "Login Failed, Check your details.!"); // Show Failed Message
-
- }
- });
- };
-
- /*
- *
- * Log Out Function.
- *
- * TODO: Check if Parse has a way of confirming logout was successful.
- *
- */
- function userLogout() {
- Parse.User.logOut(); // Call the Parse logout
- $().toastmessage('showSuccessToast', "Logout Successful!"); // Show Logout Successful message (currently assumed)
- $.mobile.changePage("#loginPage"); // Change to #loginPage
- }
-
- /*
- *
- * Customer Functions
- *
- */
-
- function showCustomers() { // Brings up all customers in the listview.
-
- var LoggedIn = Parse.User.current(); // * Get the current User state from Parse.
-
- if (LoggedIn) {
-
- $.mobile.changePage('#customerListPage');
-
- }
- }
-
- function CreateCustomer() { // Used to load up the create Customer Page.
-
- var LoggedIn = Parse.User.current(); // * Get the current User state from Parse.
-
- if (LoggedIn) {
-
- $.mobile.changePage('#createCustomerPage');
-
- }
- }
-
- function saveCustomer() { // Used to save the customer after user clicks save.
-
- var LoggedIn = Parse.User.current(); // * Get the current User state from Parse.
-
- if (LoggedIn) {
-
- // get values from form, validate and save.
- // If unsuccessful, throw up friendly error. If successful, go customers list.
-
- }
- }
-
- function editCustomer() {
-
- }
-
- function updateCustomer() {
-
- }
-
-
-
- </script>
- </body>
- </html>