Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. Yup, but with jQuery. I mean, functionally, there should be no difference between: $.get('slideshow.php', function(data){ var images = $.parseJSON(data); for(var image in images){ // used for..in here because my keys were unix timestamps. $('#slideshow').append('<img src="images/' + images[image] + '" alt="" />'); } }); and $.getJSON('slideshow.php', function(images){ for(var i = 0; i < images.length; ++i){ $('#slideshow').append('<img src="images/' + images[i] + '" alt="" />'); } });
  2. Actually, I 'figured' it out. It looks like using $.getJSON did the trick. Not exactly sure why, as my returned JSON is exactly the same. Must have something to do with the way it's parsed. $.getJSON parses it automatically, so there must be some slight difference between that and me manually parsing it.
  3. It works fine with static images being manually injected/jQuery-appended into the container div. Regarding the Chrome issue, where the last image is shown first, it looks like it's a bug with how Chrome itself parses JSON. The JSON my PHP script returns is in the right order. Alerting it in Chrome shows that it is. Once the JSON is parsed, that's when the error occurs. It still happens regardless of whether I use JSON.parse or jQuery.parseJSON. At least it looks like it isn't something on my end.
  4. I'm currently trying to create a simple carousel navigation pane/window/box/whatever for a client. He wants it to be as simple as possible to setup, so we agreed on a dumb "I upload images to a specific folder, the code does the rest" system. The PHP portion works fine. I can obtain the images, stuff their file names in an array, and json_encode them without a hitch. My problems come from Cycle. I have two main issues: 1. The images don't fully load on the first visit. I thought it was a runtime issue, but even after using a timeout, the problem remains. What's odd is that I can see a portion of the images, and can see them animating properly, but it's only on subsequent viewings that the images are fully visible. 2. In addition to problem 1, Chrome shows the last image first. Bwaaah...? I've spent the good portion of two days trying to debug this. I've read most of what counts as documentation on the Cycle site (horrendous, btw), and attempted to incorporate its simplistic demo code into mine. I've attempted to hook my ajax into Cycle's exposed callbacks. Hell, I've even shown my code to the plugin's developer and talked to him on Twitter about it. No luck. I'm just about ready to ditch it and get another carousel solution, but since it's half working, I figure I'd give it one last shot. So, below is my code. I await the verdict. <!doctype html> <html lang="en-us"> <head> <title>jQuery Cycle test</title> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js/jquery.cycle.all.min.js"></script> <style> #slideshow a { margin: 0; padding: 0; color: #fff; display: block; } img { width: 305px; height: 278px; } </style> </head> <body> <div id="slideshow"> </div> </body> <script type="text/javascript"> $.get('slideshow.php', {start : "true"}, function(data){ var images = JSON.parse(data); for(var image in images){ $('#slideshow').append('<a href="images/' + images[image] + '"><img src="images/' + images[image] + '" alt="" /></a>'); } $('#slideshow').cycle({fx: 'cover', direction: 'right', timeout: 3000, speed: 300}); }); </script> </html>
  5. First, again, 'false' is not the same as false. The first is a string which, if tested in a conditional, will actually return true. Logical true and false do not have quotes around them. Second, again, global is a bad idea. Instead of using it, rewrite the function in question to accept an extra parameter, like so: function in_this_instance($data, &$inInstance) { $rep_val = '[front banner]'; $test = strpos($data, $rep_val); if ($test === false) { $inInstance = false; return $data; } else { $inInstance = true; return $data; } } $in_this_instance = false; $data = in_this_instance($data, $in_this_instance); The '&' before $inInstance denotes a reference. This allows one to modify the value of a variable without returning it from a function, as you have a reference to the original variable rather than a copy (which is what you get with normal argument passing). More info: http://php.net/manual/en/language.references.pass.php
  6. Welcome to alt.lifestyle.phpfreaks....
  7. I don't know how the economy is in Australia, but in the States things are pretty tight. Competition is high and there are lots of very qualified people without jobs. Freelancing may be your best option now, if your situation is similar. At the very least you'll be making extra $$ and will gain some level of work experience. Also, development is a very social job. See if you can find a local geek lunch meeting, BarCamp meeting, or some other way to network with people in the business. It's a good way to make professional contacts and at least throw your name in the pool. And after, follow these guys on Facebook and/or Twitter and join in the meta conversation. Even if you only listen to them, many will share great links that will help you as a developer. Hell, I follow some guys just to follow the links they throw out there. Example: I'm working on a very simple slideshow navigation system for a graphic designer in exchange for graphics work on some of my other projects. It's one of those image boxes that a lot of sites have (most sports sites, Gamespot, etc). I have a prototype working, but want to be able to show the images in the order they were uploaded. If it wasn't for Twitter, I wouldn't have known about linq.js, which will allow me to order the returning JSON object's image file information by the last modified date using LINQ-like syntax (say what you want about Microsoft and/or C#, but LINQ is pretty damn sweet). It's going to save me a ton of time, and it's another tool for my toolbox in general. So, get out there, be social, do freelance work in the meantime.
  8. Don't use HTML to re-size your images. Make them the proper size in your image editing software. Why? Because the browser has to download the full big image before HTML adjusts the size. That severely increases load time.
  9. KevinM1

    HELP!

    Ouch. Yeah, that's pretty bad. From what it looks like, there was a rather generic template that's been shredded with items that don't fit and look ugly (plain Times New Roman everywhere, the 'Online Classes and Resources' (seriously, what happened there?), smooshed Facebook images, boring stock images...). Overall, it looks very amateurish and dated. Like something from 1998. If I was in need of consumer credit counseling, your agency would not be my first choice based on what I see. I'm also curious as to why the site is written in classic ASP. No one uses that any more. Use PHP, Python, or, if you're stuck with Microsoft, ASP.NET MVC. Whatever you're paying Niko Software, it's too much. You're getting ripped off.
  10. Just for education's sake, PHP actually uses both, but they have different operator precedences. See: http://www.php.net/manual/en/language.operators.comparison.php http://www.php.net/manual/en/language.operators.logical.php
  11. This is my very simple script: <?php echo "<script language="JavaScript" src=""></script>"; ?> I have not posted the full script as it is a affiliate link script. Thanks in advance The problem is with your quotes. You can't use double quotes to both denote a string and have double quoted text within the string. You need to do one of two things: 1. Mix in single quotes 2. Escape the double quotes within the string So... 1. echo '<script language="Javascript" src=""></script>'; 2. echo "<script language=\"Javascript\" src=\"\"></script>";
  12. Try: $(function () { $('#pause').click(function() { $('#slides').cycle('pause'); return false; }); $('#play').click(function() { $('#slides').cycle('resume'); return false; }); $('#slideshow').hover( function() { $('#controls').fadeIn(); }, function() { $('#controls').fadeOut(); } ); $('#slides').cycle({ fx: 'all', speed: 400, timeout: 1000, next: '#next', prev: '#prev', after: onAfter }); }); function onAfter(curr, next, opts) { var index = opts.currentSlide; if (index === (opts.slideCount - 1)) { $('#slides').cycle('pause'); } } Code not tested, but I was suggesting something along those lines.
  13. ok i drop autostop but idont know how to stop after i show the last picture Like I said, look at the 'after' callback function and try putting in a pause command after your last image is shown. The website has a bunch of tutorials on it, one specifically showing how the 'after' callback works.
  14. Are you using Firebug? Can you pinpoint exactly where (line number) the error is occurring?
  15. Are you sure the session variables aren't being set? Have you tried echoing them?
  16. You still need to remove autostop. Autostop locks the number of cycles you can loop through. If you set it to 1, that's all you'll get to show. See if you can use the after callback to pause the loop after the last image has been shown. This should let the play button act the way you want it to act.
  17. Again, remove your autostop property. Autostop means "Stop the loop after X cycles." You have an autostop value of one, which means the loop will end after one cycle.
  18. Okay, well, the obvious answer then is that you don't have a way to restart your loop. Your play button only resumes the loop if it's paused. You'd probably be best served reading the Cycle plugin's documentation. EDIT: looking at the documentation myself, it seems that your autostop property is the culprit: http://jquery.malsup.com/cycle/options.html Take it out if you want an infinite loop.
  19. You have a JavaScript error. The function restart() is not defined. Could be causing your problem.
  20. In light of your immense contributions to this site, I've made you a guru. I dunno. He's clearly more of a Recommended to me.
  21. First, with the economy in the toilet, you're going to face a lot of competition. Experience will be a key factor, and you don't have much. There are people with years of experience having trouble finding stable employment. It sucks, but that's the reality of the situation. Second, one project is not a portfolio. You said you completed the project 2-3 years ago and maintained it. What did this maintenance consist of? How much upgrading did you do? 2-3 years can be a long time, especially where JavaScript is concerned. Your best bet, IMO, is to take some freelance work. It'll allow you to build your portfolio, hone your skills, and develop some word-of-mouth leads. Also, get involved with your fellow geeks. Go to your local BarCamp and geek lunches and whatnot. More than ever, success in this line of work is based on who you know. Of course, this is from a web developer's slant. I don't know how social desktop app people are, but in my area of the world webheads love to get together, have drinks, and talk shop.
  22. Where should mem_id be coming from? Even if you have a hidden field for it, the value must come from somewhere, right? It just seems like you're skipping steps. Remember, you need to explicitly tell PHP to do everything you want to do. In your head it's automatic to think that "oh, yeah, I'll match my query on the member's id." PHP has no notion of that unless you tell it to do that. Nothing is automatic.
  23. You can't throw the result of a conditional in the middle of a string like that. Try: var html = "<span class='gmap-text-header'>" + name + "</span><br>"; if (url) { html += "<a href='" + url + "'>Link to Realtime Station</a>"; } html += "</span>"; It's just like building a string with PHP.
  24. I definitely believe it when you claim you're 15....
  25. A bit of both, really. I try to find (and keep links to) tutorials that explain both how and why to do things.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.