Removing dependency on Ruby #39

Closed
wants to merge 2 commits into
from
View
23 ext/background.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ </head>
+ <body>
+ <script>
+ function onRequest(request, sender, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function(data) {
+ if (xhr.readyState == 4) {
+ // xhr.status is 0, not 200. Weird. But, works. So, not checking it.
+ callback(xhr.responseText);
+ }
+ }
+
+ xhr.open('GET', request.url, true);
+ xhr.send();
+ };
+
+ chrome.extension.onRequest.addListener(onRequest);
+ </script>
+ </body>
+</html>
View
20 ext/dotjs.js
@@ -1,10 +1,10 @@
-$.ajax({
- url: 'http://localhost:3131/'+window.location.host.replace('www.','')+'.js',
- dataType: 'text',
- success: function(d){
- $(function(){ eval(d) })
- },
- error: function(){
- console.log('no dotjs server found at localhost:3131')
- }
-})
+function apply(file) {
+ var pathToScript = chrome.extension.getURL("scripts/" + file);
+
+ console.log("dotjs fetching: " + pathToScript)
+ chrome.extension.sendRequest({'action': 'fetchScript', 'url': pathToScript},
+ function(script) { if (script != null && script != "") { eval(script); } });
+}
+
+apply("default.js");
+apply(window.location.host + ".js");
View
1 ext/manifest.json
@@ -4,6 +4,7 @@
"description": "~/.js",
"icons": { "48": "icon48.png",
"128": "icon128.png" },
+ "background_page" : "background.html",
"content_scripts": [{
"run_at": "document_start",
"matches": ["http://*/*", "https://*/*"],
View
0 ext/scripts/default.js
No changes.
View
60 link_info.html
@@ -0,0 +1,60 @@
+<html>
+ <head>
+ <title>Symbolic link information for dotjs</title>
+ <style type="text/css">
+ .info { white-space: pre; opacity: 0.2; font-size: 0.5em; }
+ .show { opacity: 1; font-size: 1em; }
+ </style>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
+
+ <script type="text/javascript">
+ function showInstructionsForOs() {
+ detect("Win", "windows");
+ detect("Mac", "mac");
+ detect("Linux", "linux");
+
+ }
+
+ function detect(osSubstring, idOfOSToShow) {
+ if (navigator.platform.indexOf(osSubstring) != -1) {
+ $("#" + idOfOSToShow).toggleClass("show");
+ $("#other").toggleClass("show");
+ }
+ }
+
+ window.onload = showInstructionsForOs;
+ </script>
+ </head>
+ <body>
+ <div id="mac" class="info">
+ It looks like you're using a Mac. Here's the location of the scripts directory for dotjs:
+ ~/Library/Application Support/Google/Chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts
+
+ You can use the Terminal application to create a symbolic link to it using:
+ ln -s ~/Library/Application\ Support/Google/Chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts/ ~/.js
+ </div>
+
+ <div id="linux" class="info">
+ It looks like you're using Linux. Here's the location of the scripts directory for dotjs:
+ ~/.config/google-chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts
+
+ You can use a terminal client to create a symbolic link to it using:
+ ln -s ~/.config/google-chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts/ ~/.js
+ </div>
+
+ <div id="windows" class="info">
+ It looks like you're using Windows. Here's the location of the scripts directory for dotjs:
+ C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Extensions\fcmioojcnohimpgepefmdndlejgghdni\1.3_3\scripts\
+
+ Please edit your dotjs scripts there.
+ </div>
+
+ <div id="other" class="info show">
+ Unable to find any information about your operating system. Use the link below to find the Chrome user data directory
+ on your system and go to:
+ USER-DATA-DIRECTORY/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts/
+ </div>
+
+ <span class="info show">For more information, see <a href="http://www.chromium.org/user-experience/user-data-directory">this page</a></span>
+ </body>
+</html>