|
I wrote this to make it easier to slap a quick canvas element into jsconsolecode:
*I tired using my IP, too in case it was a security thing, but no dice.
|
# ? Mar 8, 2011 17:25 |
|
|
# ? May 16, 2024 15:20 |
|
I have this here. You should be able to see all the code from a View>Source. It functions fine, the only problem I'm having is that it shows all three drop down menus when the page is first loaded. When you start clicking the radio button's this changes to show only the corresponding drop down menu which I want. I'm sure it's something easy but I'm pretty new at this stuff so if someone could supply me with the correct code/what I need to edit that would really be fantastic as this is starting to get very frustrating. Thanks!
|
# ? Mar 9, 2011 00:59 |
|
Bearnt! posted:Set display: none; on the two divs you don't want to display right away. code:
|
# ? Mar 9, 2011 01:06 |
|
Can somebody recommend me a book to learn Javascript. I have no programming experience worth mentioning so I need one that starts from scratch, and I am only looking to learn this as a hobby.
|
# ? Mar 9, 2011 01:09 |
|
Hughmoris posted:Someone should really link this in the OP... The Good Parts Edit: I'm going to leaf through the beginning of it to make sure it's suitable for beginners. I seem to remember it being ok.
|
# ? Mar 9, 2011 01:11 |
|
epswing posted:Set display: none; on the two divs you don't want to display right away. I love you. Seriously though thank you so much.
|
# ? Mar 9, 2011 01:14 |
|
I'm not very familiar with Javascript and only have a bit of experience with PHP but what I want to do simply isn't possible in PHP. I need a way to update a link every x seconds where a part of the link is a query in an external search engine stored in a string in PHP. For example: code:
Thanks in advance for any help/advice you guys can give.
|
# ? Mar 9, 2011 01:57 |
|
include jquery:code:
code:
code:
(EDIT: I left out the # in $('#updateLink') - thanks Lumpy.) anotherone fucked around with this message at 04:17 on Mar 9, 2011 |
# ? Mar 9, 2011 02:30 |
|
anotherone posted:Change the fake URL I put in there to be the URL to a php script that just echos the URL you want to set the link's href to. It must be on the same domain. Tried this and it didn't work. Stripped it down to the three main elements (inclusion of jquery, the link with PHP string included, and the javascript pointing to a php file that just echos the new link) to eliminate any other factors. Every 10 seconds the page will sort of jutter/freeze as if it's updating, but the link stays the same. The code for my test page is this: code:
code:
|
# ? Mar 9, 2011 02:57 |
|
Doody the Clown posted:Tried this and it didn't work. Stripped it down to the three main elements (inclusion of jquery, the link with PHP string included, and the javascript pointing to a php file that just echos the new link) to eliminate any other factors. Every 10 seconds the page will sort of jutter/freeze as if it's updating, but the link stays the same. The code for my test page is this: this: $('updateLink').attr('href', data); needs to be this: $('#updateLink').attr('href', data); The jQuery selector was wrong. The original was looking for a TAG 'updateLink', the corrected version looks for a tag with an ID of 'updateLink'.
|
# ? Mar 9, 2011 03:29 |
|
Lumpy posted:this: $('updateLink').attr('href', data); This works! Much thanks to both of you.
|
# ? Mar 9, 2011 03:34 |
|
Thanks Lumpy, I updated my code.Doody the Clown posted:
This is neither here nor there but if all you're doing is echoing a .txt file you can just point the URL to the txt file and change the $('#updateLink').attr('href', data); to $('#updateLink').attr('href', 'http://google.com/#?q=' + data); and save a few PHP cycles.
|
# ? Mar 9, 2011 04:22 |
|
Just a quick question about the string.match(regex) function in javascript. I noticed while fixing a couple of functions today that the array returned has the complete string in array[0] and then the matched elements in higher positions. I'm pretty sure I read about that in "The Good Parts" recently, but I've not got the book to hand. Can someone correct my understanding?code:
|
# ? Mar 14, 2011 14:31 |
|
Flamadiddle posted:Is this standard behaviour for all uses of .match? I understand that the whole string matches the expression, but I don't want to capture that match... Should I be using a non-capturing group around the whole expression? If you use the global flag on the expression, the match object will only contain matching subsequences. Using the expression /\d{2}(?=\/)/g on your previous example, you only get "14" and "03" back in the match object. All that said, why is it a problem to have the whole string in the match object?
|
# ? Mar 14, 2011 14:57 |
|
Thanks for the response. It's not a problem at all, it was just a little unexpected as I thought the returned array would just contain capturing-groups.
|
# ? Mar 14, 2011 15:00 |
|
I guess this is the most relevant thread. I'm making something in <canvas> and I have two images. I want one to rotate and the other to stay still. Trouble is I can either make it where they both rotate or neither do.
|
# ? Mar 16, 2011 15:53 |
|
The Merkinman posted:I guess this is the most relevant thread. Rotate the "still" image opposite the direction of the canvas context rotation
|
# ? Mar 16, 2011 17:53 |
|
Lumpy posted:Rotate the "still" image opposite the direction of the canvas context rotation I found a different tutorial and recoded my wheel, but now that one won't work in IE with excanvas
|
# ? Mar 17, 2011 14:26 |
|
The Merkinman posted:That's what I can't figure out how to do. Rotate seems to affect ALL or NONE, I can't rotate on a per object basis. jsfiddle if not for the more accurate help, then we can all learn
|
# ? Mar 17, 2011 15:55 |
|
The Merkinman posted:That's what I can't figure out how to do. Rotate seems to affect ALL or NONE, I can't rotate on a per object basis. I'm on my phone all week, so no code, but what you do in essence: Save context Rotate and draw "rotated" image Restore context Draw "static" image Refresh context Here is an article that has some code and I found helpful http://visitmix.com/Articles/Translating-CANVAS-with-HTML5
|
# ? Mar 17, 2011 16:38 |
|
Is there a way to set a script to execute after another, or otherwise control the order of execution? I'm trying to integrate a 3rd party widget onto a site. They give us a script tag that inserts its own content into the page when it runs. I want to write my own script to modify some of the elements their script created, but I'm not sure how to create it so it always runs when those elements exist. I know I could do something like setting a timeout of X seconds, when I assume it will have finished running, but that seems hacky and figure there must be a better way. VVV No callbacks or other hooks, unfortunately. Kludge time! Randomosity fucked around with this message at 17:33 on Mar 17, 2011 |
# ? Mar 17, 2011 17:16 |
|
Randomosity posted:Is there a way to set a script to execute after another, or otherwise control the order of execution? I'm trying to integrate a 3rd party widget onto a site. They give us a script tag that inserts its own content into the page when it runs. I want to write my own script to modify some of the elements their script created, but I'm not sure how to create it so it always runs when those elements exist. If you have access to their source, have their widget or whatever fire a custom event when it's done initializing. Have your code listen for said event. If not, it's kludge time! code:
|
# ? Mar 17, 2011 17:21 |
|
Lumpy posted:If you have access to their source, have their widget or whatever fire a custom event when it's done initializing. Have your code listen for said event. Kludge or no, I'm having to do that exact pattern a lot in my Flash interaction project.
|
# ? Mar 17, 2011 19:08 |
|
Lumpy posted:I'm on my phone all week, so no code, but what you do in essence: Coworker found a different demo using it and it works now. Maybe that article you posted will shed some light onto why what I did earlier didn't work.
|
# ? Mar 18, 2011 03:17 |
|
I've tried jquery with a css3 transforms plugin and the result is slow and jittery. I've tried the same with dividing the image up into a grid of smaller images. I've tried just using css3 transforms without jquery, and while extremely fast in Safari, it's still slow in Chrome and FF. I've also tried doing all the resizing in canvas, but that is slow as well. The size of the image is about 1000x600, so it's really not terribly large. I know it can be done, as Google Maps rescales map tiles extremely smoothly and quickly before it loads the next set of tiles. edit: nm passionate dongs fucked around with this message at 19:58 on Mar 20, 2011 |
# ? Mar 20, 2011 19:49 |
|
Munkeymon posted:I wrote this to make it easier to slap a quick canvas element into jsconsole It's an anonymous function that's executed straight away, so you don't need to give the function a name. Remove the name and it works just fine in Opera. Hope this isn't too late. code:
|
# ? Mar 22, 2011 12:54 |
|
Randomosity posted:Is there a way to set a script to execute after another, or otherwise control the order of execution? I'm trying to integrate a 3rd party widget onto a site. They give us a script tag that inserts its own content into the page when it runs. I want to write my own script to modify some of the elements their script created, but I'm not sure how to create it so it always runs when those elements exist. You could use Jquery to load and execute the script. When that's done perform your modifications to their HTML. Replace code:
code:
|
# ? Mar 22, 2011 13:03 |
|
I have a function that updates a list of links. Each of the links have a handler bound to them with jQuerys bind. The handler calls a function which I have declared just before, which in turn updates said links:code:
|
# ? Mar 22, 2011 14:28 |
|
Knackered posted:It's an anonymous function that's executed straight away, so you don't need to give the function a name. Remove the name and it works just fine in Opera. I was going to extend it to delete the old canvas and load a new one, so I wanted the creator to have a name. Then I started messing with it to get it to work and ended up leaving the name on. Anyway, I forgot to post a follow-up, but it turns out the Opera just won't load it from the local machine over HTTP. Sticking it on my cheapo web host fixed the problem. Munkeymon fucked around with this message at 17:29 on Mar 22, 2011 |
# ? Mar 22, 2011 16:54 |
|
All Hat posted:JSLint complains about updateLinks() being called before it's declared. poo poo works, but I wonder if this is a sign of bad coding practices. I've never gotten this one, but if it's there this is one of those nit-picky things with which I don't agree in JSLint. Functions and declared variables are always hoisted to the top of their scope by the interpreter so they're ready to be used by everything in its scope. http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting
|
# ? Mar 22, 2011 17:03 |
|
Munkeymon posted:I was going to extend it to delete the old canvas and load a new one, so I wanted the creator to have a name. Then I started messing with it to get it to work and ended up leaving the name on. As an FYI, Chrome will do the same thing.
|
# ? Mar 22, 2011 17:33 |
|
geeves posted:I've never gotten this one, but if it's there this is one of those nit-picky things with which I don't agree in JSLint. Functions and declared variables are always hoisted to the top of their scope by the interpreter so they're ready to be used by everything in its scope. Except Hoisting does not include the definition of the function (or assignment if it's an expression) if it's declared as a variable: code:
|
# ? Mar 22, 2011 17:42 |
|
thank you, geeves. I've read that article before, but this time I understood it. and thanks to Lumpy, I'll be reading a bit more about globals, then.
|
# ? Mar 22, 2011 17:49 |
|
Lumpy posted:Except Hoisting does not include the definition of the function (or assignment if it's an expression) if it's declared as a variable: Good catch - I thought that article covered it, it must have been another one or maybe in The Good Parts?.
|
# ? Mar 22, 2011 18:05 |
|
no, it's in the article. declarations goes up, assignments do not.
|
# ? Mar 22, 2011 18:24 |
|
For the love of God someone save me from my insanity. Why is it in my code below that zipNum isn't being treated as a number? It's evaluating a value from an input field, and as I understand it to convert a string to a number you need only multiply times 1 or something similar. The empty if condition works fine and the else at the end is fine. I just can't do any numerical valuation on zipNum that comes out true. code:
|
# ? Mar 23, 2011 00:54 |
|
Use parseInt!code:
|
# ? Mar 23, 2011 01:09 |
|
That's also not working out for me. I guess that suggests there's something else wrong with my code?
hayden. fucked around with this message at 03:00 on Mar 23, 2011 |
# ? Mar 23, 2011 01:30 |
|
Is validationErrors is defined somewhere? You know you can use try/catch blocks, right? Wrap that whole thing in a try block and alert the exception's message property: code:
|
# ? Mar 23, 2011 03:01 |
|
|
# ? May 16, 2024 15:20 |
|
Munkeymon posted:Is validationErrors is defined somewhere? I figured this out using Firebug about 5 minutes before you posted Thanks a ton though! I was a little confused and didn't think I had to use the document.getElementById thing.
|
# ? Mar 23, 2011 03:04 |