Permalink
Browse files

using a much simpler method to inject the dynamic <base>

  • Loading branch information...
1 parent b93cc3e commit 415fbef17a594e994e39673fe1c57aeb50e941d0 @erikvold erikvold committed Jun 10, 2012
Showing with 7 additions and 48 deletions.
  1. +3 −6 data/remo-start.html
  2. +0 −29 data/remo-start.js
  3. +3 −12 lib/main.js
  4. +1 −1 package.json
View
@@ -10,23 +10,20 @@
Mozilla Reps Companion
</title>
+ <base href="{ page.baseurl }"/>
+ <link href="remo-start.css" rel="stylesheet"/>
+
<script>
function openAddonsManager() {
var evt = document.createEvent("Events");
evt.initEvent("RemoOpenAddonsManager", true, false);
document.dispatchEvent(evt);
}
- function startAboutReps() {
- var evt = document.createEvent("Events");
- evt.initEvent("StartAboutReps", true, false);
- document.dispatchEvent(evt);
- }
</script>
</head>
<body>
- <script>startAboutReps();</script>
<!-- Wrapper for background -->
<div id="wrapper">
View
@@ -1,29 +0,0 @@
-"use strict";
-
-let baseURLEle = document.createElement("base");
-baseURLEle.setAttribute("href", "");
-
-let link = document.createElement("link");
-link.setAttribute("rel", "stylesheet");
-
-let baseURL;
-
-self.port.on('baseURL', function (url) {
- baseURL = url;
- baseURLEle.setAttribute("href", url);
- link.setAttribute("href", url+"remo-start.css");
-});
-
-document.addEventListener("StartAboutReps", function (e) {
- document.getElementsByTagName("head")[0].appendChild(baseURLEle);
- document.getElementsByTagName("head")[0].appendChild(link);
-
- window.addEventListener("load", function() {
- var imgs = document.getElementsByTagName("img");
- Array.prototype.slice.call(imgs).forEach(function(img) {
- var src = img.getAttribute("src");
- if (src.match(/:/)) return;
- img.setAttribute("src", baseURL+src);
- });
- }, false);
-}, false, true);
View
@@ -67,17 +67,6 @@ pageMod.PageMod(
}
});
-pageMod.PageMod(
-{
- include: [data.url("remo-start.html"), "about:reps"],
- contentScriptWhen: 'start',
- contentScriptFile: data.url("remo-start.js"),
- onAttach: function(worker)
- {
- worker.port.emit('baseURL', self.data.url(""));
- }
-});
-
/* end about:reps */
@@ -129,7 +118,9 @@ exports.main = function(options, callback)
See bugs 759190 and 760233 */
protocol.about('reps', {
onRequest: function(request, response) {
- response.uri = data.url("remo-start.html");
+ response.contentType = "text/html";
+ response.end(data.load("remo-start.html").replace(/\{\s*page\.baseurl\s*\}/, self.data.url("")));
+ return;
}
}).register();
View
@@ -15,5 +15,5 @@
"icon": "data/Remo48.png",
"icon64": "data/Remo64.png",
"homepage": "https://reps.mozilla.org/",
- "dependencies": ["api-utils", "addon-kit", "vold-utils", "protocol"]
+ "dependencies": ["api-utils", "addon-kit", "protocol"]
}

0 comments on commit 415fbef

Please sign in to comment.