Troy III 272 Posting Pro

Heads up, this thread appears in "Code Snippets" directory, -it shouldn't!

Troy III 272 Posting Pro

I think I got it solved :)

Enlighten us >>how do you scale images while preserving their original aspect ratios<<
Please...

Troy III 272 Posting Pro

Hi,

I have a scenario where in I had to sort an array, find duplicates and increment one or the other by 1.
So, Eg: An array has 22, 23, 21, 21, 24 within it then, an array should be able to find 21 and increment it by 1 i.e. 22. Also, on the other hand, it should now go scanning from the start and find 22 already present and increment that by 1. So, far had managed to sort an array which is just a part of the entire project.
Anyone too good in VBscript, please?

Will you excuse my french,
if I say that your algorithm/"scenario" is very dumb - regardless of the language you'll victimize with it?

That's a 'clever' never-ending task you've come up with.
The programming world calls it an infinite loop!
And an infinite loop is "bad for ya"...

Troy III 272 Posting Pro

That's because you are using a pre-Toggler slide'n'fade (jQuery) animation.
Meaning, you are using a "toggle".
Which means:* the rest of the cubes will "jump" instead of "slide" in.*

Troy III 272 Posting Pro

It will gain you a "dd" method of "menu" object, which you can invoke with:
menu.dd(*[arg]*)

Troy III 272 Posting Pro

{ i = i + 1 } = "I just started coding and I simply Rock!"

{ i += 1 } = "I know, I used to suck so hard..."

{ i++ } = "Am I finally - getting the hang of it?"

Troy III 272 Posting Pro

First of: I'm no smoker
What is your problem if I may ask - What negativity?
And I don't do drugs either!

And there's Absolutely >>no relation<< between smoking and schizophrenia.
Yet that's exactly what sudoscience wiki-piki article is trying to imply.

But I don't get all that excited about it.
Why so serious?

Troy III 272 Posting Pro

In your "best way to scale an image,..." question, - "keeping aspect ratio" is what takes the priority (not the scaling), because it implies that you already know (no less than) few ways of scaling it.
That's why my answer is concentrated on the "aspect-ratio" issues rather than the scaling itself.
(the code you were using, including thanks to what was posted, was not preserving the aspect ratio;the example I recently posted, does.)

My demo was built on top of JorgeM's math resize moddel.
Not dropping it would mean that you could be feeding the function with finer values on scaling arguments.
So using a value of 1% instead of the current 10, will result in smoother sizing but 10 times the amount of clicks.

<button accesskey='s' onclick = "resize( 'img1', '0.99' )" ><u>S</u>maller</button>
<button accesskey='b' onclick = "resize( 'img1', '1.01' )" ><u>B</u>igger</button>

Adding keyboard control convenience to it as Alt+S [shrink]; Alt+B [grow] will help equalize the effort.

http://jsfiddle.net/bUfq2/11/

p.s.:
(if other precautions are not taken), the math model inherited from JorgeM may break as soon as a percentage of a smaller scale image becomes too smal to compute. But that's for release stage consideration.

Troy III 272 Posting Pro

In poor countries, up to 90% of the population may be smoking!
(yes, I did say "population")

The situation in poor neighborhoods of wealthy states, nonetheless, is not much better!
In fact, it worsens with proximity to the rich parts of a given country -by adding pot to 'the habbit'.

A truly concerned 'citizen of the world' would have tried a study in a truly existing relationship instead.
How a bout "Poverty and Smoking" ?!

Troy III 272 Posting Pro

A proof of concept*(s)... code

<script> function resize( img, ratio ){ img.width = img.width * ratio } </script>

<button onclick = "resize( img1, '0.9' )" >Smaller</button>
<button onclick = "resize( img1, '1.1' )" >Bigger</button>

<p><img id="img1" width=200 src="http://www.google.com/images/srpr/logo4w.png">

the above example is supported by all traditional / conventional browsers.
An universal approach would bring us a slightly longer/different code...:

<script> function resize( img, ratio ){ img = document.images[img]; img.width = img.width * ratio }</script>

<button onclick = "resize( 'img1', '0.9' )" >Smaller</button>
<button onclick = "resize( 'img1', '1.1' )" >Bigger</button>

<p><img id="img1" width=200 src="http://www.google.com/images/srpr/logo4w.png" >

but still reusable & libs., free!

Keeping it simple and widely supported, is not always such an easy task as it might appear above, but here we are.

http://jsfiddle.net/bUfq2/10/

Troy III 272 Posting Pro
this.close()

will do your thing!
;that is: the window will not close before prompting the client "do you wan't to close this tab \ window" ...

Troy III 272 Posting Pro

bops is correct -it will work, simply don't declare both dimensions explicitly on an image

Troy III 272 Posting Pro

if a ('match') fails, use the same command you are using to show the complete list on an else{ 'declaration' }.

Troy III 272 Posting Pro

There are articles where I try to explain that UI elements are no real DOM elements but OS provided ctrl's, which tend to (among other unexpected results) refuse z-index instruction and re-surface.

Troy III 272 Posting Pro

Historically there are no known IE #hash issues.
How do you know thatthis piece of jQuery is killing the rest of your js?
[try moving it toward the end of your scripts]

have you tried jquery community?

Troy III 272 Posting Pro

How to call HTML onClick event onLoad by JS

I really don't understand your question, nor how many?

you invoke the click event on eny elemet by [targetelemen].click(); declaration.
You don't like the "font"xyz" is installed notification alert, just delete the alert declaration line ...

Troy III 272 Posting Pro

jQuery bugs are to be solved with jquery team

Troy III 272 Posting Pro

I think I saw Firefox supporting them [events] too.

Troy III 272 Posting Pro

The submission form u use the most is in fact a user name and a password, so - this is, what you thing it is - exactly!

Troy III 272 Posting Pro

which/what 'virtual keyboard'?!

Troy III 272 Posting Pro

$(event.relatedNode).html($(event.relatedNode).html().replace(/a/g, "i"));

is it working on other browsers;
d what browser versions have you been testing ?'

Troy III 272 Posting Pro

you tell me how do you observe form submitions and what website the user is submiting it on,
and I'll tell you absolutely everything else you need to know, I'll even write the original code you are asking for...

Troy III 272 Posting Pro

you can use this code:

isInteger=
/*Troy III*/
function(v){v=Number(v);return(v!=v)+(v%1!=0)==0}

to write your own function with alerts and so...

Or you can check this funcion out:

integerCheck=
/*Troy III*/
function(v,err,Err){
Err={
      "0.0":"Integer value accepted",
      "1.0":"Decimals are not allowed!",
      "1.1":"Culd not convert to number!"
};
         v=Number(v); err=+(v%1!=0)+'.'+ +(v!=v); 
         err>0?alert(Err[err]):0;
         return Err[err]
}

Manual check example"
integerCheck("1.121") //will alert >>decimals not allowed...

p.s.:
But your teacher might want to know -where did you get it?!! (badly)

Troy III 272 Posting Pro

What do you mean with "doing this for IE"?
Are you implying that you have a working code for other UA's?!

Troy III 272 Posting Pro

Devices featuring Tegra 4i, will outperform all.

Troy III 272 Posting Pro

Kert, there are certain unwritten rules we should know by hart and always follow:
First, you should mark this threat as solved [ because: it already is! ]; and
Second, you should start e different thread for your next problem, because
a different problem requires a different solution and of course a different thread.

Have fun.

Troy III 272 Posting Pro

May 21, 2008 10:00 PM Eastern Daylight Time -this is a very old news
The title is misleading very misleading also.

This article suggests that it's referring to the article provided on the link,
but that one talks about Samsungs F1 classic HDD @5400rpm which is a lot slower than any standard 7k.2rpm HDD.

Nothing that relates to SSD prices at all... and a $1/1GB price is not "cheap" at all, if you ask me.

Troy III 272 Posting Pro

