Jump to content

MikeatW3S

Members
  • Posts

    50
  • Joined

  • Last visited

Posts posted by MikeatW3S

  1. You can use a span or a div, but using CSS to set the color or font-weight properties won't have any effect on borders, there are other properties for border styles.

    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. 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. Papers have been written about how that's a bad design, you're essentially using goto. It sounds like you need to check regardless, you're just moving the location of the checks. If you want to show your code there's a way to avoid doing that.I don't think there's a way to use a variable as a label.

    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. The DOM doesn't have a representation for columns, only rows. You would need to loop through all of the rows and apply the class to the cell in each one.For syncing, you can use the timeupdate event to run an event handler when the time changes, although you'll need to try to keep execution of that event handler as short as possible.https://developer.mozilla.org/en-US/docs/Web/Events/timeupdate

     

    What's wrong with setting a time interval and checking the currentTime() of the audio file every so often?

  6. table works by td cells in a row, not columns, you would have to reference a table by class or id and then i think using nth-of-type() (maybe adding additional classname representing the column to target) class would be a better option to highlight specific td cells in each tr row that would make up the column.

     

    There several option available here.

    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. 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. 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. 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.

  13. 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.

  14. iframes have been around for a long time, I can't name a desktop browser off the top of my head that doesn't support them. IE6 supported them, I'm not sure about IE5.

     

    Wouldn't I have to open the parent first before opening the child which has the text? Then what URL do I instruct people to link to, the parent or the child? I'd like them to go directly to the child with the text so that the parent with the audio is not even noticed by visitors (if possible). Can I actually open a parent iframe from within a child? I hope you can see my confusion about this.

  15. All you really need for the iframe solution is this:

    <audio><iframe src="page.html"></iframe>

    Then use CSS to hide the audio element and make the iframe take the full size of the window.

     

    From what I"ve seen on the net. I'm not sure what code would be browser independent. I'm trying to get things to work in IE11, Firefox, and Chrome. I've already got cookies and controls working in these browsers. But I don't know about iframes.

     

    If I had sample code I could try to open a parent and control, say, some text element in the parent from the child, I would probably go with that. If you can't easily cut and paste some code here, what search terms would I look for to google this? Thanks much.

  16. Is there a way to have the background image fade in and out to a white plain background? Hopefully there are statements to that effect that I can employ.

     

    Is there a way to anchor the background image at, say, the upper right corner of the page, no matter how the user sizes the window? I hope there is because this would make editing very easy. Thanks.

  17. What do you not like about the <iframe> solution?

     

    learning curve. The only thing I would have to learn about my suggestion would be how to open a new window, which sounds kind of easy compared to learning about iframes. The only problem I see with my suggestion is what happens with slow connections, how long do a wait with the background page playing before deciding to shut it down. Another problem might be what happens if a user opens more than one text page. But then again perhaps iframes are not that hard to learn.

  18. How about this:

     

    When I click the button to start the background music in the original page, it opens another page in a new window. This new window will continue to be open and operate even if the original window closes, right? Then I communicate between the two windows with cookies. The original page can set cookies every 500ms according to how loud and whether the background should play. And the background page can fetch the cookies every 500ms to set user preferences. If the original page should be closed and no longer update cookies, then the background page can detect this lack of updating and close as well. Does anyone see a problem with this idea? Thanks.

  19. If you create a new window with window.open() you can refer to it from the child window using window.opener.

     

    iframes can access parent windows using window.parent or window.top

     

    Does this allow me access to the <audio> elements in the parent from inside the child?

     

    How would I possibly close the parent without also closing the child? Thanks again. This is all very constructive.

  20. The code runs as soon as the browser reaches that point in the file, it doesn't download everything and then execute it. If you're using a particular variable then it does need to be defined in that scope.

     

    Does this mean that the code on each page should not refer to the separate js script before the js file loads? Do I have to somehow stop execution of code until the js file loads? When does the js file load, when it is called for in a page? Or does it load after it is done loading the present page? Thanks again.

  21. If you have code that needs to run on multiple pages it's best to put it in a separate file and include it on each page. That way the browser can cache it so that it doesn't need to keep downloading the same thing. You can give the URL of the script file inside a script tag.

     

    I have the page being refreshed from the server each time it is accessed. Otherwise it takes two button clicks to start audio if it is arrived at by a back or forward or refresh button. The first button click restarts the code and places the page at the top. Then the second click starts playing audio and scrolling. So I wonder if I would be downloading a new copy of the separate js file with every access of the page or with every press of the refresh button? Is this right?

×
×
  • Create New...