Skip to content

Instantly share code, notes, and snippets.

@feedhenry-gists
feedhenry-gists / gist:1019114
Created June 10, 2011 15:50
Security Call cloud
var res = $fh.sec( parameters ); //res will contain an 'error' key if it's failed
@feedhenry-gists
feedhenry-gists / gist:1019111
Created June 10, 2011 15:49
Security call device
$fh.sec( parameters, function(res){
//success callback function. responses are passed into res object
}, function(error){
//failure callback function. error contains the error message
});
@feedhenry-gists
feedhenry-gists / gist:1018908
Created June 10, 2011 14:15
Current Date/Time Cache Client Version
<p> Current Time : </p>
<div id="current_time_response"> </div>
<button id='current_time'> Refresh time </button>
<script>
$(document).ready(function(){
$('#current_time').click(readTime);
});
function readTime() {
@feedhenry-gists
feedhenry-gists / gist:1018747
Created June 10, 2011 12:24
Mash Hash Caching domashup
// Add some test placemarks so cache can be invalidated if required
//mashup.push({type: 'test', title: 'Test 1', lat: 57.5, lon: -7.5});
//mashup.push({type: 'test', title: 'Test 2', lat: 57, lon: -7});
//mashup.push({type: 'test', title: 'Test 3', lat: 57.3, lon: -7.3});
@feedhenry-gists
feedhenry-gists / gist:1018741
Created June 10, 2011 12:21
Mash Hash Caching Invalidating
var CACHE_TIME = 10
@feedhenry-gists
feedhenry-gists / gist:1018738
Created June 10, 2011 12:20
Mash Hash Caching readcache
function readCache() {
var ret = $fh.cache({
"act": "load",
"key": "_cache"
});
return ret.val;
}
@feedhenry-gists
feedhenry-gists / gist:1018735
Created June 10, 2011 12:20
Mash Hash Caching
function doCache(hash, data) {
var obj = {
"hash": hash,
"data": data,
"cached": true
};
$fh.cache({
"act": "save",
"key": "_cache",
"val": obj,
@feedhenry-gists
feedhenry-gists / gist:1018733
Created June 10, 2011 12:19
Mash Hash Cache Hashing getMashUp
function getMashup() {
var response = {};
// Check the cloud cache to see if we have data
var cached = readCache();
// No cahced data in cloud
if( ""=== cached ) {
@feedhenry-gists
feedhenry-gists / gist:1018731
Created June 10, 2011 12:18
Mash Hash Cache Hashing
// Call the server side function to get the mashup data
$fh.act({
act: 'getMashup',
req: {
hash: hash,
timestamp: new Date().getTime()
}
}, function (res) {
var mashup = res;
@feedhenry-gists
feedhenry-gists / gist:1018725
Created June 10, 2011 12:15
Mash Hash Cache DomashUp
function doMashUp() {
var mashup = [];
// Add some test placemarks so cache can be invalidated if required
//mashup.push({type: 'test', title: 'Test 1', lat: 57.5, lon: -7.5});
//mashup.push({type: 'test', title: 'Test 2', lat: 57, lon: -7});
//mashup.push({type: 'test', title: 'Test 3', lat: 57.3, lon: -7.3});
// Get placemarks from flickr
var flickr = getFlickrData();