Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: history
Fetching contributors…

Cannot retrieve contributors at this time

file 107 lines (92 sloc) 4.097 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head><link href="resources/public/css/tryclojure.css" rel="stylesheet" type="text/css" />
  <script src="resources/public/javascript/jquery-1.4.2.min.js" type="text/javascript"></script>
  <script src="resources/public/javascript/jquery.console.js" type="text/javascript"></script>
  <script src="resources/public/javascript/tryclojure.js" type="text/javascript"></script>
  <title>TryClojure</title>
  <script type="text/javascript">

    var DEBUG = 1;
    var TRACE = 2;
    var INFO = 3;
    function logLevel ()
    {
      var logLevel_ = localStorage.getItem ("logLevel") * 1;
      if (!logLevel_)
        {
          logLevel_ = DEBUG;
        }

      return logLevel_;
    }

    function loadHistory (c)
    {
      if (logLevel () <= INFO)
        {
          console.info ("[INFO] Load history");
        }
      for (var i = 0, cnt = localStorage.length; i < cnt; ++i)
        {
          var line = localStorage.getItem ("history_" + i);
          if (line != "" && line != null)
            {
              if (logLevel () <= DEBUG)
                {
                  console.debug ("[DEBUG] Try to add to console from history: ", line);
                }

              c.addToHistory (line);
            }
        }
    }

    function addToHistory (line)
    {
      var index = localStorage.getItem ("index") * 1;
      var depth = localStorage.getItem ("historyDepth") * 1;

      if (index >= depth)
        index = 0;

      if (logLevel () <= DEBUG)
        {
          console.debug ("[DEBUG] Add to history: ", line, " with index ", index);
        }
      localStorage.setItem ("history_" + index, line);
      localStorage.setItem ("index", index + 1);
    }

    function constructHandle (console_)
    {
      var selection = "";
      chrome.extension.onConnect.addListener (function (port)
        {
          var tab = port.sender.tab;

          port.onMessage.addListener (function (info)
            {
              if (logLevel () <= INFO)
                {
                  console.info ("[INFO] port.onMessage.handler");
                }
              loadHistory (console_);
              console_.historyChangeHandler (addToHistory);
              
              selection = info.selection;
              if (logLevel () <= DEBUG)
                {
                  console.log ("[DEBUG] selection: ", selection);
                }
              if (selection != "")
                {
                  console_.promptText (selection);
                  console_.commandTrigger ();
                }

            });
        });

      chrome.tabs.executeScript (null, { file : "get-selection.js"});
      return selection;
    }

  </script>
</head>
<body><script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-552543-3']);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  </script><div style="text-align: center;"><h1>Try Clojure</h1></div><div id="container"><div class="console" id="console"></div><!--<table border="0" class="bottom"><tr /><td class="bholder"><div class="buttons"><a class="buttons" id="tutorial">tutorial</a><a class="buttons" id="links">links</a><a class="lbutton" id="about">about</a></div></td><tr /><td><div id="changer"><p class="bottom">Welcome to TryClojure. Above, you have a Clojure REPL. You can type expressions and see their results right here in your browser. We also have a brief tutorial to give you a taste of Clojure. Try it out!</p></div></td></table>--><div id="copyleft">&copy; <a href="http://www.try-clojure.org">try-clojure.org</a></div></div></body>

Something went wrong with that request. Please try again.