Jump to content

callumacrae

Members
  • Posts

    89
  • Joined

  • Last visited

Everything posted by callumacrae

  1. 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/
  2. "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".
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. Please don't do that, that is disgusting.
  8. I seriously don't understand why we're arguing if we agree with each other. Have you actually read any of my posts?
  9. 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.
  10. That's literally my entire point. Not sure you were trying to achieve by "correcting" me. "The majority of browsers" ... "Right click". You cannot, in the majority of browsers, right click view background image.
  11. The size of the image being the size of the image element. Yes, it is. The majority of browsers don't do that, though.
  12. 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.
  13. 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.
  14. I like describing it like this: Bad PHP developers are worse than bad JSP developers, and the language allows it.
  15. 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.
  16. Oh, didnt read the original post properly (thought the OP wanted to remove duplicate spaces). Why don't you use .replace?
  17. The equivalent string operation would be pretty inefficient, though.
  18. 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.
  19. 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; }}
  20. 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.
  21. 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.
×
×
  • Create New...