473,394 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

javascript and swf object help - Ajax??

28
I've tried a few things but nothing seems to work, i'm starting to think this isnt possible.

I basically am looking to have the user click on the video number, then have the video load in its own section on the page. I'm currently using iframes as a work around and have been trying to read up on Ajax as another way around it. Problem is, i think using iframes i'm losing important keywords that would usually be right on the page. i initially created the ifram because everytime a user clicked a video number, it had to reload the whole page. plus i rather not use iframes at all if I didn't have to.

Can someone take a look at the code below? Any help is appreciated as usual...

original page I'd like to implement this is at www.dontsnooze.com

I'm testing this code below at www.dontsnooze.com/test

Code doesn't work currently:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <HTML>
  3. <HEAD>
  4.  
  5. <script type="text/JavaScript">
  6. function flashSwitch(flashid, video) {
  7. document.getElementById(flashid).value = "AmosFlash.swf";
  8. document.getElementById(flashid).src = "AmosFlash.swf";
  9. }
  10. </script></HEAD>
  11. <TITLE>Ajax Video Switch Test</TITLE>
  12.  
  13. <BODY>
  14. <center>
  15. <table border=0 cellspacing=20>
  16.  
  17. <object id="ajaxtest" width="550" height="400">
  18. <param id="ajaxtest" name="ajaxtest" value="StickFigureAnimated.swf">
  19. <embed id="ajaxtest" name="ajaxtest" src="StickFigureAnimated.swf" width="550" height="400">
  20. </embed>
  21. </object>
  22. <P>
  23. <input type="submit" value="TRYME" onclick="flashSwitch('ajaxtest','AmosFlash.swf')" >
  24.  
  25. </td>
  26. </tr>
  27. </table>
  28. </center>
  29. </body>
  30. </html>
  31.  
Jan 26 '09 #1
21 5579
gits
5,390 Expert Mod 4TB
you cannot use the same id for different nodes ... just make them unique, and let your function take care of those different ids - then it works. and where is the code related to ajax? ... it's just plain JavaScript-setting of the resource for the object-tag, no ajax is used/needed here.

kind regards
Jan 26 '09 #2
wizdom
28
Thank you for the response I really appreciate it....

I'll give changing the ID's a shot and post the results....

I'm not very familiar with ajax at all but thats what a few people keep running by me. I should have just came here first....

@gits
Jan 26 '09 #3
wizdom
28
So first I tried changing each ID individually and testing, then i tried putting an ID for each (pasted below), the video is not changing onclick. I actually tried a number of combinations. I guess my problem is (and thats if what I'm trying to do is even possible) i'm not sure where to put the ID. In the object tab? or in the param or embed tags? not sure........Any help/suggestions appreciated..heres some code I tried:

One of the first few attempts:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <HTML>
  3. <HEAD>
  4.  
  5. <!-- Switch Video script start -->
  6. <script type="text/JavaScript">
  7. function flashSwitch(flashid1,flashid2) {
  8. document.getElementById(flashid1).value = "AmosFlash.swf";
  9. document.getElementById(flashid2).src = "AmosFlash.swf";
  10. }
  11. </script>
  12. <!-- end switch video script -->
  13. <link rel="stylesheet" type="text/css" href="../ds-style.css">
  14. </HEAD>
  15. <TITLE>Ajax Video Switch Test</TITLE>
  16. <BODY>
  17. <center>
  18. <table border=0 cellspacing=20><tr><td><center>
  19. <object width="550" height="400">
  20. <param id="flashtest1" value="StickFigureAnimated.swf">
  21. <embed id="flashtest2" src="StickFigureAnimated.swf" width="550" height="400">
  22. </embed>
  23. </object>
  24. <P>
  25. <input type="submit" value="SWITCH VIDEO WITHOUT REFRESH" onclick="flashSwitch('flashtest1','flashtest2');">
  26.  
  27. </center>
  28. </td>
  29. </tr>
  30. </table>
  31. </center>
  32. </body>
  33. </html>
  34.  
  35.  

Another attempt with an ID for each:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <HTML>
  3. <HEAD>
  4. <!-- Switch Video script start -->
  5. <script type="text/JavaScript">
  6. function flashSwitch(flashid1, flashid2, flashid3, flashid4, flashid5, video) {
  7. document.getElementById(flashid1).value = "AmosFlash.swf";
  8. document.getElementById(flashid1).src = "AmosFlash.swf";
  9. document.getElementById(flashid2).value = "AmosFlash.swf";
  10. document.getElementById(flashid2).src = "AmosFlash.swf";
  11. document.getElementById(flashid3).value = "AmosFlash.swf";
  12. document.getElementById(flashid3).src = "AmosFlash.swf";
  13. document.getElementById(flashid4).value = "AmosFlash.swf";
  14. document.getElementById(flashid4).src = "AmosFlash.swf";
  15. document.getElementById(flashid5).value = "AmosFlash.swf";
  16. document.getElementById(flashid5).src = "AmosFlash.swf";
  17. }
  18. </script>
  19. <!-- end switch video script -->
  20. <link rel="stylesheet" type="text/css" href="../ds-style.css">
  21. </HEAD>
  22. <TITLE>Ajax Video Switch Test</TITLE>
  23. <BODY>
  24. <center>
  25. <table border=0 cellspacing=20><tr><td><center>
  26. <object id="flashtest1" width="550" height="400">
  27. <param id="flashtest2" name="flashtest3" value="StickFigureAnimated.swf">
  28. <embed id="flashtest4" name="flashtest5" src="StickFigureAnimated.swf" width="550" height="400">
  29. </embed>
  30. </object>
  31. <P>
  32. <input type="submit" value="SWITCH VIDEO WITHOUT REFRESH" onclick="flashSwitch('flashtest1','flashtest2','flashtest3','flashtest4','flashtest5','AmosFlash.swf');">
  33. </center>
  34. </td>
  35. </tr>
  36. </table>
  37. </center>
  38. </body>
  39. </html>
  40.  
@gits
Jan 27 '09 #4
gits
5,390 Expert Mod 4TB
you just need ids for the param and the embed nodes ... currently an error occurs since flashid3 is no id ...

kind regards
Jan 27 '09 #5
wizdom
28
@gits

I thought I did that on my first example but it's not working....can you tell me why this one doesn't work?

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <HTML>
  3. <HEAD>
  4. <!-- Switch Video script start -->
  5. <script type="text/JavaScript">
  6. function flashSwitch(flashid1,flashid2) {
  7. document.getElementById(flashid1).value = "AmosFlash.swf";
  8. document.getElementById(flashid2).src = "AmosFlash.swf";
  9. }
  10. </script>
  11. <!-- end switch video script -->
  12. <link rel="stylesheet" type="text/css" href="../ds-style.css">
  13. </HEAD>
  14. <TITLE>Ajax Video Switch Test</TITLE>
  15. <BODY>
  16. <center>
  17. <table border=0 cellspacing=20><tr><td><center>
  18. <object width="550" height="400">
  19. <param id="flashtest1" value="StickFigureAnimated.swf">
  20. <embed id="flashtest2" src="StickFigureAnimated.swf" width="550" height="400">
  21. </embed>
  22. </object>
  23. <P>
  24. <input type="submit" value="SWITCH VIDEO WITHOUT REFRESH" onclick="flashSwitch('flashtest1','flashtest2');">
  25. </center>
  26. </td>
  27. </tr>
  28. </table>
  29. </center>
  30. </body>
  31. </html>
  32.  
This is now at www.dontsnooze.com/test I'm using firefox to test it.
Jan 28 '09 #6
gits
5,390 Expert Mod 4TB
with my firefox 3.0.5 the link you posted just works as expected? have a look at your error-console ... does any errors occur there? and be sure to clear the cache before testing ... just to avoid that as an issue ...
Jan 28 '09 #7
wizdom
28
@gits

The link I posted is that exact code that i posted in my last post.

I want to be able to click the button, and then the video should change without reloading the whole page....right now, the video is not changing.

Firefox is not giving me any errors for the current code. i did have multiple erros from my first few attempts....
Now, with that said, I'm thinking i need to use 'ajax' for this.... but Ajax is brand new to me, matter of fact, it's still in the store waiting for me to pick it up.....So i'm not sure if thats what I need to do.... but let me know if you have any suggestions

thanks again

FYI, both swf files are in the same folder as the index.php file.

AmosFlash.swf and StickFigureAnimated.swf
Jan 28 '09 #8
gits
5,390 Expert Mod 4TB
as far as i could see it works in FF and not in IE (i used 6) ... currently i don't have time to have a look but it seems that the script couldn't retrieve the nodes by id?
Jan 28 '09 #9
acoder
16,027 Expert Mod 8TB
For quick, easy, cross-browser Flash integration, try out swfobject.
Jan 28 '09 #10
wizdom
28
I also checked and notice i'm using firefox 2.0.0.20 (using that at work) at home I use the latest IE. I'm Dl'ing FF 3.0.5 now. I will also check out swfobject from acoder because ultimately I would like this to work across all (or most) platforms
Jan 29 '09 #11
wizdom
28
Ok it does work in FF 3.0 for me. i will be looking into that swfobject deal.....Thanks. Thanks again acoder also =] you may notice i am using some of the stuff you showed me with my other issue.
Jan 29 '09 #12
wizdom
28
@acoder
Tried swfobject and its perfect. Took me a few to get a basic understanding and I also used JSON (JavaScript Object Notation) - found a really nice demo from google here: http://gdata.ops.demo.googlepages.co...n_codelab.html

Posting it because it was hard to find (unless you knew to search for JSON, which I didn't)

With the javascript stuff I learned from here I was able to tweak the code a bit to get it how I wanted it, with the exception of one thing...

I'm looking for a code example of how to make one of those menu bars such as what youtube does at the end of a played video... the auto scrolling rollover horizontal menu (of videos) on mousehover type deal...I figure I could write code for a simple one tho where you just click next and the next few video menu's load, but just throwing that out there if anyone knows of one off hand.

Thanks again I am grateful =))

results are at www.dontsnooze.com, you can view source to see the swfObject usage and the script i'm using
Jan 31 '09 #13
acoder
16,027 Expert Mod 8TB
If you right-click, you'll notice that it's part of the Flash file. You could do something similar with JavaScript though.
Jan 31 '09 #14
wizdom
28
@acoder
Yes, I know the youtube version is part of the flash, I just used that as an example because it's well known.

I'm playing with the code a bit and have it down to this:

http://www.dontsnooze.com/test

Obviously one long table. I guess what i'll do now is work on getting it at least to a point where it displays the first 5 videos or so, then you will be able to click and show the next 5 videos, while hiding the last....im thinking using innerHTML and as usual I'll post the results if I get it right =}

Any suggestions are helpful!
Jan 31 '09 #15
wizdom
28
Took me a lot of time and reading up but I finally got it. I'm not too proud of the very dirty looking code, but it does work pretty well. I went with a "click to see last 5 or previous 5" option ... the code got pretty detailed and long and drawn out so pasting may not help anyone...but the function is in action at dontsnooze.com and you can view source if interested, or send a pst ... but its basically just an overhaul of the google code demo I posted above (if someone does want me to post I can)

I'm sure theres a number of places where I can fine tune it...I had so many errors trying to get it working that I tried to keep a lot seperated...that plus my noobness heh

Thanks again for the help.. think i'm learning more here than at work/school lol.
Feb 1 '09 #16
acoder
16,027 Expert Mod 8TB
Yes, there could be a few improvements, e.g. there's no need to set the cursor to a pointer for links, it moves by setting it to bold on hover.
Feb 2 '09 #17
wizdom
28
Yes I'm very glad you noticed that.

I've recently made a style sheet in an effort to try to remove some of the elements in that link string. After removing that pointer style line from the links, the video thumbnail lost the pointer on hover.

With that said, I cleaned up the code as best as I could so it doesn't look as bad.

I'm not sure when you checked, but i made a few changes. And now I feel it may be necessary to paste the code so we can be on the same page, and especially since there are a couple pieces I don't understand.....

