Commit ccb100f3 authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Trivial node priority display

- Showing time spent besides a search result on start page
- Removed devcards, was interfering on the content script and blanked
  the page when it initialized
parent d44df83a
String.prototype.hashCode = function() {};
......@@ -4,10 +4,8 @@
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.145"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[cljs-ajax "0.5.0"]
[cljsjs/react-bootstrap "0.25.2-0" :exclusions [org.webjars.bower/jquery]]
[devcards "0.2.0-8"]
[khroma "0.2.0-SNAPSHOT"]
[prismatic/dommy "1.1.0"]
[re-frame "0.4.1" :exclusions [cljsjs/react]]
......@@ -15,13 +13,15 @@
:source-paths ["src/app" "src/devcards"]
:profiles {:dev {:plugins [[lein-cljsbuild "1.1.0"]
[lein-chromebuild "0.3.0"]]
:cljsbuild {:builds {:dev
{:source-paths ["src/app" "src/devcards"]
:compiler {:output-to "target/unpacked/booklet.js"
:output-dir "target/js"
:optimizations :whitespace
:pretty-print true
:devcards true}}}}
:cljsbuild {:builds
{:source-paths ["src/app"]
:compiler {:output-to "target/unpacked/booklet.js"
:output-dir "target/js"
:externs ["externs/misc-externs.js"]
:main "booklet.background"
:optimizations :whitespace
:pretty-print true}}}}
:chromebuild {:resource-paths ["resources/js"
<!DOCTYPE html>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
We need the following highlight pack embedded because otherwise devcards
attempt to do some inline execution, which Chrome does not like on
<script type="text/javascript" id="com-rigsomelight-code-highlighting" src="highlight.pack.js"></script>
<script type="text/javascript" src="booklet.js"></script>
<script type="text/javascript" src="devcards-init.js"></script>
This diff is collapsed.
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (var i = 0; i < this.length; i++) {
var char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
return hash;
\ No newline at end of file
......@@ -23,6 +23,13 @@
"persistent": false
"content_scripts": [
"matches": ["https://**", "*"],
"run_at": "document_end",
"js": ["booklet.js", "content-init.js"]
"manifest_version": 2
......@@ -2,7 +2,6 @@
(:require [clojure.set :refer [difference]]
[cljs.core.async :refer [>! <!]]
[booklet.utils :refer [on-channel from-transit to-transit]]
[cognitect.transit :as transit]
[khroma.log :as console]
[khroma.alarms :as alarms]
[khroma.runtime :as runtime]
......@@ -300,6 +299,12 @@
(defn init-time-tracking []
(dispatch-sync [::initialize])
[conn (runtime/on-connect)]
(let [content (<! conn)]
(console/log "--> Background received" (<! content))
(>! content :background-ack)
(recur conn)))
(defn init-click-handling []
(ns booklet.content
(:require [booklet.utils :refer [on-channel from-transit to-transit]]
[dommy.core :refer-macros [sel sel1] :as dommy]
[khroma.runtime :as runtime]
[khroma.log :as console]
[cljs.core.async :refer [>! <!]]
[ :as storage])
(:require-macros [cljs.core.async.macros :refer [go]]))
(defn transform-node [database node]
(let [parent (.-parentNode node)
href (.-href parent)
id (.hashCode href)
data (get database id)]
(when data
(aset node "textContent"
(str (aget node "textContent") " [time viewed: " (:time data) " ms]"))
(defn do-transformations []
(let [data (from-transit (:data (<! (storage/get))))]
(doseq [node (sel :.result_url_heading)]
(transform-node (:url-times data) node)
#_(aset node "textContent"
(aget node "textContent")
" - Hi there: "
(.-href (.-parentNode node)))))))
(console/log (sel :.result_url_heading))
(console/log (map dommy/text (sel :.result_url_heading)))
(console/log (map #(.-parentNode %) (sel :.result_url_heading))))
(defn ^:export init []
(console/log "Init on content script!")
(let [bg (runtime/connect)]
(>! bg :content-initialized)
(console/log "<-- Background replied" (<! bg)))))
\ No newline at end of file
......@@ -22,8 +22,7 @@
(defn from-transit
(transit/read (transit/reader :json) transit-data)
(transit/read (transit/reader :json) transit-data))
(def initial-focus-wrapper
(with-meta identity
(ns booklet.devcards
(:require [devcards.core :as core]
[khroma.log :as console]))
(defn ^:export main []
(console/log "Initializing UI...")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment