Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tom Robinson
committed
Sep 30, 2008
1 parent
e5dcef4
commit 3aba4a9
Showing
3 changed files
with
81 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
|
|||
function pad(n, ch) { var ch = ch || " "; var result = ""; while (n-- > 0) result += ch; return result; } | |||
|
|||
function dump(obj, stack) | |||
{ | |||
if (!stack) | |||
stack = []; | |||
|
|||
stack.push(obj); | |||
for (var i in obj) | |||
{ | |||
if (typeof obj[i] == "object") | |||
{ | |||
var loop = -1; | |||
for (var j = 0; j < stack.length; j++) { | |||
if (stack[j] === obj[i]) { | |||
loop = j; | |||
break; | |||
} | |||
} | |||
if (loop < 0) { | |||
print(pad(stack.length) + i + " => "); | |||
dump(obj[i], stack) | |||
} else { | |||
print(pad(stack.length) + i + " => [LOOP DETECTED] " + loop); | |||
} | |||
} | |||
else | |||
print((pad(stack.length) + i + " => " + obj[i]).substring(0,100).replace(/\n/g, " ")); | |||
} | |||
stack.pop(); | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,33 @@ | |||
// Takes in an array of strings, returns a regex that matches any of the input strings | |||
function optimizedRegex(list) | |||
{ | |||
var buckets = {}; | |||
var optional = false; | |||
|
|||
for (var i = 0; i < list.length; i++) | |||
{ | |||
var str = list[i]; | |||
if (!str) | |||
optional = true; | |||
else | |||
{ | |||
var prefix = str.substring(0, 1); | |||
if (!buckets[prefix]) | |||
buckets[prefix] = []; | |||
buckets[prefix].push(str.substring(1)) | |||
} | |||
} | |||
|
|||
var ptrns = []; | |||
for (var prefix in buckets) | |||
ptrns.push(prefix + optimizedRegex(buckets[prefix])); | |||
|
|||
if (ptrns.length == 0) | |||
return ""; | |||
if (optional) | |||
return "(" + ptrns.join("|") + ")?" | |||
else if (ptrns.length > 1) | |||
return "(" + ptrns.join("|") + ")" | |||
else | |||
return ptrns[0]; | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
var os = document.getElementsByTagName("object"); | |||
for (var i = 0; i < os.length; i++) | |||
{ | |||
var o = os[i].cloneNode(true); | |||
o.innerHTML = '<param name="allowFullScreen" value="true"></param>' + o.innerHTML; | |||
for (var j = 0; j < o.childNodes.length; j++) | |||
{ | |||
if (o.childNodes[j].name == "movie") | |||
o.childNodes[j].value += "&fs=1"; | |||
else if (o.childNodes[j].nodeName.toUpperCase() == "EMBED") { | |||
o.childNodes[j].src += "&fs=1"; | |||
o.childNodes[j].setAttribute("allowfullscreen", "true"); | |||
} | |||
} | |||
os[i].parentNode.replaceChild(o, os[i]); | |||
} |