commit 0794cdae0eb216899a75a700b4a8f498b2e34a17
parent bd3ba4f1b5454d2575e368675ef441d425d08e36
Author: Ryan Wolf <rwolf@borderstylo.com>
Date: Mon, 28 Jun 2010 15:45:53 -0700
made the speech bubble bit simpler and even less obtrusive
Diffstat:
1 file changed, 48 insertions(+), 51 deletions(-)
diff --git a/chrome/content/binding.xml b/chrome/content/binding.xml
@@ -13,7 +13,7 @@
</div>
<div id="seats">
<div id="empty" />
- <div id="occupied" onclick="javascript:heckle_site(this);" />
+ <div id="occupied" />
</div>
</body>
</xbl:content>
@@ -23,60 +23,57 @@
This constructor adds the speech bubbles, it has nothing directly to
do with the stack hack
*/
- var tom = 215 ;
- var joel = 145 ;
- var crow = 80 ;
- hecklers = {
- text: [
- [ crow, "They must've spent tens of dollars on this." ],
- [ joel, "I think the prop department juuust ran out of money." ],
- [ tom, "I bet this was made in Canada." ],
- [ joel, "I'll bet this site uses -moz-binding" ],
- [ joel, "Yeah." ],
- [ crow, "I know I'll never be quite the same." ],
- [ joel, "This XBL is history." ],
- [ crow, "We're history." ],
- [ crow, "Hey! Is this From Here to Eternity?" ],
- [ tom, "No, it just seems like an eternity." ],
- [ tom, "It is sort of hypnotic, isn't it?" ],
- [ crow, "Hip? Not. Ick!" ]
- ],
- bubble: null,
- fin: null,
- timeout: null
- } ;
- hecklers.index = Math.floor(Math.random() * hecklers.text.length),
- heckle_site = function (heckler_node) {
- var doc = heckler_node.ownerDocument ;
- var text = hecklers.text[hecklers.index] ;
- var remove = function () {
- if (hecklers.bubble) {
- heckler_node.removeChild(hecklers.bubble) ;
- heckler_node.removeChild(hecklers.fin) ;
- hecklers.bubble = null ;
- hecklers.fin = null ;
- }
- } ;
+ // px offsets
+ var tom = 215;
+ var joel = 145;
+ var crow = 80;
- hecklers.index = (hecklers.index + 1) % hecklers.text.length ;
- remove() ;
+ var phrases = [
+ [crow, "They must've spent tens of dollars on this."],
+ [joel, "I think the prop department juuust ran out of money."],
+ [tom, "I bet this was made in Canada."],
+ [joel, "I'll bet this site uses -moz-binding"],
+ [joel, "Yeah."],
+ [crow, "I know I'll never be quite the same."],
+ [joel, "This XBL is history."],
+ [crow, "We're history."],
+ [crow, "Hey! Is this From Here to Eternity?"],
+ [tom, "No, it just seems like an eternity."],
+ [tom, "It is sort of hypnotic, isn't it?"],
+ [crow, "Hip? Not. Ick!"]
+ ];
- hecklers.bubble = doc.createElement('div') ;
- hecklers.fin = doc.createElement('div') ;
- hecklers.bubble.id = "speechbubble" ;
- hecklers.bubble.innerHTML = text[1] ;
- hecklers.bubble.style.right = text[0] + "px" ;
- hecklers.fin.id = "speechbubblefin" ;
- hecklers.fin.style.right = (text[0] + 10) + "px" ;
- heckler_node.appendChild(hecklers.bubble) ;
- heckler_node.appendChild(hecklers.fin) ;
- if (hecklers.timeout) {
- window.clearTimeout(hecklers.timeout) ;
- hecklers.timeout = null ;
+ var index = Math.floor(Math.random() * phrases.length);
+
+ // See: https://developer.mozilla.org/en/XBL/XBL_1.0_Reference/DOM_Interfaces#getAnonymousElementByAttribute
+ var node = document.getAnonymousElementByAttribute(this, 'id', 'occupied');
+
+ node.onclick = function () {
+ // remove old speech bubble
+ while (node.hasChildNodes()) {
+ node.removeChild(node.firstChild);
}
- hecklers.timeout = window.setTimeout(remove, 10000) ;
- } ;
+
+ // choose what new speech bubble will say
+ var speech = phrases[index];
+ var offset = speech[0];
+ var text = speech[1];
+
+ // create bubble and add to dom
+ var bubble = document.createElement('div') ;
+ bubble.id = "speechbubble";
+ bubble.textContent = text;
+ bubble.style.right = offset + "px";
+ node.appendChild(bubble);
+ var fin = document.createElement('div');
+ fin.id = "speechbubblefin";
+ fin.style.right = (offset + 10) + "px";
+ node.appendChild(fin);
+
+ // update index (it wraps around phrases)
+ index = (index + 1) % phrases.length;
+ };
]]></xbl:constructor>
</xbl:implementation>
</xbl:binding>