Skip to content

Instantly share code, notes, and snippets.

@jonathanbarton
Last active September 13, 2017 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanbarton/54bc75fa7b7fd4b9289180e23ce1ea34 to your computer and use it in GitHub Desktop.
Save jonathanbarton/54bc75fa7b7fd4b9289180e23ce1ea34 to your computer and use it in GitHub Desktop.
dle-config.js
(function(appConfig, pubsub){
var config = (function(){ return <?=json_encode($_GLOBAL['app-config'])?> })() || {};
appConfig.get = function() {
return config;
};
appConfig.set = function(key, value) {
if(config[key]) {
config[key] = value;
pubsub.publish('appConfigUpdated',{ itemKey: key, itemValue: value });
pubsub.publish('appConfigUpdated',{ itemKey: key, itemValue: value }, true); //for cross-frame
} else {
throw new Error('Cannot find existing key ' + key + ' for value ' + value);
}
};
})(this.appConfig, this.pubsub);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment