This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFlickrData() { | |
var response = []; | |
var param = { | |
url: "http://www.flickr.com/services/rest/", | |
method: "POST", | |
charset: "UTF-8", | |
contentType: "application/x-www-form-urlencoded", | |
body: "method=flickr.photos.search&api_key=" + FLICKR_API_KEY + "&sort=interestingness-desc&place_id=2367105&extras=geo%2Cmedia&per_page=" + FLICKR_LIMIT + "&format=json&nojsoncallback=1" | |
} | |
var res = $fh.web(param); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initLanguages(){ | |
// Try 1. Get from cloud | |
$fh.act({ | |
act: 'buildLanguages' | |
}, function (result) { | |
lang = result; | |
$fh.data( {act:'save', key:'lang', val:JSON.stringify(lang)} ); | |
updateLanguage(def); | |
}, function (code, errorprops, params) { | |
// Try 2. Failed to get lang from server. Probably offline - grab from our local datastore. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildLanguages(){ | |
// Wrapper function - the scope of utils_lang_shared functions is private | |
return buildAllLanguages(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var languages = ["en_gb", "en_us", "en_ie", "fr"]; | |
var def = "en_gb"; // default language |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Language picker code --> | |
<script type="text/javascript" src="js/utils_lang.js"></script> | |
<!-- Includes from Shared --> | |
<script type="text/javascript" src="lang/en_gb.js"></script> | |
<script type="text/javascript" src="lang/en_ie.js"></script> | |
<script type="text/javascript" src="lang/en_us.js"></script> | |
<script type="text/javascript" src="lang/fr.js"></script> | |
<script type="text/javascript" src="utils_lang_shared.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="fh_lang"> | |
<label for="fh_lang_picker" id="label_language"></label> | |
<select id="fh_lang_picker" onchange="changeLanguage(this)"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initLanguages(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initLanguages(){ | |
lang = buildAllLanguages(); // Set the global variable to our built languages | |
updateLanguage(def); // Update the language for the first time to our default | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateLanguage(l){ | |
var newLanguage = lang[l]; // Look up the required language in our global | |
for (id in newLanguage){ // Iterate over key and value pairs | |
if (newLanguage.hasOwnProperty(id)){ | |
$("#" + id).html(newLanguage[id]); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementById("app_heading").innerHTML = "Hello"; |