Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/386/go/misc/chrome/gophertool/popup.js

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


function openURL(url) {
  chrome.tabs.create({ "url": url })
}

function addLinks() {
  var links = document.getElementsByTagName("a");
  for (var i = 0; i < links.length; i++) {
    var url = links[i].getAttribute("url");
    if (url)
      links[i].addEventListener("click", function () {
        openURL(this.getAttribute("url"));
      });
  }
}

window.addEventListener("load", function () {
  addLinks();
  console.log("hacking gopher pop-up loaded.");
  document.getElementById("inputbox").focus();
});

window.addEventListener("submit", function () {
  console.log("submitting form");
  var box = document.getElementById("inputbox");
  box.focus();

  var t = box.value;
  if (t == "") {
    return false;
  }

  var success = function(url) {
    console.log("matched " + t + " to: " + url)
    box.value = "";
    openURL(url);
    return false;  // cancel form submission
  };

  var url = urlForInput(t);
  if (url) {
    return success(url);
  }

  console.log("no match for text: " + t)
  return false;
});

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].