amosyoutubescript.ds (as of 2/2/09)
Expand|Select|Wrap|Line Numbers
  1. function loadVideo(playerUrl, autoplay, longtitle) {
  2. swfobject.embedSWF(playerUrl + '&rel=1&border=0&fs=1&autoplay=' + (autoplay?1:0), 'player', '550', '400', '9.0.0', false, false, {allowfullscreen: 'true'});
  3.  
  4.   document.getElementById('longtitle').innerHTML = longtitle;
  5.    }
  6. function barSwitch(barNumber){
  7. document.getElementById('videoBarContainer').innerHTML = barNumber;
  8. }
  9.   var totalBarNumber=0;
  10.   var videoBar = new Array();
  11.   var videoBarNumber = 0;
  12.   var videoUrl = new Array();
  13.   var longtitle = new Array();
  14.   var thumbnailUrl = new Array();
  15.   var entry = new Array();
  16.   var title = new Array();
  17.   var videosPerBar = 5;
  18.   var totalVideos=0;
  19. function showMyVideos2(data) {
  20.   var feed = data.feed;
  21.   var entries = feed.entry || [];
  22.   totalVideos = entries.length;
  23.   totalBarNumber = Math.floor(totalVideos / videosPerBar);
  24.   if (totalVideos % videosPerBar != 0) { totalBarNumber++; } 
  25.  for (var p = 0; p < entries.length; p++) {
  26.     thumbnailUrl[p] = entries[p].media$group.media$thumbnail[0].url;
  27.     videoUrl[p] = entries[p].media$group.media$content[0].url;
  28.     entry[p] = entries[p];
  29.     title[p] = entry[p].title.$t.substr(0, 20).replace(/'/gi, "’");
  30.  
  31.     if (p==0) { var firstTitle = entry[p].title.$t.replace(/'/gi, "’");} 
  32.     longtitle[p] = entry[p].title.$t.replace(/'/gi, "’");
  33.  }
  34.  
  35.  for (var i = 0;i < totalVideos;i+=videosPerBar) {
  36.  if (videoBarNumber == 0 && totalVideos < videosPerBar) {
  37.  videoBar[videoBarNumber] = '<table><tr><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[i] + '\', true , \'' + longtitle[i] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[i] + ' " src="' + thumbnailUrl[i] + '" width="65" height="47"/><br><span class="textColorChange">' + title[i] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+1)] + '\', true , \'' + longtitle[(i+1)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+1)] + ' " src="' + thumbnailUrl[(i+1)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+1)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+2)] + '\', true , \'' + longtitle[(i+2)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+2)] + ' " src="' + thumbnailUrl[(i+2)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+2)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+3)] + '\', true , \'' + longtitle[(i+3)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+3)] + '" src="' + thumbnailUrl[(i+3)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+3)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+4)] + '\', true , \'' + longtitle[(i+4)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+4)] + ' " src="' + thumbnailUrl[(i+4)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+4)] + '...</span></a></CENTER></td></tr></table>';
  38.  }
  39.  if (videoBarNumber == 0 && totalVideos > videosPerBar) {
  40.  videoBar[videoBarNumber] = '<table><tr><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar[' + (totalBarNumber-1) + '])"><span class="goGreen">«</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[i] + '\', true , \'' + longtitle[i] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[i] + ' " src="' + thumbnailUrl[i] + '" width="65" height="47"/><br><span class="textColorChange">' + title[i] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+1)] + '\', true , \'' + longtitle[(i+1)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+1)] + ' " src="' + thumbnailUrl[(i+1)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+1)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+2)] + '\', true , \'' + longtitle[(i+2)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+2)] + ' " src="' + thumbnailUrl[(i+2)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+2)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+3)] + '\', true , \'' + longtitle[(i+3)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+3)] + '" src="' + thumbnailUrl[(i+3)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+3)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+4)] + '\', true , \'' + longtitle[(i+4)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+4)] + ' " src="' + thumbnailUrl[(i+4)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+4)] + '...</span></a></CENTER></td><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar[' + (videoBarNumber+1) + '])"><span class="goGreen">»</span></a></CENTER></td></tr></table>';
  41.  }
  42.  if (videoBarNumber != 0 && ((totalVideos - i) > videosPerBar)) {
  43.  videoBar[videoBarNumber] = '<table><tr><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar[' + (videoBarNumber-1) + '])"><span class="goGreen">«</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[i] + '\', true , \'' + longtitle[i] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[i] + ' " src="' + thumbnailUrl[i] + '" width="65" height="47"/><br><span class="textColorChange">' + title[i] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+1)] + '\', true , \'' + longtitle[(i+1)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+1)] + ' " src="' + thumbnailUrl[(i+1)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+1)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+2)] + '\', true , \'' + longtitle[(i+2)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+2)] + ' " src="' + thumbnailUrl[(i+2)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+2)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+3)] + '\', true , \'' + longtitle[(i+3)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+3)] + '" src="' + thumbnailUrl[(i+3)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+3)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+4)] + '\', true , \'' + longtitle[(i+4)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+4)] + ' " src="' + thumbnailUrl[(i+4)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+4)] + '...</span></a></CENTER></td><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar['+ (videoBarNumber+1) + '])"><span class="goGreen">»</span></a></CENTER></td></tr></table>';
  44.         }
  45.  
  46.    if ((videoBarNumber == (totalBarNumber-1)) && i != 0) {
  47.     videoBar[videoBarNumber] = '<table><tr><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar[' + (videoBarNumber-1) + '])"><span class="goGreen">«</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(totalVideos-4)] + '\', true , \'' + longtitle[(totalVideos-4)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(totalVideos-4)] + ' " src="' + thumbnailUrl[(totalVideos-4)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(totalVideos-4)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(totalVideos-3)] + '\', true , \'' + longtitle[(totalVideos-3)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(totalVideos-3)] + ' " src="' + thumbnailUrl[(totalVideos-3)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(totalVideos-4)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(totalVideos-3)] + '\', true , \'' + longtitle[(totalVideos-3)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(totalVideos-3)] + ' " src="' + thumbnailUrl[(totalVideos-3)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(totalVideos-3)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(totalVideos-2)] + '\', true , \'' + longtitle[(totalVideos-2)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(totalVideos-2)] + '" src="' + thumbnailUrl[(totalVideos-2)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(totalVideos-2)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(totalVideos-1)] + '\', true , \'' + longtitle[(totalVideos-1)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(totalVideos-1)] + '" src="' + thumbnailUrl[(totalVideos-1)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(totalVideos-1)] + '...</span></a></CENTER></td><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar[0])"><span class="goGreen">»</span></a></CENTER></td></tr></table>';
  48.  }
  49.  videoBarNumber++;
  50.  }
  51.  if (totalVideos > 0) {
  52.     loadVideo(entries[0].media$group.media$content[0].url, false, firstTitle);
  53.     barSwitch(videoBar[0]);
  54.  }
  55. }
  56.  
  57.  
I want to be able to reference the line numbers so I will post this and ask Q's in another post... I apologize if its spam
Feb 2 '09 #18
wizdom
28
As I stated b4, I used the code from the google code link and editted most of it, just about all of it. So there are a few things I didn't understand...

Expand|Select|Wrap|Line Numbers
  1. Line 20: var feed = data.feed;
variable 'feed' is created, then the "data" that was pulled in is passed thru the variable just created?, or will be passed thru??

I'm not undertanding the line.

Expand|Select|Wrap|Line Numbers
  1. Line 21: var entries = feed.entry || [];
if feed.entry doesn't exist then create a blank array? entries[] ?

And I have the same question as the previous, whats the ".variable" mean at the end of the variable declaration?

And now for the hard part (for me that is)....

From line :43

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  videoBar[videoBarNumber] = '<table><tr><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar[' + (videoBarNumber-1) + '])"><span class="goGreen">«</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[i] + '\', true , \'' + longtitle[i] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[i] + ' " src="' + thumbnailUrl[i] + '" width="65" height="47"/><br><span class="textColorChange">' + title[i] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+1)] + '\', true , \'' + longtitle[(i+1)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+1)] + ' " src="' + thumbnailUrl[(i+1)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+1)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+2)] + '\', true , \'' + longtitle[(i+2)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+2)] + ' " src="' + thumbnailUrl[(i+2)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+2)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+3)] + '\', true , \'' + longtitle[(i+3)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+3)] + '" src="' + thumbnailUrl[(i+3)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+3)] + '...</span></a></CENTER></td><td><center><a onmouseover=\'this.style.cursor="pointer"\' onclick="loadVideo(\'' + videoUrl[(i+4)] + '\', true , \'' + longtitle[(i+4)] + '\')"><span class="textColorChange"><img TITLE="' + longtitle[(i+4)] + ' " src="' + thumbnailUrl[(i+4)] + '" width="65" height="47"/><br><span class="textColorChange">' + title[(i+4)] + '...</span></a></CENTER></td><td><center><a onmouseover="this.style.cursor=\'pointer\'" onclick="barSwitch(videoBar['+ (videoBarNumber+1) + '])"><span class="goGreen">»</span></a></CENTER></td></tr></table>';
  4.  
  5.  
Problems i'm having:
1: if the <A tag doesn't have an HREF element, it doesn't pick up the style, hense the main reason i had to add the seperate style for the video links and img link (thumbnail). But I haven't found another way to include text that's clickable with "on" events in the way that I would like them done.

I can't remember if i tried, but i'll give it another shot: taking the "span" and putting the whole <a> link as well as the image link in between the one span tag.

