|
<body> |
|
<nav class="navbar navbar-inverse navbar-fixed-top"><div class="container"> <div class="navbar-header"><a class="navbar-brand" href="https://github.com/thingdomio/thingdom-js">Thingdom-JS Example</a> </div><div id="navbar" class="navbar-collapse collapse"></div> </nav> |
|
|
|
<div class="container"> |
|
|
|
<div id="thingdom" class="panel panel-default"> |
|
<div class="hidden panel-heading"><h2 class="panel-title">Real Codes Already?</h2></div> |
|
<div class="panel-body"> |
|
<p><strong>Step One: Authenticate and initialize Thingdom</strong></p> |
|
<p>You'll want to instantiate a new Thingdom object by passing in your API Secret:</p> |
|
<pre>var thingdom = new Thingdom( 'EnterYourAPISecretHere' );</pre> |
|
<p>This instantiates a new Thingdom object:</p> |
|
<p><a id="newThingdom" class="btn btn-success" href="#" role="button">Try It</a></p> |
|
<pre id="newThingdomResult" class="pre-scrollable">New <var>thingdom</var> value is displayed here</pre> |
|
</div> <!-- .panel-body --> |
|
</div> <!-- #thingdom .panel.panel-default --> |
|
|
|
<hr> |
|
|
|
<div id="thing" class="panel panel-default"> |
|
<div class="panel-body"> |
|
<p><strong>Step Two: Create or get your Thing</strong></p> |
|
<p>You'll need to call your Thing with its name and a product type and pass in a callback from within your scope.</p> |
|
<p>In practice that looks a little like this:</p> |
|
<pre class="pre-scrollable">var thing; thingdom.getThing( 'Example Thing', 'javascript_example', function( newThing ) { thing = newThing } );</pre> |
|
<p><small>This is fine as an example but you should definitely try to use patterns, methods, and variables that make sense for your own code.</small></p> |
|
<p><a id="newThing" class="btn btn-success" href="#" role="button">Try It</a></p>. |
|
<pre id="newThingResult" class="pre-scrollable">New <var>thing</var> value is displayed here</pre> |
|
</div> <!-- .panel-body --> |
|
</div> <!-- #thing .panel.panel-default --> |
|
|
|
<hr> |
|
|
|
<div id="feed" class="panel panel-default"> |
|
<div class="panel-body"> |
|
<p><strong>Step Three: Post a feed to your Thing</strong></p> |
|
<p class="well well-sm">Before you continue you should download the <a href="https://itunes.apple.com/us/app/thingdom/id807761969?mt=8" target="_blank">iOS <i class="fa fa-apple"></i></a> or <a href="https://play.google.com/store/apps/details?id=com.thingdom.mobile" target="_blank">Android <i class="fa fa-android"></i></a> apps onto your device(s) of choice. To really appreciate the <em>magic</em> of what's about to happen, it helps a lot to see all this happen on a device in front of you. Once you launch Thingdom Mobile the first time you should be prompted to enter a Thing code.</p> |
|
<p class="hidden">To get the Thng Code from the Thing this example is using, click Show Code.</p> |
|
<div class="well btn-group btn-group-justified"> |
|
<a id="showThingCode" class="btn btn-default btn-primary" href="#" role="button">Show Code</a> |
|
<a id="thingCodeNode" class="btn btn-default" role="button"><span class="text-muted">Thing Code</span></a> |
|
</div> |
|
<pre class="pre-scrollable">thing.feed( "Example feed message...", "js_web_feed" );</pre> |
|
<p>When you click Try It you'll trigger a feed message.</p> |
|
<p><a id="postDefaultFeed" class="btn btn-success" href="#" role="button">Try It</a></p> |
|
<pre id="defaultFeedResult" class="pre-scrollable">...</pre> |
|
<p>Try passing in your own input:</p> |
|
<div class="input-group"> |
|
<input id="customFeedString" type="text" placeholder="Stick some text in here..." class="form-control"> |
|
<span class="input-group-btn"> |
|
<a id="postCustomFeed" class="btn btn-default" role="button">Custom Message</a> |
|
</span> |
|
</div> |
|
<pre id="customFeedResult" class="pre-scrollable">...</pre> |
|
</div> <!-- .panel-body --> |
|
</div> <!-- #feed .panel.panel-default --> |
|
|
|
<hr> |
|
|
|
<div id="status" class="panel panel-default"> |
|
<div class="panel-body"> |
|
<p><strong>Step 4: Update your Thing's Status</strong></p> |
|
<pre class="pre-scrollable">thing.status( "js_web_status", "online" );</pre> |
|
<p>Click Try It to update your Thing's status to <span class="text-success text-muted">online</span></p> |
|
<p><a id="postOnlineStatus" class="btn btn-success" href="#" role="button">Try It</a></p> |
|
<pre id="onlineStatusResult" class="pre-scrollable">...</pre> |
|
<pre class="pre-scrollable">thing.status( "js_web_status", "offline" );</pre> |
|
<p>Click Try It to update your Thing's status to <span class="text-info text-muted">offline</span></p> |
|
<p><a id="postOfflineStatus" class="btn btn-success" href="#" role="button">Try It</a></p> |
|
<pre id="offlineStatusResult" class="pre-scrollable">...</pre> |
|
</div> <!-- .panel-body --> |
|
</div> <!-- #status .panel.panel-default --> |
|
|
|
<hr> |
|
|
|
<div id="resources" class="panel panel-primary"> |
|
<div class="panel-heading"><h2 class="panel-title">Resources</h2></div> |
|
<div class="panel-body"> |
|
<p>Here are some links to resources to help you understand both what Thingdom is.</p> |
|
<div class="list-group"> |
|
<a class="list-group-item" href="https://thingdom.io" target="_blank"> |
|
<h4 class="list-group-item-heading">Thingdom Website</h4> |
|
<span class="list-group-item-text">Learn about <em>what</em> Thingdom is and how it works. Most of the links below can be found there as well a links to our apps on iTunes and Google Play.</span> |
|
</a> |
|
<a class="list-group-item" href="https://dev.thingdom.io/" target="_blank"> |
|
<h4 class="list-group-item-heading">Thingdom Developer Portal</h4> |
|
<span class="list-group-item-text">Once you have signed up for your free Thingdom account, the developer portal allows you to define your own thing product types, status types, and feed types. <strong class="text-danger">Signing up</strong> is crucial to get YOUR OWN API Secret to use within your own project.</span> |
|
</a> |
|
<a class="list-group-item" href="https://dev.thingdom.io/docs/api/1.1/" target="_blank"> |
|
<h4 class="list-group-item-heading">Thingdom REST API Documentation</h4> |
|
<span class="list-group-item-text">Learn about how to communicate with the Thingdom API. There are examples that you can try out on your own using the online REST client hurl.it</span> |
|
</a> |
|
<a class="list-group-item" href="https://github.com/thingdomio" target="_blank"> |
|
<h4 class="list-group-item-heading">Thingdom GitHub Page</h4> |
|
<span class="list-group-item-text">Repositories for all the opensource Thingdom wrappers and examples.</span> |
|
</a> |
|
<a class="list-group-item" href="https://github.com/thingdomio/thingdom-js" target="_blank"> |
|
<h4 class="list-group-item-heading">Official Thingdom-JS Wrapper</h4> |
|
<span class="list-group-item-text">The Thingdom-JS wrapper that will be used in this example today</span> |
|
</a> |
|
</div> <!-- / .list-group --> |
|
</div> <!-- / .panel-body --> |
|
</div> <!-- / #resources .panel.panel-primary --> |
|
|
|
<hr> |
|
|
|
</div> |
|
</body> |