* added README
* do name->URL conversion in the popup
* define functions before they are added as listeners
This commit is contained in:
Will Bamberg
2016-01-19 15:15:59 -08:00
parent 5f58a9f23b
commit d552033b78
3 changed files with 51 additions and 8 deletions
+7 -6
View File
@@ -1,8 +1,3 @@
/*
Assign beastify() as a listener for messages from the extension.
*/
chrome.runtime.onMessage.addListener(beastify);
/*
beastify():
* removes every node in the document.body,
@@ -11,7 +6,7 @@ beastify():
*/
function beastify(request, sender, sendResponse) {
removeEverything();
insertBeast(beastNameToURL(request.beast));
insertBeast(request.beastURL);
chrome.runtime.onMessage.removeListener(beastify);
}
@@ -36,6 +31,12 @@ function insertBeast(beastURL) {
document.body.appendChild(beastImage);
}
/*
Assign beastify() as a listener for messages from the extension.
*/
chrome.runtime.onMessage.addListener(beastify);
/*
Given the name of a beast, get the URL to the corresponding image.
*/