aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Rob <rob.manea@gmail.com>2009-11-30 17:48:03 +0100
committerGravatar Rob <rob.manea@gmail.com>2009-11-30 17:48:03 +0100
commit6c25bcb44b4f273b892a4c4bcc4ecb27d1a93d9b (patch)
tree26b8530a7364d3445f4e2bbf45c48f4ff04e364a /examples
parent03b9e4bcea04790d0ddadf671b41484ff6a3e90c (diff)
added scroll-percentage.js and config example
Diffstat (limited to 'examples')
-rw-r--r--examples/config/uzbl/config4
-rw-r--r--examples/data/uzbl/scripts/scroll-percentage.js68
2 files changed, 71 insertions, 1 deletions
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index 35a051b..2f3218a 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -45,6 +45,7 @@ set new_window = sh 'uzbl-browser -u $8' # equivalent to the default beh
# Load commit handler
@on_event LOAD_COMMIT @set_status <span foreground="green">recv</span>
+@on_event LOAD_COMMIT script @scripts_dir/scroll-percentage.js
# Load finish handlers
@on_event LOAD_FINISH @set_status <span foreground="gold">done</span>
@@ -79,12 +80,13 @@ set hint_style = weight="bold"
set mode_section = <span background="khaki" foreground="black">[\@[\@mode_indicator]\@]</span>
set keycmd_section = [<span \@prompt_style>\@[\@keycmd_prompt]\@</span><span \@modcmd_style>\@modcmd</span><span \@keycmd_style>\@keycmd</span><span \@completion_style>\@completion_list</span>]
set progress_section = <span foreground="#606060">\@[\@progress_format]\@</span>
+set scroll_section = <span foreground="#606060">\@[[\@scroll_message]]\@</span>
set uri_section = <span foreground="#99FF66">\@[\@uri]\@</span>
set name_section = <span foreground="khaki">\@[\@NAME]\@</span>
set status_section = <span foreground="orange">\@status_message</span>
set selected_section = <span foreground="#606060">\@[\@SELECTED_URI]\@</span>
-set status_format = <span font_family="monospace">@mode_section @keycmd_section @progress_section @uri_section @name_section @status_section @selected_section</span>
+set status_format = <span font_family="monospace">@mode_section @keycmd_section @progress_section @scroll_section @uri_section @name_section @status_section @selected_section</span>
# Progress bar config
@progress width = 8
diff --git a/examples/data/uzbl/scripts/scroll-percentage.js b/examples/data/uzbl/scripts/scroll-percentage.js
new file mode 100644
index 0000000..c9a51aa
--- /dev/null
+++ b/examples/data/uzbl/scripts/scroll-percentage.js
@@ -0,0 +1,68 @@
+// VIM ruler style scroll message
+(function() {
+ var run = Uzbl.run;
+ var update_message = function() {
+ var innerHeight = window.innerHeight;
+ var scrollY = window.scrollY;
+ var height = document.height;
+ var message;
+
+ if (UzblZoom.type === "full") {
+ var zoom_level = UzblZoom.level;
+ innerHeight = Math.ceil(innerHeight * zoom_level);
+ scrollY = Math.ceil(scrollY * zoom_level);
+ height -= 1;
+ }
+
+ if (! height) {
+ message = "";
+ }
+ else if (height <= innerHeight) {
+ message = run("print @scroll_all_indicator") || "All";
+ }
+ else if (scrollY === 0) {
+ message = run("print @scroll_top_indicator") || "Top";
+ }
+ else if (scrollY + innerHeight >= height) {
+ message = run("print @scroll_bottom_indicator") || "Bot";
+ }
+ else {
+ var percentage = Math.round(scrollY / (height - innerHeight) * 100);
+ message = percentage + "%";
+ }
+ run("set scroll_message=" + message);
+ };
+
+ self.UzblZoom = {
+ get level() {
+ return Number(run("print @zoom_level")) || 1;
+ },
+ set level(level) {
+ if (typeof level === "number" && level > 0) {
+ run("set zoom_level = " + level);
+ update_message();
+ }
+ },
+ get type() {
+ return run("print @zoom_type") || "text";
+ },
+ set type(type) {
+ if ((type === "text" || type === "full") && this.type != type) {
+ run("toggle_zoom_type");
+ run("set zoom_type = " + type);
+ update_message();
+ }
+ },
+ toggle_type: function() {
+ this.type = (this.type === "text" ? "full" : "text");
+ }
+ };
+
+ window.addEventListener("DOMContentLoaded", update_message, false);
+ window.addEventListener("load", update_message, false);
+ window.addEventListener("resize", update_message, false);
+ window.addEventListener("scroll", update_message, false);
+ update_message();
+})();
+
+// vim: set noet ff=unix