Merge pull request #170 from supahgreg/hook_params_runtime_loaded

Adding JS hooks for init params and runtime info
master
Andrew Dolgov 12 years ago
commit 712032589c

@ -8,6 +8,8 @@ var PluginHost = {
HOOK_FEED_LOADED: 5, HOOK_FEED_LOADED: 5,
HOOK_ARTICLE_EXPANDED: 6, HOOK_ARTICLE_EXPANDED: 6,
HOOK_ARTICLE_COLLAPSED: 7, HOOK_ARTICLE_COLLAPSED: 7,
HOOK_PARAMS_LOADED: 8,
HOOK_RUNTIME_INFO_LOADED: 9,
hooks: [], hooks: [],
register: function (name, callback) { register: function (name, callback) {
if (typeof(this.hooks[name]) == 'undefined') if (typeof(this.hooks[name]) == 'undefined')

@ -1269,16 +1269,17 @@ function backend_sanity_check_callback(transport) {
if (params) { if (params) {
console.log('reading init-params...'); console.log('reading init-params...');
if (params) {
for (k in params) { for (k in params) {
var v = params[k]; var v = params[k];
console.log("IP: " + k + " => " + v); console.log("IP: " + k + " => " + v);
if (k == "label_base_index") _label_base_index = parseInt(v); if (k == "label_base_index") _label_base_index = parseInt(v);
} }
}
init_params = params; init_params = params;
// PluginHost might not be available on non-index pages
window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, init_params);
} }
sanity_check_done = true; sanity_check_done = true;

@ -753,6 +753,8 @@ function parse_runtime_info(data) {
init_params[k] = v; init_params[k] = v;
notify(''); notify('');
} }
PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data);
} }
function collapse_feedlist() { function collapse_feedlist() {
@ -992,7 +994,7 @@ function handle_rpc_json(transport, scheduled_call) {
if (counters) if (counters)
parse_counters(counters, scheduled_call); parse_counters(counters, scheduled_call);
var runtime_info = reply['runtime-info'];; var runtime_info = reply['runtime-info'];
if (runtime_info) if (runtime_info)
parse_runtime_info(runtime_info); parse_runtime_info(runtime_info);

Loading…
Cancel
Save