Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Source/content_script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
walk(document.body);
document.title = buttify(document.title);

function walk(node)
{
Expand Down Expand Up @@ -29,11 +30,9 @@ function walk(node)
}
}

function handleText(textNode) {
var v = textNode.nodeValue;

function buttify(text) {
// Deal with the easy case
v = v.replace(/\b(T|t)he (C|c)loud/g, function(match, p1, p2, offset, string) {
text = text.replace(/\b(T|t)he (C|c)loud/g, function(match, p1, p2, offset, string) {
// t - 7 = m
// c - 1 = b
m = String.fromCharCode(p1.charCodeAt(0) - 7);
Expand All @@ -42,23 +41,25 @@ function handleText(textNode) {
});

// Deal with private clouds
v = v.replace(/\b(P|p)rivate (C|c)loud/g, function(match, p1, p2, offset, string) {
text = text.replace(/\b(P|p)rivate (C|c)loud/g, function(match, p1, p2, offset, string) {
// c - 1 = b
b = String.fromCharCode(p2.charCodeAt(0) - 1);
return b + "utt";
});
// Get the corner cases
if(v.match(/cloud/i)) {
if(text.match(/cloud/i)) {
// If we're not talking about weather
if(v.match(/PaaS|SaaS|IaaS|computing|data|storage|cluster|distributed|server|hosting|provider|grid|enterprise|provision|apps|hardware|software|/i)) {
v = v.replace(/(C|c)loud/gi, function(match, p1, offset, string) {
if(text.match(/PaaS|SaaS|IaaS|computing|data|storage|cluster|distributed|server|hosting|provider|grid|enterprise|provision|apps|hardware|software|/i)) {
text = text.replace(/(C|c)loud/gi, function(match, p1, offset, string) {
// c - 1 = b
b = String.fromCharCode(p1.charCodeAt(0) - 1);
return b + "utt";
});
}
}
textNode.nodeValue = v;
return text;
}


function handleText(textNode) {
textNode.nodeValue = buttify(textNode.nodeValue);
}