swaplang / popup.html

<!DOCTYPE html>
<meta name="Content-Type" content="text/html; charset = UTF-8">
<title>Swaplang Popup</title>
  :link {text-decoration:none}
  a:hover {background: #ddd;}
  * {margin: 0px ; padding: 0px}
  p { line-height: 1.4em}
  li { font-family: sans-serif; margin-left: 1.5em; }
<p id="para">Also available:</p>
<ul id="list"></ul>
  var portToUserJS;
  //Direct messages are always from the userJS.
  opera.extension.onmessage = function( event ){
    //The port to communicate on
      portToUserJS = event.ports[0];

    //Split the JSON data, and create the links
      var languageChoices = JSON.parse( );
      var theList = document.getElementById('list');
      for (i in languageChoices) {
      //JSON data has a length and item attribute, which has to be ignored.
        if(i == "length" || i == "item") continue;
      //Add a title, if none exists.
        if (!(languageChoices[i].title)) {
          languageChoices[i].title = "Change to " + languageChoices[i].hreflang ;
      //Create links
        var theItem = document.createElement("li");
        var theLink = document.createElement('a');
        theLink.textContent = languageChoices[i].title;
        theLink.href = languageChoices[i].href;
        theLink.onclick = function(event) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.