http://git-wip-us.apache.org/repos/asf/usergrid-javascript/blob/94020d26/examples/facebook/facebook.html
----------------------------------------------------------------------
diff --git a/examples/facebook/facebook.html b/examples/facebook/facebook.html
new file mode 100755
index 0000000..2ea8943
--- /dev/null
+++ b/examples/facebook/facebook.html
@@ -0,0 +1,73 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Facebook Login Example App for Apigee App Services 
(Usergrid)</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <link rel="stylesheet" href="../resources/css/bootstrap-combined.min.css" 
/>
+    <link rel="stylesheet" href="../resources/css/styles.css" />
+    <script 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"; 
type="text/javascript"></script>
+    <script src="../../usergrid.js" type="text/javascript"></script>
+    <script src="app.js" type="text/javascript"></script>
+    <script src="//connect.facebook.net/en_US/all.js" 
type="text/javascript"></script>
+  </head>
+  <body>
+    <div class="header">
+      <img src="../resources/images/apigee.png"> App Services (Usergrid) 
Javascript SDK
+    </div>
+    <div class="breadcrumb">
+        <a href="../../index.html">&lt;&lt; examples</a>
+      </div>
+    <div class="info">
+      This sample application will show you how to log into App Services 
(Usergrid) using Facebook and the Usergrid Javascript SDK.
+      Enter the <a href="https://developers.facebook.com/apps/";>API Key that 
you get from Facebook</a>, then log in.
+      <br/><br/>
+      The Log in button sends the user to the facebook login page.  Once the 
user logs in, they are redirected back to
+      this page and automatically logged into Usergrid.  If the user is 
already logged into facebook, then they don't need to log in again.
+      <br/><br/>
+      Clicking the log out button calls the logout method of the Facebook JS 
SDK, and also logs the user out of Usergrid by calling the Usergrid 
logoutAppUser method.
+      <br/><br/>
+      For a step by step walk-thru on how to get this app running, see this <a 
href="guide.html">guide</a>.
+      <br/><br/>
+      For more information on App Services, see our <a 
href="http://apigee.com/docs/app_services";>docs</a> site, specifically or our 
<a href="http://apigee.com/docs/usergrid/content/facebook-sign-in";>Facebook 
docs page</a>.
+      <br/><br/>
+      For more information on how using the Facebook JS SDK to log users in, 
see this guide: <a 
href="http://developers.facebook.com/docs/howtos/login/getting-started/";>http://developers.facebook.com/docs/howtos/login/getting-started/</a>
+    </div>
+    <div id="main" class="main">
+      <div class="section-header">Log in with Facebook</div>
+      <div class="well">
+        <div id="name-control" class="control-group">
+          <div class="controls">
+            <label class="control-label" for="get-path">Facebook API key (<a 
href="https://developers.facebook.com"; target="_blank">Learn more</a>)</label>
+            <input type="text" name="api-key" id="api-key" class="span4" 
style="float: left;" value="308790195893570"/>
+            <span class="span4 left" style="width: 10px; float: 
left;">&nbsp;</span>
+            <button class="btn btn-primary" id="login-button" style="width: 
90px;">Log In</button>
+            <button class="btn btn-primary" id="logout-button" style="width: 
90px;">Log out</button>
+            <span style="clear: both;">&nbsp;</span>
+          </div>
+        </div>
+      </div>
+      <div class="section-header"><b>API Response</b></div>
+      <div class="well" id="facebook-status">
+        // Press 'Log in' to log in with Facebook.
+      </div>
+    </div>
+    <div id="fb-root" class=" fb_reset"> </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/usergrid-javascript/blob/94020d26/examples/facebook/guide.html
----------------------------------------------------------------------
diff --git a/examples/facebook/guide.html b/examples/facebook/guide.html
new file mode 100755
index 0000000..725dd9a
--- /dev/null
+++ b/examples/facebook/guide.html
@@ -0,0 +1,63 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE html>
+<html>
+  <head>
+    <title></title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <link rel="stylesheet" href="../resources/css/bootstrap-combined.min.css" 
/>
+    <link rel="stylesheet" href="../resources/css/styles.css" />
+  </head>
+  <body>
+    <div class="header">
+      <img src="../resources/images/apigee.png"> App Services (Usergrid) 
Javascript SDK
+    </div>
+    <div class="info">
+      To get the Facebook example working on your development machine, follow 
these steps:
+      <br/><br/>
+      <b>1. Sign up</b>
+      <br/>Sign up for a <a href="http://facebook.com";>Facebook</a> account.
+      <br/><br/>
+      <b>2. Create a new app</b>
+      <br/>Go to <a 
href="https://developers.facebook.com";>https://developers.facebook.com</a> and 
follow
+      the prompts to authenticate yourself.  Then, go to the Facebook App 
Dashboard, and create a new app.
+      <br/><br/>
+      <b>3. Specify your Facebook integration method</b>
+      <br/>On the app creation page, make sure you specify that you will use 
"Website with Facebook Login".
+      You should see something like <a 
href="http://cl.ly/image/0K2L1z062Q1H";>this</a>. You should enter the url where
+      you will host this sample (e.g. http://mywebsite.com/path-to-my-code). 
If want just to test with our gh-pages repo,
+      located here:  <a 
href="http://apigee.github.com/usergrid-javascript-sdk/";>http://apigee.github.com/usergrid-javascript-sdk/</a>,
+      then enter http://apigee.github.com/usergrid-javascript-sdk in the field 
instead.
+      <br/><br/>
+      <b>4. Get your App Id</b>
+      <br/>Once your app is created, you can get the app id by going here:  <a 
href="https://developers.facebook.com/apps";>https://developers.facebook.com/apps</a>
+      <br/><br/>
+      <b>5. Download this code</b> (skip this step if you plan to run it on 
our gh-pages repo)
+      <br/>If you haven't done so already, download the Usergrid Javascript 
SDK: <a 
href="https://github.com/apigee/usergrid-javascript-sdk";>https://github.com/apigee/usergrid-javascript-sdk</a>
+      and save to a local directory on your hard drive. You will then need to 
deploy the code to your server.
+      <br/><br/>
+      <b>6. Run the file</b>
+      <br/>Navigate your browser to the location where you uploaded your code, 
or go to our gh-pages repo
+      ( <a 
href="http://apigee.github.com/usergrid-javascript-sdk/";>http://apigee.github.com/usergrid-javascript-sdk/</a>)
 and choose "Facebook Login Example".
+      <br/><br/>
+      <b>7. Log in!</b>
+      <br/>Enter your API key, and follow the prompts.
+    </div>
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/usergrid-javascript/blob/94020d26/examples/persistence/test.html
----------------------------------------------------------------------
diff --git a/examples/persistence/test.html b/examples/persistence/test.html
new file mode 100644
index 0000000..3d7c553
--- /dev/null
+++ b/examples/persistence/test.html
@@ -0,0 +1,54 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Readme File Tests</title>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  <link rel="stylesheet" href="../resources/css/bootstrap-combined.min.css" />
+  <link rel="stylesheet" href="../resources/css/styles.css" />
+  <script 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"; 
type="text/javascript"></script>
+  <script src="../../usergrid.js" type="text/javascript"></script>
+  <script src="test.js" type="text/javascript"></script>
+  <script type="text/javascript">
+
+  </script>
+</head>
+<body>
+<div class="header">
+  <img src="../resources/images/apigee.png"> App Services (Usergrid) 
Javascript SDK
+</div>
+<div class="info">
+  This sample application runs tests to demonstrate how to persist collections 
using the collection.serialize() method.
+</div>
+<div id="main" class="main">
+  <div class="section-header">README sample code tests</div>
+  <div class="well">
+    <div id="name-control" class="control-group">
+      <div class="controls">
+        <button class="btn btn-primary" id="start-button" style="width: 
90px;">Start</button>
+        <span style="clear: both;">&nbsp;</span>
+      </div>
+    </div>
+  </div>
+  <div class="section-header"><b>Test Output</b></div>
+  <div class="well">
+    <pre id="test-output">// Press Start button to begin</pre>
+  </div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/usergrid-javascript/blob/94020d26/examples/persistence/test.js
----------------------------------------------------------------------
diff --git a/examples/persistence/test.js b/examples/persistence/test.js
new file mode 100644
index 0000000..352323a
--- /dev/null
+++ b/examples/persistence/test.js
@@ -0,0 +1,130 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+$(document).ready(function () {
+
+//call the runner function to start the process
+  $('#start-button').bind('click', function() {
+    $('#start-button').attr("disabled", "disabled");
+    $('#test-output').html('');
+    runner(0);
+  });
+
+  var logSuccess = true;
+  var successCount = 0;
+  var logError = true;
+  var errorCount = 0;
+  var logNotice = true;
+
+  var client = new Usergrid.Client({
+    orgName:'yourorgname',
+    appName:'sandbox',
+    logging: true, //optional - turn on logging, off by default
+    buildCurl: true //optional - turn on curl commands, off by default
+  });
+
+  function runner(step, arg, arg2){
+    step++;
+    switch(step)
+    {
+      case 1:
+        notice('-----running step '+step+': create and serialize collection');
+        createAndSerialzeCollection(step);
+        break;
+      case 2:
+        notice('-----running step '+step+': de-serialize collection');
+        deserializeCollection(step);
+        break;
+      default:
+        notice('-----test complete!-----');
+        notice('Success count= ' + successCount);
+        notice('Error count= ' + errorCount);
+        notice('-----thank you for playing!-----');
+        $('#start-button').removeAttr("disabled");
+    }
+  }
+
+//logging functions
+  function success(message){
+    successCount++;
+    if (logSuccess) {
+      console.log('SUCCESS: ' + message);
+      var html = $('#test-output').html();
+      html += ('SUCCESS: ' + message + '\r\n');
+      $('#test-output').html(html);
+    }
+  }
+
+  function error(message){
+    errorCount++
+    if (logError) {
+      console.log('ERROR: ' + message);
+      var html = $('#test-output').html();
+      html += ('ERROR: ' + message + '\r\n');
+      $('#test-output').html(html);
+    }
+  }
+
+  function notice(message){
+    if (logNotice) {
+      console.log('NOTICE: ' + message);
+      var html = $('#test-output').html();
+      html += (message + '\r\n');
+      $('#test-output').html(html);
+    }
+  }
+
+
+  function createAndSerialzeCollection(step){
+    var options = {
+      type:'books',
+      qs:{ql:'order by name'}
+    }
+
+    client.createCollection(options, function (err, books) {
+      if (err) {
+        error('could not make collection');
+      } else {
+
+        //collection made, now serialize and store
+        localStorage.setItem('item', books.serialize());
+
+        success('new Collection created and data stored');
+
+        runner(step);
+
+      }
+    });
+  }
+
+
+  function deserializeCollection(step){
+    var books = client.restoreCollection(localStorage.getItem('item'));
+
+    while(books.hasNextEntity()) {
+      //get a reference to the book
+      book = books.getNextEntity();
+      var name = book.get('name');
+      notice('book is called ' + name);
+    }
+
+    success('looped through books');
+
+    runner(step);
+  }
+
+});
\ No newline at end of file

Reply via email to