2: Line 37,40,43,47 (the links):
I get errors anytime i try to put this line on multiple lines (i'm trying to make it easier to read/edit) and then the function doesn't run. - I'm guessing it doesn't like the carriage return?

At first I couldn't figure out what was causing the problem, seemed like sometimes the function was running, and sometimes it wasn't. I ended up removing all the comments I originally had in the code, which I'm kinda kicking myself for now.

3. last but not least, more of a "what do u think" question

Would it be better to write another javascript function that takes most of the info from
"Line 37 (and similar)" ? But it would only be so the code is more readable.

and then, would adding another function add more loading time to the page than if I left it as is?

*EDIT* last last but not least, i'm not getting erros in firefox but...
The way i'm declaring the variables with that long string (line 37 and similar)... is that "acceptable" ? or am I causing a lot of memory usage on the user? or something else thats bad......
========

As you guys know I'm still a little new at javascript/css so if anything pops out to you that I can improve, any suggestions/comments are appreciated
Feb 3 '09 #19
acoder
16,027 Expert Mod 8TB
@wizdom
That's the callback function and data will be a JSON feed, so you can access properties using dot notation.

I'm not undertanding the line.

Expand|Select|Wrap|Line Numbers
  1. Line 21: var entries = feed.entry || [];
if feed.entry doesn't exist then create a blank array? entries[] ?
Yes.

And I have the same question as the previous, whats the ".variable" mean at the end of the variable declaration?
I'm not sure which variable you're referring to here.
Problems i'm having:
1: if the <A tag doesn't have an HREF element, it doesn't pick up the style, hense the main reason i had to add the seperate style for the video links and img link (thumbnail). But I haven't found another way to include text that's clickable with "on" events in the way that I would like them done.
Include the href attribute, but make the function return false in onclick to prevent the link being followed when clicked.

2: Line 37,40,43,47 (the links):
I get errors anytime i try to put this line on multiple lines (i'm trying to make it easier to read/edit) and then the function doesn't run. - I'm guessing it doesn't like the carriage return?
Not within quotes, it doesn't. Close the quote and use + for concatenation.

3. last but not least, more of a "what do u think" question

Would it be better to write another javascript function that takes most of the info from
"Line 37 (and similar)" ? But it would only be so the code is more readable.

and then, would adding another function add more loading time to the page than if I left it as is?
You could improve things by using a function to get rid of the repitition. It may also be good practice to use the DOM rather than strings here. Since this is a relatively small application, it won't make much difference to loading time.
Feb 3 '09 #20
wizdom
28
@acoder
I was referring to the

.entry part of the line in:

Expand|Select|Wrap|Line Numbers
  1. Line 21: var entries = feed.entry || [];
I understand tho that it gives me the entry from the feed of course depending on which entry you select. I guess I don't understand how they are using the "entry" function on this....but it may be something I could check out more inside the swfobject code.

It's minor in the fact that although i don't understand it in detail, I can put it to use. But once again man I really appreciate the responses. I see i have a little work cut out for me that may take me some time... I will post back my improvements tho. thanks!
Feb 5 '09 #21
acoder
16,027 Expert Mod 8TB
I doubt entry will be a function - it'll be a property of feed. Most likely a JSON array.
Feb 5 '09 #22

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: robbi.st | last post by:
hallo, da ich nicht so gut bin in dem, wollte ich mal fragen ob es möglich ist, ein popup via javascript in ajax aufzurufen. bis jetzt ist es mir zwar gelungen, ein popup aufzurufen, jedoch...
2
by: praveen2gupta | last post by:
Hi I wants to make my application compatable with IE7, Its working fine in IE6. But there are a lot of errors while working with IE7. I am using JavaScript and Ajax a lot of places. I would Like...
6
by: subhash9 | last post by:
Is it possible to write client side validations with out using javascript or ajax.
3
by: venkat bandla | last post by:
tell me the differences between JavaScript and AJAX
1
by: satyanand | last post by:
hi, Can anybody give me the book and author name which have the combined code and description of "Javascript / DHTML / Ajax" . I need it very much. Thanks..... Satyanand Verma Software...
9
by: TechnoAtif | last post by:
<form name=frm action="" method="post"> <table> <tr><td><select name=combo> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <td><input type="text"...
23
Frinavale
by: Frinavale | last post by:
JavaScript is a very strange place for me... So, I decided that, before I attempt to create an Object, I should first learn about Objects. I had actually created one before with the help of a...
3
Frinavale
by: Frinavale | last post by:
I've created a few ASP.NET Ajax Enable Server controls. There are 2 components to these controls: a server side Object that deals with the server side stuffs, and a client side Object that deals...
1
by: intermanch | last post by:
how call function php($varible) into javascript withod ajax: <!-- this code only call funnctions php but how call function php intermanch@gmail.com www.intermanch.blogfa.com
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.