media_scrape_default: use js object instead of string_hashset
[conkeror/arlinius.git] / modules / page-modes / google-maps.js
blob8567d26c99ff2875b44d36719255115fa54c9ac2
1 /**
2  * (C) Copyright 2009-2011 John J. Foerch
3  *
4  * Use, modification, and distribution are subject to the terms specified in the
5  * COPYING file.
6 **/
8 require("content-buffer.js");
10 function dom_click_xpath (doc, xpath) {
11     var iter = doc.evaluate(xpath,
12                             doc,
13                             xpath_lookup_namespace,
14                             Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE ,
15                             null);
16     var node = iter.singleNodeValue;
17     if (node) {
18         var rect = node.getBoundingClientRect();
19         dom_node_click(node, rect.left + 1, rect.top + 1);
20     }
23 interactive("google-maps-zoom-in",
24     "Zoom in on a google map",
25     function (I) {
26         dom_click_xpath(I.buffer.document,
27                         "//div[@guidedhelpid='zoom_in']/div[@title]");
28     });
30 interactive("google-maps-zoom-out",
31     "Zoom out on a google map",
32     function (I) {
33         dom_click_xpath(I.buffer.document,
34                         "//div[@guidedhelpid='zoom_out']/div[@title]");
35     });
37 interactive("google-maps-pan-left",
38     "Pan a google map left",
39     function (I) {
40         dom_click_xpath(I.buffer.document,
41                         "//div[@log='pan_lt']");
42     });
44 interactive("google-maps-pan-right",
45     "Pan a google map right",
46     function (I) {
47         dom_click_xpath(I.buffer.document,
48                         "//div[@log='pan_rt']");
49     });
51 interactive("google-maps-pan-up",
52     "Pan a google map up",
53     function (I) {
54         dom_click_xpath(I.buffer.document,
55                         "//div[@log='pan_up']");
56     });
58 interactive("google-maps-pan-down",
59     "Pan a google map down",
60     function (I) {
61         dom_click_xpath(I.buffer.document,
62                         "//div[@log='pan_down']");
63     });
65 define_keymap("google_maps_keymap", $display_name = "google-maps");
66 define_key(google_maps_keymap, "C-c +",   "google-maps-zoom-in");
67 define_key(google_maps_keymap, "C-c -",   "google-maps-zoom-out");
68 define_key(google_maps_keymap, "C-f", "google-maps-pan-right");
69 define_key(google_maps_keymap, "C-b", "google-maps-pan-left");
70 define_key(google_maps_keymap, "C-n", "google-maps-pan-down");
71 define_key(google_maps_keymap, "C-p", "google-maps-pan-up");
73 define_keymaps_page_mode("google-maps-mode",
74     build_url_regexp($domain = "maps.google"),
75     { normal: google_maps_keymap },
76     $display_name = "Google Maps");
78 page_mode_activate(google_maps_mode);
80 provide("google-maps");