[Proto-Scripty] sound.js hack that works in IE, gecko, webkit
Ok, here's an extremely ugly hack, but it works in IE6/8, Opera, Chrome, FF3, and Safari: http://pastie.org/915231 It also doesn't load the entire mp3 file before playing it like the old bgsound version did. I'm not too familiar with the object and embed tags so there's probably more junk in there than is really needed. There's another version here that uses windows media player for all browsers rather than just IE: http://wekkerradio.berkheij.nl/# ...but that didn't work for streaming mp3s for me. I haven't done much testing either, so it's probably buggy. -Junk On Apr 11, 11:49 am, Junkshops junksh...@gmail.com wrote: Well, the problem seems to be that sound.js detects IE and then uses the bgsound tag to play music - but IE8 doesn't support bgsound. Hence the problem. I'll see if I can hack it so it uses a plugin instead like all the other browsers; if I can get it to work I'll post it here. On Apr 10, 8:30 pm, Junkshops junksh...@gmail.com wrote: Oof, I hope I'm not going to get labeled a spammer here... I just have lots of questions and this seems to be the place to go. My apologies in advance. So I've searched the list archives, the ruby on rails spinoffs archives, and did a general net search on this one and came up with nothing so I hope asking this isn't a faux pas. Anyway, I'm trying to play sound via the Sound.play() scriptaculous call. The code works fine in Opera, FF3, Safari, and IE6 (boggle [although it doesn't stream like it does in the others]) but doesn't work in IE8 (boggle). I have some pngs I'm swapping out whenever the user asks to play or stop a sound, and that works fine, so I know the code is being run. It just seems like IE8 is completely ignoring the Sound call. Is this a known bug or am I missing something? Source: var TuneToaster = Class.create({ initialize: function(ele) { this.soundPrefix = http://[redacted]/cgi-bin/ stealingourtunesaintcoolseriously.py?id= this.idPrefix = Song-; this.currentlyPlaying = null; var ele = $(ele); var players = ele.select('.JSmusicPlayer'); players.invoke('update', 'img src=images/uglyPlay.png'); players.each(this.setupPlayer.bind(this)); }, setupPlayer: function(ele) { ele.observe('click', this.playerClicked.bindAsEventListener(this)); }, playerClicked: function(ev) { var elm = ev.findElement(); ev.stop(); elm = elm.up(); //for some reason elm is the img rather than the JSmusicPlayer span var idText = elm.identify(); idText = idText.sub(this.idPrefix, ''); if (this.currentlyPlaying) { this.currentlyPlaying.update('img src=images/uglyPlay.png'); Sound.play('', {replace:true}); if (this.currentlyPlaying == elm) { this.currentlyPlaying = null; return; } } elm.update('img src=images/uglyStop.png'); this.currentlyPlaying = elm; Sound.play(this.soundPrefix + idText); } }); Cheers, Junk -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: enumerate hash
If I understand well, what you're asking for is pretty close to what you suggested in your original post: hashToBeTested.each(function(pair){ if(valueToTest==pair.value){ hashToBeTested.unset(pair.key); } } Christophe Le 10 avr. 2010 à 12:36, chrysanthe m a écrit : Hi, again Sorry for being obtuse. But can someone help me and even understand how to write a function and call it on a hash that will take a value, compare it against each of the keys in the hash, on match delete the key/value, and return the hash. tia. On Thu, Apr 8, 2010 at 5:24 PM, chrysanthe m chrysant...@gmail.com wrote: Hi Alex Thanks, but a newbie here so that was drinking at a firehose. Let me parse it to better understand. First can you really invoke on two separate enumerable objects with that [n,n1,n2] syntax? That is tremendous. My problem is I need to first check the presence of a key before I unset it b/c I found out unset-ing a non-existent key seems to zero the struct; also it is more courteous, grin. So how would I construct the and parameterize the annonymous function to do the check and if present do it to itself. Ideally I would like to pass in the enumerable, call the function and return the modified(or not) enumerable in the function's return. On Thu, Apr 8, 2010 at 4:41 PM, Alex Wallace alexmlwall...@gmail.com wrote: Ah, I see. You can handle this using Enumerable's invoke. This code should make it clear: a = new Hash({ x : foo, y : bar }); b = new Hash({ x : zam, y : moof }); a.get(x); foo b.get(x); zam [a,b].invoke(get,x); [foo, zam] [a,b].invoke(unset,x) [foo, zam] a.get(x) (undefined) Cheers, Alex On Thu, Apr 8, 2010 at 3:24 PM, chrysanthe m chrysant...@gmail.com wrote: Sorry sudden send resume in this reply Hello I am having a difficult time trying to enumerate a hash to determine if a give key is in the hash and if so delete it and its value. If I could approach it index it would be function remove(valueToTest, hashToBeTested){ for(i=0;ihashToBeTested.length;i++){ if(valueToTest==hashToBeTested[i]) hashToBeTested.unset(valueToTest); } Would I do it like hashToBeTested.each(function(valueToTest){ if(valueToTest==this)hashToBeTested.unset(valueToTest); },hashToBeTested); return hashToBeTested; which I am sure is wrong syntactically if not semantically. Can someone guide the proper way and more deeply the use of this? On Thu, Apr 8, 2010 at 3:06 PM, chrysanthe m chrysant...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: The Unofficial Wiki
Hi, Instead of moving the wiki content to official prototype's page, couldn't we just rename it as Official Wiki and link it from the prototypejs homepage? This would allows more peoples to find the content while still let them add/edit content if they wish it. The howtos (and some of the tips) are a real added value and are not available anywhere (afaik). Of course, since the wiki is also about scriptaculous we may have to find a clear way to not confuse users which just need prototype information. Eric On Apr 9, 12:43 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I think the site needs an integrated contribution system for Prototype Extensions, better than jQuery's(http://plugins.jquery.com/). One thing at a time. :-) And of course, there's scripteka.com. Some want something easier than learning git, rake, lighthouse, etc., in order to contribute; maybe a web front-end to whichever code is in place, to lower the barrier to contributing. Good news: Apparently in GitHub, you can fork the project and do on- site editing of content (Mislav and Tobie just told me about that), then send a pull request. So if git is a barrier, someone can contribute just using a browser. Result! -- T.J. :-) On Apr 9, 3:17 am, disccomp discc...@gmail.com wrote: T.J. Crowder: Question: Do we need a wiki with user-generated content? We should: just move all of the relevant content to the Prototype website and make sure the process for contributing to the website is well-publicized, easy, and efficient I think the site needs an integrated contribution system for Prototype Extensions, better than jQuery's(http://plugins.jquery.com/). It would be great if the extensions and the patch submission system shared a contribution system. Some want something easier than learning git, rake, lighthouse, etc., in order to contribute; maybe a web front-end to whichever code is in place, to lower the barrier to contributing. User generated code and examples could be posted maintained right on the site with (Prototype Friendly) syntax highlighting. Rico 2.0 has lots of goodies[1], so does Scriptaculous, it would be awesome to sync all these projects up, make the components modular with clear a dependance scheme, especially when considering the future of the library. [1]http://openrico.sourceforge.net/examples/index.html -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Class Inheritance from Element
Could you post a use example? In this case, I usualy create a simple class not derived from Element and a maker function to extend DOM elements with this class prototype. I am not sure at all it is the best approach but it works and is relatively easy to maintain. It looks like this (untested) for exemple if you want to cast a LI tag into a kind of tree: function mkTree(domElement) { domElement = $(domElement) || new Element('li'); Object.extend(domElement,Tree.prototype); domElement.initialize(); return domElement; } var Tree = Class.create({ initialize: function() {this.addClassName('tree'); }, createNode: function(...) {.../... } }); You may have to play with Array.shift and Function.call if you want to have extra parameters to your constructor (I've never needed it yet but it should be possible). Eric Note: I've never tried to override a native method and I am kind of certain it would not work :o) On Apr 7, 9:11 pm, Guss gus...@gmail.com wrote: On Mar 25, 12:02 am, Glen a...@usa.com wrote: I would like to use Prototype's class inheritance to derive a class from Element as below: The current structure of Element and Class does not support such. I was wondering if anyone had anything more elegant. I have the same issue - I want to create my own classes that inherit from standard DOM elements, so I can do something like: var Button = Class.create(Element, { initialize: function($super, content) { $super('button'); this.update(content); }}); document.body.appendChild(new Button(submit)); But as you noted, Element in prototype is not a prototype Class that can be extended using Class.create. I decided not to muck about with that and instead write something else. So I create Class.createElement() that works like as you would expect, with the very serious caveat that you can't override most native methods (not sure why - I can override some, but not others). The implementation looks like this (and is mostly copied from Class.create): Class.createElement = function(tagname, impl) { var IS_DONTENUM_BUGGY = (function() { for ( var p in { toString : 1 }) { // check actual property name, so that it works with augmented // Object.prototype if (p === 'toString') return false; } return true; })(); return function() { var elm = new Element(tagname); properties = Object.keys(impl); // IE6 doesn't enumerate `toString` and `valueOf` (among other built- in // `Object.prototype`) properties, // Force copy if they're not Object.prototype ones. // Do not copy other Object.prototype.* for performance reasons if (IS_DONTENUM_BUGGY) { if (impl.toString != Object.prototype.toString) properties.push(toString); if (impl.valueOf != Object.prototype.valueOf) properties.push(valueOf); } for ( var i = 0, length = properties.length; i length; i++) { var property = properties[i], value = impl[property]; if (Object.isFunction(value) value.argumentNames()[0] == $super) { var method = value; value = (function(m) { return function() { return elm[m].apply(this, arguments); }; })(property).wrap(method); value.valueOf = method.valueOf.bind(method); value.toString = method.toString.bind(method); } impl[property] = value; } Object.extend(elm,impl); elm.initialize.apply(elm,arguments); return elm; }; }; -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Proposal: Alias clearContent for update()
Hi, I didn't find a method for clearing the content of an HTML element *and* which from its name clearly indicates this action. I formerly used $(myContainer).update() for clearing the element's content, i.e. calling the update method with no arguments. But I prefer a readable alias like Element.clearContent() for this. (I first tried an alias Element.clear() but this wasn't a good idea, the function clear seems to be reserved for other things). I like to propose such an alias for the Prototype standard. Regards, Rüdiger -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Cross-browser function for Text content
Hi there, is there a cross-browser function for retrieving the text content of an element? If I have an element like span id=test4711/span I get the number 4711 in IE with $(test).innerText and in FF with $ (test).textContent - does Prototype provide a browser-independent abstraction for this? Regards, Rüdiger -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Cross-browser function for Text content
Hi, I get the number 4711 in IE with $(test).innerText and in FF with $ (test).textContent - does Prototype provide a browser-independent abstraction for this? Hopefully you get the *string* 4711 rather than the number 4711 (unless you parse it). :-) `innerHTML` works on all major browsers. It was introduced by IE back in v5 or so, supported by every major browser, and is now standardized in the HTML5 stuff. Of course, it returns the HTML rather than the text, so given: span id=testem4711/em/span $('test').innerHTML will return em4711/em. If you want just the text with the tags stripped away, Prototype adds `stripTags`[1] to the `String` prototype, so $('test').innerHTML.stripTags() will return 4711. If you wanted to shorten that a bit, you could add a `text` function via Element.addMethods[2]: Element.addMethods({ text: function(element) { if (!(element = $(element))) return; return element.innerHTML.stripTags(); } }); (That's off-the-cuff, but I think it's correct; more on the addMethods page.) [1] http://api.prototypejs.org/language/string/prototype/striptags/ [2] http://api.prototypejs.org/dom/element/addmethods/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 12, 2:05 pm, Rüdiger Plantiko ruediger.plant...@astrotexte.ch wrote: Hi there, is there a cross-browser function for retrieving the text content of an element? If I have an element like span id=test4711/span I get the number 4711 in IE with $(test).innerText and in FF with $ (test).textContent - does Prototype provide a browser-independent abstraction for this? Regards, Rüdiger -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Cross-browser function for Text content
Hi TJ, I get the number 4711 in IE with $(test).innerText and in FF with $ (test).textContent - does Prototype provide a browser-independent abstraction for this? Hopefully you get the *string* 4711 rather than the number 4711 (unless you parse it). :-) You are right, in a posting every word is important, in order to avoid misunderstandings. So, yes: I am getting the string, not the number. ... innerHTML ... yeah, if the document structure guarantees to me that the element in question only contains a text node, then I could use innerHTML equivalently to innerText/textContent. Element.addMethods({ text: function(element) { if (!(element = $(element))) return; return element.innerHTML.stripTags(); } }); thanks for the reference to String.stripTags() - I hadn't realized the existence of such a function before. - Regards, Rüdiger -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Proposal: Alias clearContent for update()
Admittedly, there are methods in Prototype (and any library) which are not perfectly intuitive because they can serve multiple purposes for the sake of condensing code. i personally see the update() method as suitable. When there's an argument, you're updating with the content in the argument. When there's none, you're updating the element to empty content. There are a lot of aliases in the Prototype library as it is - something i see more often as a confusing eyesore than a help. If you really want to propose the alias to the core, though, join the Prototype Core group and toss it out there, see if it sticks. -joe t. On Apr 12, 9:01 am, Rüdiger Plantiko ruediger.plant...@astrotexte.ch wrote: Hi, I didn't find a method for clearing the content of an HTML element *and* which from its name clearly indicates this action. I formerly used $(myContainer).update() for clearing the element's content, i.e. calling the update method with no arguments. But I prefer a readable alias like Element.clearContent() for this. (I first tried an alias Element.clear() but this wasn't a good idea, the function clear seems to be reserved for other things). I like to propose such an alias for the Prototype standard. Regards, Rüdiger -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Proper observer removal
If i setup an html link element to be observed, and then i subsequently remove the html element without calling stopObserving(), does that remove the observer? or does it create a leak of some sort? Ex: $('logo').observe('click', function (e) { e.stop(); }); // remove the html element w/o stopObserving $('logo').remove (); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Proposal: Alias clearContent for update()
If you really want to propose the alias to the core, though, join the Prototype Core group and toss it out there, see if it sticks. Or file an enhancement request: http://prototype.lighthouseapp.com/projects/8886/home But I'm with Joe on this (FWIW), I think just #update is clear enough that that Prototype has enough aliases as it is... -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 13, 3:23 am, joe t. thooke...@gmail.com wrote: Admittedly, there are methods in Prototype (and any library) which are not perfectly intuitive because they can serve multiple purposes for the sake of condensing code. i personally see the update() method as suitable. When there's an argument, you're updating with the content in the argument. When there's none, you're updating the element to empty content. There are a lot of aliases in the Prototype library as it is - something i see more often as a confusing eyesore than a help. If you really want to propose the alias to the core, though, join the Prototype Core group and toss it out there, see if it sticks. -joe t. On Apr 12, 9:01 am, Rüdiger Plantiko ruediger.plant...@astrotexte.ch wrote: Hi, I didn't find a method for clearing the content of an HTML element *and* which from its name clearly indicates this action. I formerly used $(myContainer).update() for clearing the element's content, i.e. calling the update method with no arguments. But I prefer a readable alias like Element.clearContent() for this. (I first tried an alias Element.clear() but this wasn't a good idea, the function clear seems to be reserved for other things). I like to propose such an alias for the Prototype standard. Regards, Rüdiger -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Proper observer removal
Hi, On Apr 13, 5:24 am, Gregory Nicholas faction.greg...@gmail.com wrote: If i setup an html link element to be observed, and then i subsequently remove the html element without calling stopObserving(), does that remove the observer? or does it create a leak of some sort? It leaves the handler in memory, you do need to call stopObserving first. The same thing happens if you remove an ancestor of an element that has handlers still attached to it (e.g., div form input where you have a handler on the input, and you remove the div). Once or twice people have suggested that Prototype do it automatically, but there are a couple of reasons why that's not a great idea in practice, so those proposals haven't had legs. HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 13, 5:24 am, Gregory Nicholas faction.greg...@gmail.com wrote: If i setup an html link element to be observed, and then i subsequently remove the html element without calling stopObserving(), does that remove the observer? or does it create a leak of some sort? Ex: $('logo').observe('click', function (e) { e.stop();}); // remove the html element w/o stopObserving $('logo').remove (); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.