I'm not sure I understand your problem completely but since you mention events load status of img files, my advice is that:

  • you can't rely on img onload event to fire consistently;
  • they'll [images] start loading from the cache as soon as they get cached;
  • Images loaded from the cache, will simply overrun the event notifier.

A no-cache scenario might work, but at what cost...?
Regards.

Troy III 272 Posting Pro

this syntax working only one condition is true

function yourfunction(){
   if(condition 1 is true)$('.cCal').css('border-color','red');
   if(condition 2 is true)$('.cCal2').css('border-color','red');
   if(condition 3 is true)$('.cCal3').css('border-color','red');
return false;
}
Troy III 272 Posting Pro

I want to make some shortcut keys (example Alt+K) to do a "onclick" on a button. How can I do this?

isn't the: accesskey="K" attribute working for you?

Troy III 272 Posting Pro

An unreal, superstitious, boring & completely speculative article.

Assembly Guy commented: Oh really? -1
Troy III 272 Posting Pro

'm following the lessons on appendTo.com. It seems in JS functions are made into variable and those >ariable are invoked. Is that how it works?

Not really, but the guy at appendTo is most probably trying to impress beyond reason.
Feel free to write your functions the way you're used too and do it with confidence.

Things written like:

var myfunc = function(){...};

are called: Anonymous functions. (They may be useful, but are not a [language] requirement).

Troy III 272 Posting Pro

That may be the exact reason of why they are offending the eye...

Everything should [at least in this case] be a continuation of colors you are introducing on the banner.

The color of the "sheep field" background should aesthetically match the fill of "Christopher", whereas the "about me" background fill should be from "the Creat" hue (lightened) and finally the feedback section should be picked off of the banner mains: light-gray, gray and dark-gray present range values.

p.s.: please don't learn this by hart -its not a law. Provinding that it migh even fail this particular case also.

Troy III 272 Posting Pro

Erratic behaviour on repetitive user-actions was revealed while testing my JS Spartan (property) Togler, targeting properties on STYLE object. The bug was filed at Bugzilla, (Bug 720129), but because of its manifestation inconsistency, its status remains UNCONFIRMED since.

Troy III 272 Posting Pro

why are these 2 arguments: '#content .grid_5, #content .grid_6' - a (single) string: [?]
not that I think it will solve the problem but,
check if Explorer supports your blur effect first, so to make sure that the first doesn't affect the later -because drag'n'drop (along with everything dynamic), was, invented by Explorer. (and still provides the best support possible).

Troy III 272 Posting Pro

You are misusing IDs for something they were never meant too - don't do that!

Troy III 272 Posting Pro

have you tried it?

Troy III 272 Posting Pro

This is doable, but it will require some scripting...
But I see another problem;

You say: "2.) The user entered a word,...", and pressed the enter key".
My question is, -where will the user enter the word?
Given the heads-up that: "There is no input box where the user enters "cow".

Your end-users/clients,-In case that they'll understand (if they understand) the "task" (about being required to type names of things they see on the page), they will also be forced on blind-typing!
Which is, a bad experience, as they say.

Troy III 272 Posting Pro

Hello

I want to create a button that when the user clicks on it, the browser goes automatically fullscreen. It would be for mainly IE9 and I use for the rest of the browsers the HTML5 fullscreen API.

On Win8 you are already on full-screen mode

Troy III 272 Posting Pro

It returns "A", because HTML tag-names are defined in uppercase. In fact, HTML doesn't support or distinguish between lowercase and uppercase; Meaning, HTML is case insensitive and everything is interpreted and/or retrieved in uppercase.

Troy III 272 Posting Pro

are you sure you've saved your files in utf-8 charset format since you are so eager in instructing the interpreter what chaset is to be used when parsing your content?

Troy III 272 Posting Pro

You don't write a document in a paragraph. It's just something that you don't normaly do.
The "document.write" writes a new document over the previous. Not inside the existing one. Meaning you can't have another document in a document.

I believen you might want to read and try to use the "innerHTML" command instead.

