callumacrae
-
Posts
89 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by callumacrae
-
-
"Any text they delete is not deleted, but marked as deleted" In effect, if I select "aa" and delete it, I won't know whether to display "aaaaaaaa" or "aaaaaaaa".if you took "aa" out of "aaaaaaaa", the end result is still "aaaaaa", so what's the problem with that? take it from the beginning, take it from the end, take it from the middle, whatever. what's the difference? -
If the contents of the form are "aaaaaaaa" and the user selects "aa", I have no way of knowing which "aa" they have selected. that method isn't really viable.
-
Yup. I don't want to make a WYSIWYG editor though, I just want to make a textarea-like element which will show what has been changed.
-
I'm trying to create something similar to annotate mode in openoffice for a website I'm developing. Basically, the user is presented with an input containing text. Any text they delete is not deleted, but marked as deleted; made red and strikethrough. Any text they add is green. The original text remains black. I'm not really sure how to do this. I know that I'll need to use contenteditable as textareas do not support styled text. I'll need one of two approaches: either I'll need to capture all user input and insert it manually, highlighting it as necessary, or I'll need to get the updated text from the input, compare it to the old text, and apply highlighting as necessary. Which would be the best approach, and how would I go about implementing it? There doesn't appear to be a way to get the caret position, so I'm not sure how I'll do it. Is there a better way I'm not aware of? I'm sure that people must have ran into this problem before; for example, the WYSIWYG editor this forum uses must do something similar. Thanks.
-
If you hide it using JS in the first place (there are ways to do it that will hide it before it appears to the user), that won't be a problem.The problem is, with setting content as invisible using css opacity, and if the user has JS disabled in his/her browser, the content will remain invisible. -
I can't read that code.
-
Please don't do that, that is disgusting.
-
I seriously don't understand why we're arguing if we agree with each other. Have you actually read any of my posts?
-
I'm talking about this in the context of web design. You're not. The size of the image is the size of the visible portion of the image (whatever size it has been scaled to) on the screen measured in pixels. Not the size of the image file itself, because that would be silly.Err pointing out to OP, that what was implied was not correct! in that 'The CSS image will be the size of the div.' when used as a CSS background image. IT does not stretch/shrink to size of div container, unless you use css3 styling to do so. You CAN right click to gain access to background image, it might not be shown as 'view background image' but it is still accessible by the right click. -
That's literally my entire point. Not sure you were trying to achieve by "correcting" me.I don't know what you trying to point out? a image used as a background image DOES not force the div to be the size of the image used, unless you specify the size with CSS, or content within the div element makes it high enough to view the image, otherwise the div element will just collapse to zero height, meaning the image wont be viewable.
"The majority of browsers" ... "Right click". You cannot, in the majority of browsers, right click view background image.Not true! its available if you know where to look. -
The size of the image being the size of the image element. Yes, it is.The size of image is not determine by the size of the div, the viewable area of the background image is determined by the div, the image could be larger, or smaller than the div itself, the image can be positioned to specific area, using background-position, also with CSS3 you can make a small image fill the area of the larger div.
The majority of browsers don't do that, though.How are they not right clickable? i can right click an background image, and select view background-image, granted you have to view within another page, to select copy image and such like, but it is still right clickable. -
The CSS image will be the size of the div. The HTML div will be the size of the image.Images defined using CSS are not right clickable, which is pretty annoying.It's mostly about semantics, though.
- 1
-
They're completely different. How are they similar?
-
It'll make your code unreadable and no more efficient.
-
a = [3]; // [3]a = new Array(3); // [ , , ]
They behave differently. You should only use an array literal unless you specifically want to create an array of a certain length (useful for making a string with 50 instances of a word, for example.) There are a few reasons for this; it is cleaner, the Array variable can be overwritten, no need for scope resolution which makes it more efficient, and no strange behaviours that you need to worry about.
-
I like describing it like this: Bad PHP developers are worse than bad JSP developers, and the language allows it.The "problem" with PHP that still exists is that it also allows you (and inherently => other developers that you may or may not end up working with) to write messier code than what Java would let you get away with. With good discipline and coding standards in place before a project starts, your PHP code can be protected from this.- 1
-
Just start making websites. If you find something you can't do, learn it. I would suggest learning PHP instead of JSP, as more people use it and it is easier to learn. You could also try looking at a few job descriptions to see what they expect you to know.
-
-
Oh, didnt read the original post properly (thought the OP wanted to remove duplicate spaces). Why don't you use .replace?
-
The equivalent string operation would be pretty inefficient, though.fwiw, the power of regex comes in finding patterns in strings. for a simple substitution method like in the OP, a regex might be considered excessive overhead. -
Yeah, that's good practice. Micro-optimisations like this and caching the length of an array doesn't really make any difference, but they certainly can't hurt.@ dsonesuk: Thank's for editing, I really appreciated your effort and I learned a lot of things I have another question my friends, Is it good practice to place jQuery selectors in a variables for optimisation? Here's my code:$(document).ready(function(){ $("form").submit(function(){ var a=$("#position"); var b=$("#job"); var c=$("input#religion"); var d="Others"; if (a.val() == "" && b.val() == d ){ b.val("").focus(); return false; } if (c.val() == d){ c.val("").focus(); return false; } }); });
- 1
-
So the problem is fixed now?A couple notes:First, you should indent your code. I can't read it. Something like this:
foreach($file_allowed_extensions as $i => $file_allowed_extensions_value) { if ($fileupload == 0 || !isset($fileupload)) { if ($file_extension == $file_allowed_extensions_value) { $fileupload = 1; } else { $fileupload = 0; } }}foreach($thumbnail_allowed_extensions as $i => $thumbnail_allowed_extensions_value) { if ($thumbnail_extension == $thumbnail_allowed_extensions_value) { if ($thumbnailupload == 0 || !isset($thumbnailupload)) { $thumbnailupload = 1; } else { $thumbnailupload = 0; } }}
Second, you can use ternary to shorten your code quite a bit. The following code does the same as above:
foreach($file_allowed_extensions as $i => $file_allowed_extensions_value) { if ($fileupload == 0 || !isset($fileupload)) { $fileupload = ($file_extension == $file_allowed_extensions_value) ? 1 : 0; }}foreach($thumbnail_allowed_extensions as $i => $thumbnail_allowed_extensions_value) { if ($thumbnail_extension == $thumbnail_allowed_extensions_value) { $thumbnailupload = ($thumbnailupload == 0 || !isset($thumbnailupload)) ? 1 : 0; }}
-
Note that you should only use it for debugging, you shouldn't use it in production code. It doesn't exist in a couple browsers, and so using it will throw an error and stop your code from running.
-
Correct spacing would help, here, the problem is extremely obvious with tabs:
$(document).ready(function () { $("#weight").hover(function () { $("#show").css("display", "block"); }, function () { $("#show").css("display", "none"); $("#show").mouseenter(function () { $(this).data("mouse", "enter"); if ($(this).data("mouse") == "enter") { $(this).css("display", "block").click(function () { var converted = prompt("Convert poud to kilograms:", "") answer = converted * 0.45359237; // 1 lb = 0.45359237 kg answer = answer.toFixed(2); if (!isNaN(converted)) { // If not illegal number if (converted != 0) { // If not empty value alert(converted + " poud = " + answer + " kilograms"); $("#weight").val(answer); } else alert("Error: Empty value!"); // If empty value } else alert("Error: Illegal number!"); // If illegal number }); } }); });});
You're setting a mouseenter handler inside another event handler, and so it will be set multiple times. Then inside the mouseenter handler, you're setting the click handler, so that will be set a lot more times.You should set the event handlers outside of the existing event handlers to prevent them from being added multiple times.
- 1
Playing with contenteditable
in JavaScript
Posted
I'm trying a different approach, which is using a transparent(ish) textarea over a div and diffing them. Deletion isn't working properly, though, and I'm not sure how to solve it: http://jsfiddle.net/Dgn4z/1/