Talk:Audio alarm
Too specific
This is not a RC task, it's a job assignment a manager would hand out to programers. Also, what day and age is this, that someone still uses document.write
? --Ledrug 02:58, 22 July 2011 (UTC)
- Yeah we have a lot of these bits already: The user input, the pause, display a blank window, timers and event triggers (I think), play a recorded sound. We might need truncation of a string for the purpose of removing the file extension. (I haven't seen that anywhere). Also I don't think this is useful in alarm clock type applications, because you would typically want the event to be synchronous, with the clock itself, (typically, the alarm clock application would trigger the audio event, rather than a separate process.) Markhobley 09:39, 22 July 2011 (UTC)
- I have stumbled across "document.write" a few times. I don't think that is a cause for concern. Markhobley 09:39, 22 July 2011 (UTC)
Hello, this is the original writer of AudioAlarm; the newbie RosettaCoder Star651. I was looking at your threads. I've been programming JavaScript since 2006, when I became this big HTMLer, and document.write and its evil partner document.writeln were always being used to display HTML content in JavaScript applications within HTML documents. In fact, the alarm clock I've woken up to the past few days was this app I wrote (major geekage). And, I'm positive it works. I'm sure non-programmers can use it. Some people (who are not programmers) can use it, for these non-programmers might not know about those file extensions. They might think that MP3 is a file type, but not necessarily know what an "extension" is. When I program it at 10:00 PM, for "28800" (28,800 seconds, which is 8 hours), and type in alarm name, such as "example" (which calls example.mp3), I keep this mobile device plugged in, which causes it to never shut off, until I tell it to. When the sound goes off, I know to get off, go over to my device, close the program, close the media-player, and off I go! HTML/JavaScript mania! I'll send the package to the people that I think may need it. So, as I reiterate, AudioAlarm.htm is a working program, when you load it in a Web-browser with active content on. (My browser has it on all the time). Star651 22:48, 22 July 2011 (UTC)
- Oh I have no doubt you can make the program work, I was rather questioning the suitablity of the very specific requirements of your description: "type names without extension", "type seconds", "must be in its own folder"--what value do those provide as code examples here?
- And, let me reiterate your "app"'s design goal: you kindly send this "app" to some hapless schmuck who has never seen a file extension or an alarm clock, so that he can wake up in time; now every night before he goes to bed he needs to fire up an html file, calculate how many seconds he needs to sleep, type that in carefully, remember what filename it is and type that in carefully, then spend all night worrying if he typed anything wrong (you did no error check) or if the computer would itself go to sleep before dawn (Mr. Schmuck might not have your l33t mobile device)—I feel sorry for the poor soul. Then again, it's probably his own fault for making acquaintance with a "major geekage" who doesn't know to use javascript to calcuate time or file drag and drop. Meh. --Ledrug 23:10, 22 July 2011 (UTC)
- It probably just needs some rewriting. I think an analogue clock with an audible alarm (a variation on the "Draw a clock" task currently in draft), only it needs a full set of hands, a facility to set the alarm time, and a choice of audio file. This should not be a problem. I'm sure one of us can knock up a task description for that. Markhobley 23:31, 22 July 2011 (UTC)
What you were saying about "hapless schmuck", etc. was very funny. I'll tell all the other geeks what you said. But, I, being blind, make non-visual programs. With the HTML meta command and the "http-equiv" set to "refresh", the variable sets the content to a number of seconds, followed by ";url=" and then the filename, ".mp3". I've written all kinds of apps like this since 2007, and, with my knowledge of using MediaWiki editing (which I got from editing thousands of other wikis between late 2009 and now), that this is a programmer's wiki paradise. I can write apps, as long as they are original in the RC community. I guess mine ripped off of other ones or something. And what ridiculous person would say, "no more document.write for JavaScript"? That, and it's "writeln" counterpart, are the only way to actually produce HTML that's being manipulated by JavaScript. You know, I'm obsessed with client-side JavaScript. The JS definitive guide doesn't mention HTML "server tags" and server JS. What book would I need for that? Or, better yet, what RC page? Star651 23:52, 25 July 2011 (UTC)
- Eh I know how meta refresh tag works. The input of seconds is counter-intuitive from a program design point of view: normal people are much more comfortable with hour:minute notations when dealing with time span of more than a few minutes, especially so for someone who's already sleepy. The document.write is bad because there's no promise what you write is valid HTML/XML but the text is forcefully injected into the document as source code anyway. It's generally better to manipulate the DOM via document.createElement, document.insertBefore, etc. The refresh is easily done with a
window.setTimeout() { location.href = new_address }
, and while the timer is ticking, you can do other things, even cancel the timer if you want to. Using DOM instead of HTML code has another advantage: you don't invoke a reparse/reflow of the whole document, the browser only need to work with the parent element. Even if you really, really want to produce raw HTML code, you can useelement.InnerHTML = some_html_text
. This way, if something is wrong with the html you produced, only the element is clobbered, and you get a proper error indication unlikedocument.write
. document.write should be considered obsolete in all regards. --Ledrug 00:13, 26 July 2011 (UTC)
No. In 2006 when I started learning JavaScript, I saw document.write so much, that I started picking up my mobile device, slapping my USB flash drives against the keybord, and making "yeee-haw!" sounds. That proves, that document.write is awesome, because you insert regular text into the document. I just upgraded my JS definitive guide from Edition Four to Edition Five, and, in Edition Five, I still see alert and prompt (and document.write). Just name a browser where the command doesn't work, and I'll say it's obsolete. Just one ... browser! And, yes, timers have a seconds button, and I'm representing that. Star651 01:37, 26 July 2011 (UTC)
- When discussing programming, a sentence like "that proves foo is awesome" automatically wins the argument, because that sentence is awesome. You won. --Ledrug 01:56, 26 July 2011 (UTC)
I have just been informed that AudioAlarm, an app that I invented (and submitted here), which was originally written in JavaScript, has been redone using a form of Basic. Whatever anonymous IP did this, thank you! I like it when my work is translated. Just like my Last.FM biography; it's been translated into French, so now people from France (and maybe Canada) can read about my music. Ship it out, boys! Star651 15:39, 15 August 2011 (UTC)