Display in the mode-line that Javascript is enabled, to warn user.
This is accomplished by having a global variable have access to the mode_line
update function, and having that global invoked upon change. I made some
attempt to do this by using:
global_update_mode_line_for_javascript =
function () { watch_pref("javascript.enabled", obj.do_update);};
However, I couldn't figure out where to call that so that it always worked at
the right moment. This solution is probably simpler in the end.
This commit is contained in:
parent
26d3da217c
commit
c7186c1fbb
1 changed files with 36 additions and 3 deletions
37
conkerorrc
37
conkerorrc
|
|
@ -44,7 +44,41 @@ session_auto_save_file = "auto-save-session.conkeror";
|
||||||
hints_auto_exit_delay = 400;
|
hints_auto_exit_delay = 400;
|
||||||
hints_ambiguous_auto_exit_delay = 2000;
|
hints_ambiguous_auto_exit_delay = 2000;
|
||||||
|
|
||||||
|
// require("noscript");
|
||||||
|
// While we wait for noscript support to be fixed:
|
||||||
// C-j toggles Javascript support on and off, displays status of it in minibuffer
|
// C-j toggles Javascript support on and off, displays status of it in minibuffer
|
||||||
|
|
||||||
|
// The below first creates a mode_line_hook to always display in the modeline if
|
||||||
|
// Javascript is enabled.
|
||||||
|
|
||||||
|
require("pref");
|
||||||
|
var global_update_mode_line_for_javascript;
|
||||||
|
var global_watch_mode_line_for_javascript;
|
||||||
|
|
||||||
|
function javascript_status_widget (window) {
|
||||||
|
this.class_name = "javascript-status-widget";
|
||||||
|
text_widget.call(this, window);
|
||||||
|
var obj = this;
|
||||||
|
this.do_update = function () {
|
||||||
|
obj.update();
|
||||||
|
watch_pref("javascript.enabled", obj.do_update);
|
||||||
|
}
|
||||||
|
global_update_mode_line_for_javascript =
|
||||||
|
function () { obj.do_update();};
|
||||||
|
global_watch_mode_line_for_javascript =
|
||||||
|
function () { watch_pref("javascript.enabled", obj.do_update);};
|
||||||
|
global_watch_mode_line_for_javascript();
|
||||||
|
}
|
||||||
|
javascript_status_widget.prototype = {
|
||||||
|
constructor: javascript_status_widget,
|
||||||
|
__proto__: text_widget.prototype,
|
||||||
|
update: function () {
|
||||||
|
this.view.text = (get_pref("javascript.enabled")) ?
|
||||||
|
"Javascript: ENABLED!" : "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
add_hook("mode_line_hook", mode_line_adder(javascript_status_widget), true);
|
||||||
|
// Then, the maps C-j to toggle javascript on and off.
|
||||||
interactive("toggle-js", "toggle javascript",
|
interactive("toggle-js", "toggle javascript",
|
||||||
function (I) {
|
function (I) {
|
||||||
var js_pref = "javascript.enabled";
|
var js_pref = "javascript.enabled";
|
||||||
|
|
@ -52,7 +86,6 @@ interactive("toggle-js", "toggle javascript",
|
||||||
js_val = ! js_val;
|
js_val = ! js_val;
|
||||||
session_pref(js_pref, js_val);
|
session_pref(js_pref, js_val);
|
||||||
I.window.minibuffer.show("JavaScript Status: " + (js_val ? "on" : "off"));
|
I.window.minibuffer.show("JavaScript Status: " + (js_val ? "on" : "off"));
|
||||||
|
global_update_mode_line_for_javascript();
|
||||||
});
|
});
|
||||||
define_key(default_global_keymap, "C-j", "toggle-js");
|
define_key(default_global_keymap, "C-j", "toggle-js");
|
||||||
|
|
||||||
// require("noscript");
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue