Skip to content
Browse files

Super Find and Highlight

  • Loading branch information...
0 parents commit de25d4cb70ccec6ac8df43a6d1414df68964ccc0 @psankar committed Aug 17, 2011
Showing with 9,099 additions and 0 deletions.
  1. +21 −0 highlight.css
  2. BIN icon.png
  3. +54 −0 jquery.highlight-3.js
  4. +8,981 −0 jquery.js
  5. +16 −0 manifest.json
  6. +26 −0 popup.html
  7. +1 −0 sfind.css
21 highlight.css
@@ -0,0 +1,21 @@
+/* Style definition file generated by highlight 2.16, http://www.andre-simon.de/ */
+
+/* Highlighting theme definition: */
+
+body.hl { background-color:#ffffff; }
+pre.hl { color:#000000; background-color:#ffffff; font-size:10pt; font-family:'Courier New';}
+.hl.num { color:#2928ff; }
+.hl.esc { color:#ff00ff; }
+.hl.str { color:#ff0000; }
+.hl.dstr { color:#818100; }
+.hl.slc { color:#838183; font-style:italic; }
+.hl.com { color:#838183; font-style:italic; }
+.hl.dir { color:#008200; }
+.hl.sym { color:#000000; }
+.hl.line { color:#555555; }
+.hl.mark { background-color:#ffffbb;}
+.hl.kwa { color:#000000; font-weight:bold; }
+.hl.kwb { color:#830000; }
+.hl.kwc { color:#000000; font-weight:bold; }
+.hl.kwd { color:#010181; }
+
BIN icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 jquery.highlight-3.js
@@ -0,0 +1,54 @@
+/*
+
+highlight v3
+
+Highlights arbitrary terms.
+
+<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
+
+MIT license.
+
+Johann Burkard
+<http://johannburkard.de>
+<mailto:jb@eaio.com>
+
+*/
+
+jQuery.fn.highlight = function(pat) {
+ alert ("Hello Scripts, Thankg God");
+ function innerHighlight(node, pat) {
+ var skip = 0;
+ if (node.nodeType == 3) {
+ var pos = node.data.toUpperCase().indexOf(pat);
+ if (pos >= 0) {
+ var spannode = document.createElement('span');
+ spannode.className = 'highlight';
+ var middlebit = node.splitText(pos);
+ var endbit = middlebit.splitText(pat.length);
+ var middleclone = middlebit.cloneNode(true);
+ spannode.appendChild(middleclone);
+ middlebit.parentNode.replaceChild(spannode, middlebit);
+ skip = 1;
+ }
+ }
+ else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
+ for (var i = 0; i < node.childNodes.length; ++i) {
+ i += innerHighlight(node.childNodes[i], pat);
+ }
+ }
+ return skip;
+ }
+ return this.each(function() {
+ innerHighlight(this, pat.toUpperCase());
+ });
+};
+
+jQuery.fn.removeHighlight = function() {
+ return this.find("span.highlight").each(function() {
+ this.parentNode.firstChild.nodeName;
+ with (this.parentNode) {
+ replaceChild(this.firstChild, this);
+ normalize();
+ }
+ }).end();
+};
8,981 jquery.js
8,981 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
16 manifest.json
@@ -0,0 +1,16 @@
+{
+ "name": "Sankar's Find",
+ "version": "1.0",
+ "description": "Search is the purpose of life",
+ "browser_action": {
+ "default_icon": "icon.png",
+ "popup": "popup.html"
+ },
+ "content_scripts": [ {
+ "matches": [ "<all_urls>" ],
+ "js": [ "jquery.js", "jquery.highlight-3.js" ]
+ } ],
+ "permissions": [
+ "tabs", "http://*/*", "https://*/*"
+ ]
+}
26 popup.html
@@ -0,0 +1,26 @@
+<script src="jquery.js"></script>
+<script src="jquery.highlight-3.js"></script>
+
+<link rel="stylesheet" type="text/css" href="sfind.css">
+
+<script>
+ function search(that) {
+
+ var token = new String (t1.value);
+
+ chrome.tabs.insertCSS(null,
+ {file:"sfind.css"});
+
+ chrome.tabs.executeScript(null,
+ {code:"$(document.body).highlight('"+token+"')"});
+
+ window.close();
+ }
+</script>
+
+<input type="text" id="t1"/>
+<input type="text" id="t2"/>
+<input type="text" id="t3"/>
+<input type="text" id="t4"/>
+
+<button onclick="search(this)" id="click">
1 sfind.css
@@ -0,0 +1 @@
+.highlight { background-color: yellow }

0 comments on commit de25d4c

Please sign in to comment.
Something went wrong with that request. Please try again.