diff options
| author | Daniel MacDougall | 2012-08-18 22:58:15 -0700 | 
|---|---|---|
| committer | Daniel MacDougall | 2012-08-18 22:58:20 -0700 | 
| commit | a3fb35be007a44e5ba35e5ee9d75af3634bf5dac (patch) | |
| tree | b6a81e3e09d77e32d4f36ea2eec210a50235e781 | |
| parent | c21b62e9d1645dc09af7e8a57761e57e3bb7c49d (diff) | |
| download | vimium-a3fb35be007a44e5ba35e5ee9d75af3634bf5dac.tar.bz2 | |
Move inline popup javascript to popup.js
| -rw-r--r-- | popup.html | 141 | ||||
| -rw-r--r-- | popup.js | 20 | 
2 files changed, 82 insertions, 79 deletions
| @@ -1,79 +1,62 @@ -<style> -  * { -    margin: 0px; -    padding: 0px; -  } - -  #vimiumPopup { width: 300px; } - -  #excludeControls { -    padding: 10px; -  } - -  #popupInput { -    width: 160px; -  } - -  #excludeConfirm { -    display: inline-block; -    width: 18px; -    height: 13px; -    background: url(icons/check.png) 3px 2px no-repeat; -    display: none; -  } - -  #popupButton { margin-left: 10px; } - -  #popupMenu ul { -    list-style: none; -  } - -  #popupMenu a, #popupMenu a:active, #popupMenu a:visited { -    color: #3F6EC2; -    display: block; -    border-top: 1px solid #DDDDDD; -    padding: 3px; -    padding-left: 10px; -  } - -  #popupMenu a:hover { -    background: #EEEEEE; -  } -</style> - -<div id="vimiumPopup"> -  <div id="excludeControls"> -    <input id="popupInput" type="text" /> -    <input id="popupButton" type="button" value="Exclude URL" /> -    <span id="excludeConfirm"></span> -  </div> - -  <div id="popupMenu"> -    <ul> -      <li><a id="optionsLink" target="_blank">Options</a></li> -    </ul> -  </div> -</div> - - -<script type="text/javascript"> -  function onLoad() { -    document.getElementById("optionsLink").setAttribute("href", chrome.extension.getURL("options.html")); -    chrome.tabs.getSelected(null, function(tab) { -      // The common use case is to disable Vimium at the domain level. -      // This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html". -      var domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) || tab.url; -      document.getElementById("popupInput").value = domain + "*"; -    }); -  } - -  function onExcludeUrl(e) { -    var url = document.getElementById("popupInput").value; -    chrome.extension.getBackgroundPage().addExcludedUrl(url); -    document.getElementById("excludeConfirm").setAttribute("style", "display: inline-block"); -  } - -  window.addEventListener("load", onLoad, false); -  document.getElementById("popupButton").addEventListener("click", onExcludeUrl, false); -</script> - +<html> +  <head> +    <style> +      * { +        margin: 0px; +        padding: 0px; +      } + +      #vimiumPopup { width: 300px; } + +      #excludeControls { +        padding: 10px; +      } + +      #popupInput { +        width: 160px; +      } + +      #excludeConfirm { +        display: inline-block; +        width: 18px; +        height: 13px; +        background: url(icons/check.png) 3px 2px no-repeat; +        display: none; +      } + +      #popupButton { margin-left: 10px; } + +      #popupMenu ul { +        list-style: none; +      } + +      #popupMenu a, #popupMenu a:active, #popupMenu a:visited { +        color: #3F6EC2; +        display: block; +        border-top: 1px solid #DDDDDD; +        padding: 3px; +        padding-left: 10px; +      } + +      #popupMenu a:hover { +        background: #EEEEEE; +      } +    </style> +    <script src="popup.js"></script> +  </head> +  <body> +    <div id="vimiumPopup"> +      <div id="excludeControls"> +        <input id="popupInput" type="text" /> +        <input id="popupButton" type="button" value="Exclude URL" /> +        <span id="excludeConfirm"></span> +      </div> + +      <div id="popupMenu"> +        <ul> +          <li><a id="optionsLink" target="_blank">Options</a></li> +        </ul> +      </div> +    </div> +  </body> +</html> diff --git a/popup.js b/popup.js new file mode 100644 index 00000000..859f30f3 --- /dev/null +++ b/popup.js @@ -0,0 +1,20 @@ +function onLoad() { +  document.getElementById("optionsLink").setAttribute("href", chrome.extension.getURL("options.html")); +  chrome.tabs.getSelected(null, function(tab) { +    // The common use case is to disable Vimium at the domain level. +    // This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html". +    var domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) || tab.url; +    document.getElementById("popupInput").value = domain + "*"; +  }); +} + +function onExcludeUrl(e) { +  var url = document.getElementById("popupInput").value; +  chrome.extension.getBackgroundPage().addExcludedUrl(url); +  document.getElementById("excludeConfirm").setAttribute("style", "display: inline-block"); +} + +document.addEventListener("DOMContentLoaded", function() { +  document.getElementById("popupButton").addEventListener("click", onExcludeUrl, false); +  onLoad(); +}); | 
