Jump to content

callumacrae

Members
  • Posts

    89
  • Joined

  • Last visited

Posts posted by callumacrae

  1. 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?
    "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".
  2. 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.

  3. 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.
    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.
  4. 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.
    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.
  5. 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.
    That's literally my entire point. Not sure you were trying to achieve by "correcting" me.
    Not true! its available if you know where to look.
    "The majority of browsers" ... "Right click". You cannot, in the majority of browsers, right click view background image.
  6. 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 size of the image being the size of the image element. Yes, it is.
    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 majority of browsers don't do that, though.
  7. 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.

  8. 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.
    I like describing it like this: Bad PHP developers are worse than bad JSP developers, and the language allows it.
    • Like 1
  9. 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.

  10. @ 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;					}				});			});		  

    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.
    • Like 1
  11. 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;	}}

  12. 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.

    • Like 1
×
×
  • Create New...