You know what... I actually just found this out. Apparently assigning a value to "this" is not allowed, so I have to use copies. It's a bit odd, though, since a few of the String object builtins operate directly on the object (such as "sort" and "splice"). I'm not sure how you'd implement this in pure JS-- some sort of iteration?
Edit: Playing with it further...
Although it does seem to work...
User Profile
Collapse
-
JS Array Methods, Best Practice: When to modify, when to return a copy?
I'm creating a couple helper methods to beef up the Array type: Array.shuffle() and Array.rotate(st eps) (rotates an array like [1,2,3,4,5], [2,3,4,5,1], [3,4,5,1,2], etc). What I'm wondering is what the consensus is on modifying the original array, versus returning a new array.
My instinct is that in these cases, since they're operations on the array itself, I should simply modify the array in-place. -
Yeah, it's a bit of an old thread, but just in case anyone else bumps into it... a smarter way to implement this would be as an Array method, not a simple function:
Then, it becomes a method of every Array. Easy to read, simple to remember:Code:Array.prototype.copy = function () { return [].concat(this); }
...Code:var myArray = [1,2,3,4,5]; var myArrayCopy = myArray.copy();
Leave a comment:
-
Also-- you might already know this, but it's worth noting anyhow-- be careful who you let upload, and what you let them upload.
I've actually been bitten by this once, although, in my defense, it was only from a site I maintained, not a script I created, configured, or selected (There... ass adequately covered). There was a mailer script, an old Perl job from the stone age, at least. The problem was that it put any and every uploaded...Leave a comment:
-
Using the if/thans is a bit much, but using an echo doesn't achieve the goal evilrevolution was talking about: making the editor colorize/WYSIWYG the HTML as HTML, not as a long PHP string.
By coming out of PHP mode, the HTML code goes back to being colorized/WYSIWYG'd with HTML rules, not PHP rules.
However, it could be just as easily achieved by:
...Code:<?php function header() { ?> <html>Leave a comment:
-
MIT License: How is it "permissive" with the "Permission Notice" requirement?
Something in my gut tells me this is an FAQ, but my furious Googling thus-far hasn't found the answer (Biggest problem? The terms I'm looking for are in the license itself. Search, and... get... 50 copies of the license. Great.)
I've heard it said that the MIT license is one of the most permissive licenses, and that it allows a person to put MIT-licensed code into proprietary works (with the proper attribution). However, I don't understand... -
If you can get a font with those systems' bars in it (AFAIK, there are some free ones out there), generating separate images would likely be a simple batch task using something like gd or ImageMagick....Leave a comment:
-
-
JS (or JQuery): Find the point where a line wraps
Is there a built-in function or a simplified method to tell where a given line of text wraps/will wrap in a given container (the container is fixed-width)? I want to chop off and add an ellipsis to some text at the point where it exceeds one line.
My best idea so far is to just create a dummy container with the same specs, off-screen or invisible, and feed words into it one-by-one, then return where the container changes height. This... -
It's always better to be explicit. Magic Quotes is a PHP option that escapes input strings before they are passed to your PHP script. However, this feature can be turned off (and a script that depends upon Magic Quotes will most likely work the same, just have more security holes).
It's better to turn off Magic Quotes and explicitly escape strings yourself. It assures that you're escaping everything you intend to, and assures that...Leave a comment:
-
I don't know of any offhand, but you might look for an OCR program on your server platform that can work in command-line mode. Then, it would just be a matter of executing it from PHP. I doubt (although I may be wrong) that you're likely to find an OCR app that integrates into PHP.Leave a comment:
-
The session-variable idea sounds the cleanest, to me. Create a session variable with a random or sequential "Transactio n ID". Then, write the ID into the form in a HIDDEN variable.
[PHP]
session_start() ;
// Generate a $this_tid variable however you want to...
$_SESSION['tids'][$this_tid] = true;
// and when you are building your form, insert the tid field...
...Leave a comment:
-
You could try clearing out and replacing only the <option> elements and not the entire <select>. I can't say as I know what the actual problem might be, given the description, but that's something to try.Leave a comment:
-
http://us.php.net/manual/en/book.imap.php
IIIRC, a fair amount of the IMAP functions work with POP3 mail servers as well....Leave a comment:
-
Maybe, but it's not a sure thing.
One thing you can do is put a "Read Receipt Request" on the email. Many email clients will then mail a read-receipt back to the sender, although this depends on the mail client and whether the recipient allows it.
The second thing you could do is incorporate an image-tracking "bug" into the mail. If you are sending an HTML mail, you can incorporate an image URL with...Leave a comment:
-
I'm assuming you're using a third-party news scroller script. You would probably have better luck looking into that script specifically-- searching for help on it, or finding information from the developers.
My first guess is that the script is not designed for multiple instances by default. There may be some extra steps or parameters that will allow you to have multiple scrollers. Or, you may just have to find a different news scroller...Leave a comment:
-
First: What Web browser(s) have you tried this on? Also, is there a particular browser you're targeting (if it's an Intranet or other such private site), or is this a general-purpose site.
Second: Can you link to an example or test case with the "full package"-- the HTML, CSS, and any JavaScript-- in a form that the behavior is triggered? This could be the result of the CSS you've shown, other CSS taking precedence, HTML...Leave a comment:
-
Are you trying to extract the attachment from the end-user's computer? If so, this is beyond the scope of PHP. PHP runs entirely on the server, and any complex interaction with the end-user's computer would have to be accomplished through client-side programs. You might be able to do something with a signed Java applet, but that's still rather a complex operation.
If you're trying to pull it off an email server-- or if you <i>can</i>...Leave a comment:
-
When you access the address, your router is running the code and giving you the results. From the browser-side, this is the only access you will usually have. You need to find some way of pulling files off of the router, such as FTP or TFTP, in order to view them in their unprocessed state.
This is an unusual way of using the router, and it may not be possible to do it. The specific way of getting the raw files depends on the specific...Leave a comment:
-
It's not random-- it's completely predictable. If the variable referenced does not exist, then one is created-- in the global scope. I'm not completely sure, but I would suppose this is merely a "fallback" functionality to allow looser programming and not throw a bunch of "Use of undeclared variable" errors.
You can use a var statement, outside any local scope, to declare a global. Purposely initializing global...Leave a comment:
No activity results to display
Show More
Leave a comment: