OLD | NEW |
1 var backgroundPage = chrome.extension.getBackgroundPage(); | 1 var backgroundPage = chrome.extension.getBackgroundPage(); |
2 var require = backgroundPage.require; | 2 var require = backgroundPage.require; |
3 var Prefs = require("prefs").Prefs; | 3 var Prefs = require("prefs").Prefs; |
4 var Utils = require("utils").Utils; | 4 var Utils = require("utils").Utils; |
5 | 5 |
| 6 function extractBaseUrl(url) |
| 7 { |
| 8 return url.split("/").slice(0, 3).join("/"); |
| 9 } |
| 10 |
6 function openSharePopup(url) | 11 function openSharePopup(url) |
7 { | 12 { |
8 var iframe = document.getElementById("share-popup"); | 13 var iframe = document.getElementById("share-popup"); |
9 var glassPane = document.getElementById("glass-pane"); | 14 var glassPane = document.getElementById("glass-pane"); |
10 var popupMessageReceived = false; | 15 var popupMessageReceived = false; |
11 | 16 |
12 var popupMessageListener = function(event) | 17 var popupMessageListener = function(event) |
13 { | 18 { |
14 if (event.origin !== url) | 19 if (event.origin !== extractBaseUrl(url)) |
15 return; | 20 return; |
16 | 21 |
17 iframe.width = event.data.width; | 22 iframe.width = event.data.width; |
18 iframe.height = event.data.height; | 23 iframe.height = event.data.height; |
19 popupMessageReceived = true; | 24 popupMessageReceived = true; |
20 window.removeEventListener("message", popupMessageListener); | 25 window.removeEventListener("message", popupMessageListener); |
21 }; | 26 }; |
22 window.addEventListener("message", popupMessageListener, false); | 27 window.addEventListener("message", popupMessageListener, false); |
23 | 28 |
24 var popupLoadListener = function() | 29 var popupLoadListener = function() |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 119 } |
115 } | 120 } |
116 } | 121 } |
117 | 122 |
118 function getDocLink(page, anchor) | 123 function getDocLink(page, anchor) |
119 { | 124 { |
120 return Prefs.documentation_link | 125 return Prefs.documentation_link |
121 .replace(/%LINK%/g, page) | 126 .replace(/%LINK%/g, page) |
122 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : ""
); | 127 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : ""
); |
123 } | 128 } |
OLD | NEW |