Troy III 272 Posting Pro

well than - you'll need to patch

 if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
document.getElementById("livesearch").style.fontFamily="Arial";
a = livesearch.getElementsByTagName("a");
i = 0; while(a[i])a[i++].removeAttribute("target");
}
Troy III 272 Posting Pro

You're late!
Anyway, while at it, -every link (generated or not) contains the target (_blank) attribute, which will force the link to navigate on a popup window.
You'll need to correct/remove that.

Troy III 272 Posting Pro

Is there any reason why would I want my toggle to take longer than a click to get out of my way and pop up right back when I need it?
- Or, what gives me the right to punish my client's bandwidth with additional 92KB download and leave him hanging, before he could toggle it back and forth with that document ready thing, and for what? A thing of which my client doesn't have the slightest interest and moreover, doesn't even notice!

Aside that, your reply is hostile and uneducated. And I don't like it; At all.

Troy III 272 Posting Pro

There isn't! (At least not theoretically).
Practically? There is!
- But the method chosen for conversion will have to be idiomatic. Therefore not understood by anybody else unless canonized and learned by other parties of same interest.

Troy III 272 Posting Pro

well first thing's first:
<a href="http://www.supportworks.org" target="_blank">HTML SupportWorks Home Page</a>

You need to delete the damn target="_blank" from your links.

Troy III 272 Posting Pro

use the onblur=... event to hide them

Troy III 272 Posting Pro

Cool song. I can only get this code to work in IE. I just get NaN in Firefox and Chrome.

But, you don't need to. I gather that this app is for local use on top of it for personal use.

Here is a Demo that will play on Chrome and all IE versions.

<!DOCTYPE html>
<html>
<meta charset=UTF-8>
<head>
<style>
* {padding:0; margin: 0; border-radius: 8px }
#time { font:600  12pt Arial;
    position: relative;
    top:-23pt;
    color:rgba(0,180,255,.6)
}
#msg {  font: bold 16pt Georgia;
    color: rgba(0,180,255,1);
    padding:0 0 5px 0;
}

body div { color: rgb(0,170,225); }
</style>

<script>
    var d = new Date();
    var hours = d.getHours(); 

    var callAudio = 
        function( soundfile ) {
            sound.src = soundfile;
            audio.dynsrc = soundfile;
    }

    var greeting = function()
        {
    time.innerHTML = d.toLocaleTimeString();
    showTime : setInterval(
    "time.innerHTML = new Date().toLocaleTimeString()", 1000);

    if (hours >=4 && hours <12)  {
        greeting = callAudio('sounds/goodMorning.mp3');
    }

    if (hours >=12 && hours <17) {
        greeting = callAudio('sounds/goodAfternoon.mp3');
    }

    if (hours >=17 && hours <23) {
        greeting = callAudio('sounds/goodEvening.mp3');
    }

    if (hours >=23 && hours !==3)   {
        greeting = callAudio('sounds/goToSleep.mp3');
    }

    if (hours <=3 && hours !==4)     {
        gretting = callAudio('sounds/goToSleep.mp3');
    }

    var theDay=d.getDay();
    switch (theDay)
        {
        case 5:
            msg.innerHTML="Finally Friday";
            break;
        case 6:
            msg.innerHTML="Super Saturday";
            break;
        case 0:
            msg.innerHTML="Sleepy Sunday";
            break;
        case 1:
            msg.innerHTML="Back to the grind Monday";
            break;
        case 2:
            msg.innerHTML="Another day in paradise Tuesday";
            break;
        case 3:
            msg.innerHTML="Over the hump Wednesday";
            break;

        default:
            msg.innerHTML="I'm really looking forward to this weekend!";
        } 
 } 

</script> …
Troy III 272 Posting Pro
    function addLinks () {
        for (var i=0, link; i<5; i++) {
                link = document.createElement("a");
                link.innerHTML = "Link " + i;
                link.onclick = Function( "alert("+i+")" );

                document.body.appendChild(link);
        }
        }