Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
74 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
(function() { | ||
chrome.browserAction.onClicked.addListener(function(tab) { | ||
chrome.browserAction.onClicked.addListener(function(tab) { | ||
return chrome.tabs.executeScript(null, { | ||
file: "jquery-1.6.4.min.js" | ||
}, function() { | ||
return chrome.tabs.executeScript(null, { | ||
file: "content_script.js" | ||
}); | ||
}); | ||
chrome.extension.onConnect.addListener(function(port) { | ||
return port.onMessage.addListener(function(info) { | ||
var lat, ll, lng, param, socket, _ref; | ||
socket = io.connect('http://localhost:3000'); | ||
if (info.isMap) { | ||
param = {}; | ||
info.url.split('&').forEach(function(q) { | ||
var kv; | ||
kv = q.split('=', 2); | ||
return param[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1]); | ||
}); | ||
ll = param['ll'] || param['sll']; | ||
_ref = ll.split(','), lat = _ref[0], lng = _ref[1]; | ||
return socket.emit('fireEvent:openMap', { | ||
latitude: lat, | ||
longitude: lng | ||
}); | ||
} else { | ||
return socket.emit('fireEvent:openUrl', { | ||
url: info.url | ||
}); | ||
} | ||
}); | ||
}); | ||
chrome.extension.onConnect.addListener(function(port) { | ||
return port.onMessage.addListener(function(info) { | ||
var lat, ll, lng, param, socket, _ref; | ||
socket = io.connect('http://localhost:3000'); | ||
if (info.isMap) { | ||
param = {}; | ||
info.url.split('&').forEach(function(q) { | ||
var kv; | ||
kv = q.split('=', 2); | ||
return param[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1]); | ||
}); | ||
ll = param['ll'] || param['sll']; | ||
_ref = ll.split(','), lat = _ref[0], lng = _ref[1]; | ||
return socket.emit('fireEvent:openMap', { | ||
latitude: lat, | ||
longitude: lng | ||
}); | ||
} else { | ||
return socket.emit('fireEvent:openUrl', { | ||
title: info.title, | ||
url: info.url, | ||
image: info.image | ||
}); | ||
} | ||
}); | ||
}).call(this); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
(function() { | ||
var link, pageInfo; | ||
pageInfo = { | ||
url: document.location.href, | ||
title: document.title, | ||
selection: window.getSelection().toString(), | ||
isMap: false | ||
}; | ||
if (pageInfo.url.match(/^http[s]?:\/\/maps\.google\./)) { | ||
link = document.getElementById('link'); | ||
if (link && link.href) { | ||
pageInfo.url = link.href; | ||
pageInfo.isMap = true; | ||
} | ||
var link, og, pageInfo; | ||
pageInfo = { | ||
url: document.location.href, | ||
title: document.title, | ||
selection: window.getSelection().toString(), | ||
isMap: false, | ||
image: null | ||
}; | ||
if (pageInfo.url.match(/^http[s]?:\/\/maps\.google\./)) { | ||
link = document.getElementById('link'); | ||
if (link && link.href) { | ||
pageInfo.url = link.href; | ||
pageInfo.isMap = true; | ||
} | ||
chrome.extension.connect().postMessage(pageInfo); | ||
}).call(this); | ||
} | ||
og = {}; | ||
$('meta[property^="og:"]').each(function() { | ||
return og[$(this).attr('property').match(/og:(.+)$/)[1]] = $(this).attr('content'); | ||
}); | ||
if (og.image) { | ||
pageInfo.image = og.image; | ||
} | ||
chrome.extension.connect().postMessage(pageInfo); |
Large diffs are not rendered by default.
Oops, something went wrong.