Jump to content

davej

Moderator
  • Posts

    3,988
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by davej

  1. I have only implemented MVC in Java. JSP pages presented the view. Submits were directed to servlets which were the controllers. "Business" classes used by the servlets were the models. In addition I wanted to have the database isolation of the 3-tier scheme so I tried to get all SQL code out of the servlets and into a dedicated DB class. I don't know if there is actually a name for trying to do both? [Models and Database] <=====>[Controller] <=====> [View]
  2. Oh, that pretty much answers it. I thought they didn't quite match up. So in the MVC if a data-access class is used and all data accesses pass through it, would that satisfy both schemes?
  3. Seems like these are almost the same idea?
  4. A great website is one that provides the information you need. No Photoshop necessary. Now maybe if you want a "beautiful and artistic" website you will need Photoshop and a person with artistic talent... But for most websites that just need simple resizing, cropping, thumbnailing, and tweaking of photos something as simple as Irfanview will work fine.
  5. davej

    NEED HELP!

    Did you actually write this code? I am amazed that anyone could take something so simple and make such a complex mess out of it. Maybe you could delete all the Javascript and start over? EDIT- Maybe I am being too harsh. Maybe this was created using Dreamweaver? That tool often produces messy and almost unreadable code.
  6. Too many iphone imitators -- some people even want the image to bounce to a stop like a basketball. No thanks. A title and description field above or below the photo would be good. Some displayed EXIF data would be good.
  7. Compiled? Do you mean compressed / obfuscated? I would not mind a slight transition effect as long as it is quick and not distracting.
  8. This example looks pretty straightforward... http://www.codeproject.com/Articles/12218/Web-Based-Image-Slideshow-using-JavaScript
  9. Well, I ended up with a simple slideshow in the other thread. Actually several slideshows have been posted recently http://w3schools.invisionzone.com/index.php?showtopic=44146http://w3schools.invisionzone.com/index.php?showtopic=43766http://w3schools.invisionzone.com/index.php?showtopic=42971
  10. So does image caching occur if you simply read that image before it is needed? What if I wanted to prefetch the next few images as the slideshow is running? Would I simply add... var fullpreload = new Image();function timer(){$(p[tmrcnt]).style.backgroundColor='';tmrcnt++;if (tmrcnt >= plen){tmrcnt=0;}$('large').style.backgroundImage="url('" + full[tmrcnt] + "')";$(p[tmrcnt]).style.backgroundColor='#00F';tmr=setTimeout("timer()",2000);// millisecondsif (tmrcnt+1 >= plen){fullpreload.src = full[tmrcnt+1];}if (tmrcnt+2 >= plen){fullpreload.src = full[tmrcnt+2];}} ...Or maybe I need to declare and use fullpreload1 and fullpreload2 ?
  11. JS can't see files.
  12. I'm curious where document.write() output really goes? Creates new document? Adds to end of document? I don't think I've ever used it in JS but several other languages have very similar commands.
  13. Thanks Dsonesuk! I've dumbed that down and produced this: <html> <head> <title>Slideshow</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">#large {width:448px; height:336px; background:#000 no-repeat center; }#thumbs {padding-top:12px; overflow:auto; white-space:nowrap; width:448px; }img {padding:1px; width:80px; height:60px;}img:hover {background:#00F;}</style><script type="text/javascript" src="jonerror.js"></script><script type="text/javascript" src="jphotolist.js"></script><script type="text/javascript">var p= new Array();var plen;var run=false;var tmrcnt=0;var tmr;var i; window.onload=function(){plen=full.length;var thumb_img;for(i=0 ; i<plen ; i++){p[i] = "p" + i;thumb_img=document.createElement("img")thumb_img.src=thumb[i];thumb_img.onclick=f;thumb_img.id="p"+i;thumb_img.alt="p"+i;$('thumbs').appendChild(thumb_img);}$('ssbtn').onclick=btnf;$('large').style.backgroundImage=full[0];//alert('Init success');}function f(){if (!run){i=0;while(i<plen){if(this.id==p[i]){$('large').style.backgroundImage=full[i];setborder(this);}i++;}}}function $(id){return document.getElementById(id);}function setborder(e){var i;for(i=0 ; i<plen ; i++){$(p[i]).style.backgroundColor='';}e.style.backgroundColor='#00F';}var run = false;var tmrcnt;var tmr; function btnf(){if (!run){for (i=0 ; i<plen ; i++){$(p[i]).style.backgroundColor='';}tmrcnt=plen-1;timer();run=true;$('ssbtn').style.backgroundColor='#77F';}else{clearTimeout(tmr);run=false;$('ssbtn').style.backgroundColor='';}} function timer(){$(p[tmrcnt]).style.backgroundColor='';tmrcnt++;if (tmrcnt >= plen){tmrcnt=0;}$('large').style.backgroundImage=full[tmrcnt];$(p[tmrcnt]).style.backgroundColor='#00F';tmr=setTimeout("timer()",2000);// milliseconds}</script></head> <body> <div id="large"></div> <div id="thumbs"></div> <input type="button" id="ssbtn" value="Slideshow"/> </body></html> Where the image list is a separate file named jphotolist.js... var full= new Array();var thumb= new Array(); full[0]="url('http://lh5.googleusercontent.com/-ugFamEhbqPo/Thc6hoArbwI/AAAAAAAAABA/PFeHcJhR4Xw/s800/image1.jpg')";full[1]="url('http://lh3.googleusercontent.com/-u5BHGxpr0rg/Thc6hLbDRKI/AAAAAAAAAA8/IvQWzJBvqjg/s800/image2.jpg')";full[2]="url('http://lh4.googleusercontent.com/-4AMWSfi8q7A/Thc6haUv1QI/AAAAAAAAABE/oRdTWawPi_c/s800/image3.jpg')";thumb[0]='http://lh3.googleusercontent.com/-hUXeHq5OxEo/Thc7hFFv3gI/AAAAAAAAABQ/Yh7omR8iwzI/s800/thumb1.jpg';thumb[1]='http://lh3.googleusercontent.com/-JU5a-eDnOSg/Thc7g5UkwLI/AAAAAAAAABI/9aCyCMixWb4/s800/thumb2.jpg';thumb[2]='http://lh4.googleusercontent.com/-TdbbNGFbDNk/Thc7g0IBSsI/AAAAAAAAABM/pxpntZaTVoQ/s800/thumb3.jpg';
  14. Works for me using Chrome.
  15. If you have a div with an id of "thumbs" how would you add an arbitrary number of thumbnail images inside that div using JS? I tried innerHTML but it didn't entirely work. Is this a job for createElement or addChild? <script type="text/javascript">var thumb= new Array();var p= new Array();var pmax;var i;thumb[0]='http://lh3.googleusercontent.com/-hUXeHq5OxEo/Thc7hFFv3gI/AAAAAAAAABQ/Yh7omR8iwzI/s800/thumb1.jpg';thumb[1]='http://lh3.googleusercontent.com/-JU5a-eDnOSg/Thc7g5UkwLI/AAAAAAAAABI/9aCyCMixWb4/s800/thumb2.jpg';thumb[2]='http://lh4.googleusercontent.com/-TdbbNGFbDNk/Thc7g0IBSsI/AAAAAAAAABM/pxpntZaTVoQ/s800/thumb3.jpg';pmax=full.length-1;window.onload=function(){for(i=0 ; i<=pmax ; i++){p[i] = "p" + i;$('thumbs').innerHTML+='<img id="' + p[i] + '"/>';$(p[i]).src=thumb[i];$(p[i]).onclick=f;alert(p[i] + " was created");}}</script></head><body><div id="large"></div><div id="thumbs"></div><input type="button" id="ssbtn" value="Slideshow"/></body>
  16. Another version: <html><head><title>Slideshow</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">#large {width:448px; height:336px; background:#000 url(http://lh5.googleusercontent.com/-ugFamEhbqPo/Thc6hoArbwI/AAAAAAAAABA/PFeHcJhR4Xw/s800/image1.jpg) no-repeat center; }#thumbs {padding-top:12px; overflow:auto; white-space:nowrap; width:448px; }img {padding:1px; width:80px; height:60px;}img:hover {background:#00F;}</style><script type="text/javascript" src="jonerror.js"></script><script type="text/javascript">var full= new Array();var thumb= new Array();var p= new Array();var pmax=2;var run=false;var tmrcnt=0;var tmr;full[0]="url('http://lh5.googleusercontent.com/-ugFamEhbqPo/Thc6hoArbwI/AAAAAAAAABA/PFeHcJhR4Xw/s800/image1.jpg')";full[1]="url('http://lh3.googleusercontent.com/-u5BHGxpr0rg/Thc6hLbDRKI/AAAAAAAAAA8/IvQWzJBvqjg/s800/image2.jpg')";full[2]="url('http://lh4.googleusercontent.com/-4AMWSfi8q7A/Thc6haUv1QI/AAAAAAAAABE/oRdTWawPi_c/s800/image3.jpg')";thumb[0]='http://lh3.googleusercontent.com/-hUXeHq5OxEo/Thc7hFFv3gI/AAAAAAAAABQ/Yh7omR8iwzI/s800/thumb1.jpg';thumb[1]='http://lh3.googleusercontent.com/-JU5a-eDnOSg/Thc7g5UkwLI/AAAAAAAAABI/9aCyCMixWb4/s800/thumb2.jpg';thumb[2]='http://lh4.googleusercontent.com/-TdbbNGFbDNk/Thc7g0IBSsI/AAAAAAAAABM/pxpntZaTVoQ/s800/thumb3.jpg';p[0]='p1';p[1]='p2';p[2]='p3';window.onload=function(){$('p1').src=thumb[0];$('p2').src=thumb[1];$('p3').src=thumb[2];$('p1').onclick=f1;$('p2').onclick=f2;$('p3').onclick=f3;$('ssbtn').onclick=fss;//alert('Init success');}function f1(){$('large').style.backgroundImage=full[0];setborder(this);}function f2(){$('large').style.backgroundImage=full[1];setborder(this);}function f3(){$('large').style.backgroundImage=full[2];setborder(this);}function $(id){return document.getElementById(id);}function setborder(e){$('p1').style.backgroundColor='';$('p2').style.backgroundColor='';$('p3').style.backgroundColor='';e.style.backgroundColor='#00F';}var start1;var run = false;var tmrcnt = 0;var tmr;function fss(){if (!run){tmrcnt=0;timer();run=true;$('ssbtn').style.backgroundColor='#77F';}else{clearTimeout(tmr);run = false;$('ssbtn').style.backgroundColor='';}}function timer(){$(p[tmrcnt]).style.backgroundColor='';tmrcnt = tmrcnt + 1;if (tmrcnt > pmax){tmrcnt = 0;}$('large').style.backgroundImage=full[tmrcnt];$(p[tmrcnt]).style.backgroundColor='#00F';tmr=setTimeout("timer()",2000);// milliseconds}</script></head><body><div id="large"></div> <div id="thumbs"><img id="p1" /><img id="p2" /><img id="p3" /></div><input type="button" id="ssbtn" value="Slideshow"/></body></html>
  17. Oops. I thought I had tested that but apparently not correctly. Thanks.
  18. Most of the JS I have written have been event-driven validators and I am curious if it is possible to save variable values while the code is not executing? I mean if you use window.onload to set up some values and then later an onclick event fires some code that needs those values. How can that be done? Are there several options? I see that I can assign values to hidden HTML fields to accomplish this but that seems a little hokey. Thanks.
  19. This seems to work: <html><head><title>Slideshow</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">#large {width:448px; height:336px; background:#000 url(http://lh5.googleusercontent.com/-ugFamEhbqPo/Thc6hoArbwI/AAAAAAAAABA/PFeHcJhR4Xw/s800/image1.jpg) no-repeat center; }#thumbs {padding-top:12px; overflow:auto; white-space:nowrap; width:448px; }img {padding:1px; width:80px; height:60px;}img:hover {background:#00F;}</style><script type="text/javascript" src="jonerror.js"></script><script type="text/javascript">window.onload=function(){$('p1').src='http://lh3.googleusercontent.com/-hUXeHq5OxEo/Thc7hFFv3gI/AAAAAAAAABQ/Yh7omR8iwzI/s800/thumb1.jpg';$('p2').src='http://lh3.googleusercontent.com/-JU5a-eDnOSg/Thc7g5UkwLI/AAAAAAAAABI/9aCyCMixWb4/s800/thumb2.jpg';$('p3').src='http://lh4.googleusercontent.com/-TdbbNGFbDNk/Thc7g0IBSsI/AAAAAAAAABM/pxpntZaTVoQ/s800/thumb3.jpg';$('p1').onclick=f1;$('p2').onclick=f2;$('p3').onclick=f3;//alert('Init success');}function f1(){$('large').style.backgroundImage="url('http://lh5.googleusercontent.com/-ugFamEhbqPo/Thc6hoArbwI/AAAAAAAAABA/PFeHcJhR4Xw/s800/image1.jpg')";setborder(this);}function f2(){$('large').style.backgroundImage="url('http://lh3.googleusercontent.com/-u5BHGxpr0rg/Thc6hLbDRKI/AAAAAAAAAA8/IvQWzJBvqjg/s800/image2.jpg')";setborder(this);}function f3(){$('large').style.backgroundImage="url('http://lh4.googleusercontent.com/-4AMWSfi8q7A/Thc6haUv1QI/AAAAAAAAABE/oRdTWawPi_c/s800/image3.jpg')";setborder(this);}function $(id){return document.getElementById(id);}function setborder(e){$('p1').style.backgroundColor='';$('p2').style.backgroundColor='';$('p3').style.backgroundColor='';e.style.backgroundColor='#00F';}</script></head><body><div id="large"></div> <div id="thumbs"><img id="p1" alt="p1" /><img id="p2" alt="p2" /><img id="p3" alt="p3" /></div></body></html> jonerror.js is a file containing://pre-load the javascript error handlerwindow.onerror = function(m, u, l){ alert('Javascript Error: '+m+'\nURL: '+u+'\nLine Number: '+l); return true; //supress fallback error-msg if true}
  20. How would you give Javascript the array of image names/paths so that it could build the table? Otherwise this looks very simple.
  21. I've googled this topic and there is some material out there. I guess I never thought about it for Javascript. I guess if you consider your validators to be models?
  22. So if I use window.onload to assign a button to an onclick function then inside that function "this" is the button? I have used event.target to identify which element called a function.
  23. I have not used "this" in JS and it seems a bit confusing because I'm not sure we are always dealing with objects here. Is an HTML tag an object? Some examples look rather strange. At http://www.quirksmode.org/js/this.html the following code is suggested... HTML:element.onclick = doSomething; Javascript:function doSomething(){this.style.color = '#cc0000';} Ok, since no parameter is passed "this" is what? The current document? The HTML document? The HTML tag? Isn't there a more clear and obvious way to accomplish the same thing?
  24. davej

    New to this

    So it is Wordpress? I see Wordpress mentioned in the source and two links to ,php files. It maintains .com in the address bar.
  25. davej

    New to this

    <a href="/?page_id=83"><div id="bottombox1"> Campaign Updates</div></a> I have never seen this before. The href="/?page..." looks like a GET. Does a link in this form submit a GET? Is this GET intercepted by jQuery? Thanks.
×
×
  • Create New...