-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload progress so far
- Loading branch information
Showing
12 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
if (!localStorage['saved']){ | ||
localStorage['letA'] = '#800000'; //maroon | ||
localStorage['letE'] = '#008000'; //green | ||
localStorage['letI'] = '#0000ff'; //blue | ||
localStorage['letO'] = '#008080'; //teal | ||
localStorage['letU'] = '#800080'; //purple | ||
|
||
localStorage['saved'] = 'Y'; | ||
|
||
} | ||
|
||
|
||
// Converts an integer (unicode value) to a char | ||
function itoa(i) | ||
{ | ||
return String.fromCharCode(i); | ||
} | ||
|
||
// Converts a char into to an integer (unicode value) | ||
function atoi(a) | ||
{ | ||
return a.charCodeAt(); | ||
} | ||
|
||
|
||
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { | ||
if (request.method == "getColors"){ | ||
var colorList = new Array(); | ||
for( x=0; x<26; x++){ | ||
colorList[x] = localStorage['let' + itoa( atoi('A') + x) ]; | ||
} | ||
sendResponse({colors: colorList}); | ||
} | ||
else{ | ||
sendResponse({}); // snub them. | ||
} | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* modified version of a highlight function for jquery, original developed by Johann Bukard; alterations done by Adam Savvas | ||
MIT license also applies to modified version | ||
*/ | ||
|
||
//original credit that went with highlight | ||
/* | ||
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:[email protected]> | ||
*/ | ||
|
||
jQuery.fn.highlight = function(pat, mcolor) { | ||
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'; | ||
spannode.style.color = mcolor | ||
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()); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "Synesthetize", | ||
"version": "1.11", | ||
"manifest_version": 2, | ||
"description": "Color code individual characters on pages you view -- induce color-graphemic synesthesia", | ||
"options_page": "options.html", | ||
"content_scripts": [ | ||
{ "matches": ["http://*/*","https://*/*","file:///*/*"], | ||
"js": ["jquery-1.7.2.min.js","jquery.highlight-3.js","swap.js"], | ||
"all_frames": false | ||
} | ||
|
||
], | ||
"background": { "scripts": ["background.js"]}, | ||
"icons": { "128": "128-t.png" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.highlight { color: yellow } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<html> | ||
<head><title>Synaesthete options</title></head> | ||
<body> | ||
<script src="optsave.js"></script> | ||
Set colors: | ||
<form id="mform"><span id="letterA"> | ||
A: </span><input type="text" name="letA" value="#800000" id ="letA"/> <br /><span id="letterB"> | ||
B: </span><input type="text" name="letB" id="letB" /> <br /><span id="letterC"> | ||
C: </span><input type="text" name="letC" id="letC" /> <br /><span id="letterD"> | ||
D: </span><input type="text" name="letD" id="letD" /> <br /><span id="letterE"> | ||
E: </span><input type="text" name="letE" id="letE" /> <br /><span id="letterF"> | ||
F: </span><input type="text" name="letF" id="letF" /> <br /><span id="letterG"> | ||
G: </span><input type="text" name="letG" id="letG" /> <br /><span id="letterH"> | ||
H: </span><input type="text" name="letH" id="letH" /> <br /><span id="letterI"> | ||
I: </span><input type="text" name="letI" id="letI" /> <br /><span id="letterJ"> | ||
J: </span><input type="text" name="letJ" id="letJ" /> <br /><span id="letterK"> | ||
K: </span><input type="text" name="letK" id="letK" /> <br /><span id="letterL"> | ||
L: </span><input type="text" name="letL" id="letL" /> <br /><span id="letterM"> | ||
M: </span><input type="text" name="letM" id="letM" /> <br /><span id="letterN"> | ||
N: </span><input type="text" name="letN" id="letN" /> <br /><span id="letterO"> | ||
O: </span><input type="text" name="letO" id="letO" /> <br /><span id="letterP"> | ||
P: </span><input type="text" name="letP" id="letP" /> <br /><span id="letterQ"> | ||
Q: </span><input type="text" name="letQ" id="letQ" /> <br /><span id="letterR"> | ||
R: </span><input type="text" name="letR" id="letR" /> <br /><span id="letterS"> | ||
S: </span><input type="text" name="letS" id="letS" /> <br /><span id="letterT"> | ||
T: </span><input type="text" name="letT" id="letT" /> <br /><span id="letterU"> | ||
U: </span><input type="text" name="letU" id="letU" /> <br /><span id="letterV"> | ||
V: </span><input type="text" name="letV" id="letV" /> <br /><span id="letterW"> | ||
W: </span><input type="text" name="letW" id="letW" /> <br /><span id="letterX"> | ||
X: </span><input type="text" name="letX" id="letX" /> <br /><span id="letterY"> | ||
Y: </span><input type="text" name="letY" id="letY" /> <br /><span id="letterZ"> | ||
Z: </span><input type="text" name="letZ" id="letZ" /> <br /> | ||
</form> | ||
|
||
<br> | ||
<button>Save</button> | ||
|
||
<span id="status"></span> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Saves options to localStorage. | ||
|
||
// Converts an integer (unicode value) to a char | ||
function itoa(i) | ||
{ | ||
return String.fromCharCode(i); | ||
} | ||
|
||
// Converts a char into to an integer (unicode value) | ||
function atoi(a) | ||
{ | ||
return a.charCodeAt(); | ||
} | ||
|
||
// Restores select box state to saved value from localStorage. | ||
function restore_options() { | ||
|
||
var mform = document.getElementById("mform"); | ||
for( var x= 0; x < 26; x++) { | ||
var mlet = "let" + itoa( atoi('A') + x); | ||
var mbox = mform.elements[mlet] //document.getElementByID(mlet); | ||
//var index = mbox.selectedIndex; | ||
//var mbox = document.getElementById("let" + mlet ); | ||
|
||
//document.write(mcolor) | ||
var mspan = document.getElementById( "letter" + itoa( atoi('A') + x) ) ; | ||
if (localStorage[mlet]){ | ||
mbox.value = localStorage[mlet]; | ||
mspan.style.color = localStorage[mlet]; | ||
} else{ | ||
mbox.value = ""; | ||
mspan.style.color = '#000000' | ||
} | ||
|
||
} | ||
} | ||
|
||
function save_options() { | ||
|
||
var mform = document.getElementById("mform") | ||
for( var x= 0; x < 26; x++) { | ||
var mlet = "let" + itoa( atoi('A') + x); | ||
//document.write(mlet) | ||
var mbox = mform.elements[mlet] //document.getElementByID(mlet); | ||
//var index = mbox.selectedIndex; | ||
//var mbox = document.getElementById("let" + mlet ); | ||
var mcolor = mbox.value; | ||
//document.write(mcolor) | ||
localStorage[mlet] = mcolor; | ||
//mform.elements[mlet].color = mcolor | ||
} | ||
|
||
|
||
var status = document.getElementById("status"); | ||
status.innerHTML = "Options Saved!"; | ||
/* setTimeout(function() { | ||
status.innerHTML = ""; | ||
}, 1750);*/ | ||
localStorage['saved'] = "Y" | ||
restore_options(); | ||
} | ||
|
||
|
||
function clickHandler(e) { | ||
setTimeout(save_options, 1000); | ||
} | ||
// Add event listeners once the DOM has fully loaded by listening for the | ||
// `DOMContentLoaded` event on the document, and adding your listeners to | ||
// specific elements when it triggers. | ||
document.addEventListener('DOMContentLoaded', function () { | ||
document.querySelector('button').addEventListener('click', clickHandler); | ||
restore_options() | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Converts an integer (unicode value) to a char | ||
function itoa(i) | ||
{ | ||
return String.fromCharCode(i); | ||
} | ||
|
||
// Converts a char into to an integer (unicode value) | ||
function atoi(a) | ||
{ | ||
return a.charCodeAt(); | ||
} | ||
|
||
//just an array of number to letter mappings | ||
var letters = new Array() | ||
for( x=0; x<26; x++){ | ||
letters[x] = itoa( atoi('a') + x); | ||
} | ||
|
||
//get array of letters and their corresponding colors | ||
chrome.extension.sendRequest({method: "getColors"}, function(response) { | ||
console.log(response.colors); | ||
|
||
for( x=0; x<26; x++){ | ||
var let = itoa( atoi('A') + x); | ||
var mlet = "let" + let; | ||
//document.write('letter:' + let+ ' the stored result is: ' + localStorage[mlet] + "<br>" ); | ||
if(response.colors[x]){ | ||
$('body').highlight(let,response.colors[x]); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
}); | ||
|
||
/* | ||
//set defaults if not yet defined | ||
if (!localStorage['saved']){ | ||
localStorage['letA'] = '#800000'; //maroon | ||
localStorage['letE'] = '#008000'; //green | ||
localStorage['letI'] = '#0000ff'; //blue | ||
localStorage['letO'] = '#008080'; //teal | ||
localStorage['letU'] = '#800080'; //purple | ||
localStorage['saved'] = 'Y' | ||
} | ||
*/ | ||
/* | ||
//for each letter, if it's not | ||
for( x=0; x<26; x++){ | ||
var let = itoa( atoi('A') + x); | ||
var mlet = "let" + let; | ||
//document.write('letter:' + let+ ' the stored result is: ' + localStorage[mlet] + "<br>" ); | ||
if(localStorage[mlet]){ | ||
$('*').highlight(let,localStorage[mlet]); | ||
} | ||
} | ||
*/ |