Last active
September 13, 2017 12:44
-
-
Save jonathanbarton/54bc75fa7b7fd4b9289180e23ce1ea34 to your computer and use it in GitHub Desktop.
dle-config.js
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(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