Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About MikeatW3S

  • Rank
  1. Execute code based on time in audio

    Span might work, but I think div inserts a carriage return last I checked. Is it the case that <span>contents</span> won't do anything to the contents; it's "neutral", right?
  2. Execute code based on time in audio

    If I put a class attribute in the <tr> or <td> tags, in order to change the color or bold font, then the color of the black table-cell boarders will also change. I don't want to change the table, just the contents of each cell. So I think I have to put a tag on just the contents of each cell. So is there a neutral HTML element that I can put inside each cell that I can attach multiple classes inside? For example, can I do this: <a class="row1 column1 cell1"></a>cell 1 contents...?
  3. I was thinking more in the lines of a hash-table like this: var foo = '35'; // where 35 is the number of tenths of a second into the audio file. var cases = {}; cases['10'] = function() { code for 1.0s; }; cases['25'] = function() { code for 2.5s; }; cases['35'] = function() { code for 3.5s; }if(typeof cases[foo] == 'function') { // only executes for foo = 3.5 seconds. cases[foo]();} else { // default (the fallthrough)} Then only the code associated with a time to change text will execute, and nothing more. Of course I'd have to execute the if(typeof cases[foo] == 'function') { code every 10th of a second, or faster. This looks like what a jump table would do. But I'm not sure what the processor would do. Would a processor actually go through the list from top to the right case['35']? After all, a processor has to find cases['35'] out of all the possibilities, right?
  4. Yes, I know goto is not best practice, messy code, hard to follow, etc. But how else would one construct a vector jump table, that jumps to some address/label based on the offset into some table, i.e. based on some expression? Otherwise, I may have hundreds of decisions to make every 10th of a second. I don't know how much that may unnecessarily overwork the processor.
  5. Execute code based on time in audio

    What's wrong with setting a time interval and checking the currentTime() of the audio file every so often?
  6. Execute code based on time in audio

    So would I add a class="row1" to the first <tr> tag and then a separate class="column1", "2", "3" to each of the <td> tags in each of the 3 column, for example? Or don't the <td> and <tr> tags admit a class attribute?
  7. Execute code based on time in audio

    Yea, I know, alert()s would stop execution. Thanks. Now I wonder, if I'd like to highlight a column and separately highlight a row, how would I refer to each separately? Can I attach a div or type or class or id to each entry in the table and then get element by column name or row name?
  8. I'd like to execute code depending on some expression, and no other code than that. I don't want to go through a lot of checking before deciding whether or not to execute each section of code. I'd like to simply evaluate and expression, and depending on what it is go directly to the appropriate code. How do I do that?
  9. Suppose I'd like to jump out of a loop to a number of different places in the code. Each of those places start under a different label. Can I create a variable that somehow evaluates to the text of one of the label names and use that variable in the "continue label;" to jump to the code under that label? Or will continue only use the text of the label and not consider what text that label may evaluate to?
  10. Execute code based on time in audio

    Maybe a hash-table will work for me var foo = '35'; // where 35 is the number of tenths of a second into the audio file. var cases = {}; cases['10'] = function() { alert('I am A!'); }; cases['25'] = function() { alert('I am B!'); }; cases['35'] = function() { alert('I am C!'); }if(typeof cases[foo] == 'function') { // only executes if we've defined it above cases[foo](); // I am C!} else { // default (the fallthrough)} Then only the code associated with a time to change text will execute, and nothing more. Of course I'd have to execute the if(typeof cases[foo] == 'function') { code every 10th of a second, or faster.
  11. I want to use an audio file to explain a table. This will mean that I will use javascript to highlight text (change color, make bold) at certain time points in the audio. There could be 100 time points in the audio file where I will need to change text and put it back again. I probably need to check the audio file time stamp every third of a second in order to make the table entry blink on and off as I am talking about it. So I don't want to spend a lot of processor time going through a bunch of if-then statements until I match the right time interval. I'd like to simply execute code at the right time. What can I do? I wonder if I can add an event listener to watch for certain times in the audio. I haven't seen any reference to this on the web. Maybe I can use the switch-case statement. Here I can check the currentTime() every third of a second, average that time to the nearest tenth of a second, and make a case statement only for the times (labelled by the number of tenths-of-a-second) where I need to change things. But I don't know if the switch-case statement runs through all the possible cases before getting to the case statement that matches the time. Or does the switch-case simply jump to the right case depending on an expression. If not, is there any javascript structure that does jump to code based on expression? Or can I dynamically eliminate previous case statements from the code when done with them? Your help would be appreciated. Thanks.
  12. Background audio that survives page transition

    After I hyperlink to the background music page in a new window, what command can I put in a onclick button function of that new window to go back to the previous text window?
  13. Background audio that survives page transition

    It turns out that using window.open() to create a new window that is hidden in the background (even to play music) is frowned upon because it's called a popup. And many browsers default to blocking popups. I've tried everything to take the focus off the newly opened page (where the music is) and put the focus back on the original page (with the text). But nothing seems to work across all browsers. Plus I'd have to ask the visitor to enable popups for my site in order to do this. So I need to find another way. So perhaps I can create a button that is a hyperlink that opens link in new window. And then once the new window is open I can change the button to an onclick="myfunction()" that just displays this newly opened background music page so that the visitor can adjust the background. Can I change the button type with javascript from an <a href...> to an onclick="myfunction()"? I know you can add attributes later in the program with javascript. But I need to stay away from the window.open() statement because popups may be blocked. Any help is appreciated. Thanks.
  14. To synchronize vertical scrolling with audio file

    I'm wondering, since javascript is interpreted by the user's browser at run time and not first compiled, should variables and functions be given the shortest possible names? Should I go through the code and able variable as v1, v2, v3, etc., and functions as f1, f2, f3, etc? Would this make the javascript run faster?
  15. Background audio that survives page transition

    Thank you, justsomeguy, The problem is that my current pages have been around awhile and many may have links to particular text pages. So I'd like to not generate an error for them if I now make all the pages only accessible from the url of a parent page. So my inclination at this time is to simply open a new page from the text pages, not as an iframe, but as an entirely new independent page that will stay open even during text page transitions. I've seen this done before where I have to go and separately close the newly created window after closing the creating window. This new page will have the audio in it, and I can communicate settings using cookies. I think I already know how to do all that. Thanks for all your help.