Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Resources
- * Implements the javascript access to the phonegap plugin for retrieving specific resource information
- * Based in original resources from Olivier Brand. Tested in Cordova 2.0
- * @version 1.0
- * @author Luis Balam
- * Modified for Blackberry
- */
- /**
- * @return the Resources class instance
- */
- var LocalResources = function() {
- };
- /**
- * Returns the named resources defined in R.strings Note the last parameter,
- * this method is synchronous
- *
- * @param successCallback
- * The callback which will be called when directory listing is
- * successful
- * @param failureCallback
- * The callback which will be called when directory listing encouters
- * an error
- */
- LocalResources.prototype.getStrings = function(params, successCallback, failureCallback) {
- if (failureCallback == null) { failureCallback = function() {}; };
- if (typeof failureCallback != "function") {
- failureCallback = function(){};
- }
- if (typeof successCallback != "function") {
- successCallback = function(){};
- }
- //read xml
- var xFile = "../res/values/strings.xml";
- var arrRs = {};
- arrRs["SYSTEM_LANG"] = "en";
- $.ajax({
- url:xFile, // relative path to www folder
- type:"get",
- contentType:"xml",
- success: function(xml){
- //todo:
- //read nodes string
- $(xml).find("string").each(function()
- {
- arrRs[$(this).attr("name")] = $(this).text();
- });
- //execute the function
- successCallback(arrRs);
- }
- });
- };
- if(!window.plugins) {
- window.plugins = {};
- }
- if (!window.plugins.resources) {
- window.plugins.resources = new LocalResources();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement