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

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

and found that
Firefox 15.01 will play the ogg, but not the mp3.
IE8 won't play anything.
Chrome (Version 22.0.1229.92 m) will play both.

That's ironic because the following will play in any Internet Explorer, say version 0 through IE10 if you like.

Without even having to make use the <bgsound> element, I will demonstrate here the posibility of playing audio files without plug-ins using plain <img> tag; to (among other multimedia files) also play a separate audio file (mp3 in this demo). The supported formats are limited only by the number/variety of formats your current OS can play independently.

<!DOCTYPE html>
<html>
  <head>
   <basefont face="geneva, arial, helvetica" size=2 color=#555555>
  </head>
<body>

<div align=center>
   <h1>   The Policy Of Truth  </h1>

   <img id=audio title="right-click for [ Play : Pause / Stop ] commands"
        src=http://t0.gstatic.com/images?q=tbn:ANd9GcR8cqxyVAIUQwMiijsXV3Z6fru33gnRIJYONVzJmBaV7z1LPIc0
        border=0 height=180 width=244 
    dynsrc=http://www.soundcat.ch/download.php?id=13477
        controls
  >
  <br>
  <div id=inf>
     <img src=http://www.nantucketsound.com/images/loading.gif><br>
    wait for file download 
  </div>
</div>

<script>

    document.
    onreadystatechange = 

    function(){
        if(audio.complete)
            inf.innerHTML  = audio.mimeType + "<br>",
            inf.innerHTML += ( audio.fileSize / 1024  / 1024 ).toPrecision(4) + " MB";
        }

</script>
</body>
</html>

p.s.: The file linked is not a stream, -meaning: will not play before it is fully loaded!

Troy III 272 Posting Pro

Troy III, thanks for the help, but there isn't any way to do it with animations/transitions?

There is, but I don't like fixed things,
-however, this will do until you find a better approach.

demo:
http://jsfiddle.net/KWUHy/6/

the snip:

   activate : syncAttr(lineTop.style, "backgroundColor", menu.children);    

     function syncAttr(t, a, x){
            function cS(x){return getComputedStyle(x,0)||x.currentStyle};
            var L = x[0] ? x : [x], i = 0, z,tm;
            while(L[i]){ 
                L[i].onmouseout = function(){t[a]="";clearInterval(tm)};
                L[i++].onmouseover= attSync;}
            function attSync(){z=this; 
                tm=setInterval(function(){
                if(/rgba|tran/.test(cS(z)[a])){ t[a]=cS(z)[a];
                }else{ t[a]=cS(z)[a]; clearInterval(tm) }},8)}
            }
Troy III 272 Posting Pro

do you use a separate towel on each hand?!
-well than, you'll need to take it easy on those CSS definitions.

This is the exact equivalent of your existing css, [except that it is at least 1/4 times shorter].

.linha {
          width: 100%;
          height: 3px;
          background-color: #E51400;
}
#menu {
        width: 100%;
        text-align: center;
        font-weight: 400;
        font-size: 1.6em;
        color: #333;
}
.home,.contato,.trabalhos,.experimentos  {
        text-decoration: none;
        border-bottom-width: 1px;
        border-bottom-style: dotted;
        border-bottom-color: #E51400;
        padding-right: 5px;
        padding-left: 5px;
        margin: 10px;
        -webkit-transition: all .2s ease-in-out 0s;
        -moz-transition: all .2s ease-in-out 0s;
        -ms-transition: all .2s ease-in-out 0s;
        -o-transition: all .2s ease-in-out 0s;
        transition: all .2s ease-in-out 0s;
        color: #333;
}

.home:hover,.home.active {
          background-color: #E51400;
          color: #fff;
}
.trabalhos:hover,.trabalhos.active {
        background-color: #8CBF26;
        border-bottom-color: #8CBF26;
        color: #fff;
}

.experimentos:hover,.experimentos.active {
        background-color: #6E155F;
        color: #fff;
        border-bottom-color: #6E155F;
}
.contato:hover,.contato.active {
        background-color: #1BA1E2;
        border-bottom-color: #1BA1E2;
        color: #fff;
}

but even this can stand a trial for further optimizations.

***

The following JavaScript function can do your thing, - if you agree to remove css transitions...

   activate : syncAttr(lineTop.style, "backgroundColor", menu.children);    
     function syncAttr(t, a, x){
            function cS(x){return getComputedStyle(x,0) || x.currentStyle};
            var L = x[0] ? x : [x], i = 0;
            while(L[i]){ 
                L[i].onmouseover= attSync;
                L[i].onmouseout = function(){t[a]=""};
            i++;}
            function attSync(){t[a] = cS(this)[a]}
            }

The code is assuming that: <div class="linha"></div> has an id=lineTop. That is <div id=lineTop class=linha></div>.

But as mentioned; Will not work with css transitions enabled.

Troy III 272 Posting Pro

This is not impossible to do with CSS if the elements are next to each other. It's not recommended to rely on that though in case elements get moved around but here is how it's done just as an FYI:

True,
but you should warn about browser compatibility;
-not all versions support pseudo-classes on ordinary elements;

Love your hair though :)

Troy III 272 Posting Pro

Quoted Text Here

Hmm... Not sure what that mean... :( Too vauge... Anyway, the example I made is just to show a very simple wayt to change background color using mouse event of each element. May not be a solution. :)

The sentence: "trying to change an element background color when my mouse goes over another element."
would usually mean: I need to change the background of element B, when element A is hovered :p

My Spartan (universal property toggle) happens to be the right tool for the job since it is not bound to the event source element, therefore its action can arbitrarilly target any element on the document, on an iframe, on a popup window; including itself. ;)

Troy III 272 Posting Pro

"trying to change an element background color when my mouse goes over another element."

Troy III 272 Posting Pro
toggleXprop=
    function(o,p,v){
            o.m||(o.m={});
            o[p]==v?o[p]=o.m[p]:(o.m[p]=o[p],o[p]=v);
    }

usage:

handlerElement.setAttribute("onmouseover", 
     "toggleXprop(targetElement.style, 'backgroundColor', 'colorVal')");

handlerElement.setAttribute("onmouseout",
     "toggleXprop(targetElement.style, 'backgroundColor', '')");
Troy III 272 Posting Pro

It must be a jQuery bug, so you should try a fix with them.
Input doesn't have a "closing tag" and most often it will cause DOM errors.

tip:
You don't use xhtml syntax when coding in HTML.

Troy III 272 Posting Pro

I totally agree, but I was trying to make a point that:
- it is always a better choice to eliminate mistakes instead of fixing them with aditional code.
Say, correct the textbox "... value=null>" which is wrong, with a proper type ... value=""> instead.

Troy III 272 Posting Pro

...the default value of a textbox should always correspond to, at least the type of an expected value -which in this case, is a string("");
Strings can contain numerals also, but not objects. And null is exactly that, -a* Typeless Emty Object*, but nonetheless an object; of which parseFloat is not very found of, since it expects a string containing numbers or at least an object of that type Number.
-Anything else will fail on conversion and return a "not a number" Number object.

Troy III 272 Posting Pro

I don't understand why does an empty textbox contain null value in the first place?

Troy III 272 Posting Pro

Try this:

_.radios.onclick=function(e){
        e=e||event;e=e.target||e.srcElement;
            e.value==="1"?
            _.divtext.style.display="none":
            _.divtext.style.display="block";
    }

!Dependency: The UnderDot Platform
(provided on the link).

Troy III 272 Posting Pro

Literally, NaN stands for not a number.

NaN is a javascript object returned when a value treated as a number fails to convert to number. Basically it is not a number. Whereas the type of NaN it self, is - a number container that has no value. (It's not even a zero).

It's a box of numbers alright - but it's empty. Therefore (another) NaN is never equal to (previous/following) NaN, because it's a different box.

You cannot check if( Number("1.a") == NaN )
That's why isNaN() function was needed.

Though NaN==NaN >> is always false!
It's not a Voodoo..., since NaN is an Object;

It's the same as with other empty objects, say: []==[] >> false! They mey be equal in the sense of emptyness and type etc, alas, they are not the same "box". They are different instances of that type of objects.

Contrary to abstractions that can be equal, say 1==1 > true, -since all the 1's of the world are that same 1 (one). That is, the same abstraction. They (NaN's), will be compared by instances, not by values { as in say Number(1)==Number(1) >> true}, because there is a value of the same type that can be compared there. And since they belong to the same abstraction (1) they are the same. >> true!

p.s.:
There are a lot of highly "professional coders" that don't understand the half of it. And ask questions like: why is the typeof NaN >> "number" - …

Troy III 272 Posting Pro

Try targeting an iFrame placeholder and populate it only after the page has loaded.

Troy III 272 Posting Pro

try the built-in function

isNaN(input)

Troy III 272 Posting Pro

...and the problem is?

Troy III 272 Posting Pro

var p = document.createElement("input");
form.appendChild(p);

What do you mean by:

p.name = "p";

?

Troy III 272 Posting Pro

if(inputValues[elem] < 0 ){

you are comparing a string literal type of data (like: "", " ", "abc", "123") against dynamic data type of a numeral 0, or a Boolean(false) in HEX mode; -Which will always evaluate to false.

if( "" < 0 ) //will aways return false because [""] is greater than [0].

Troy III 272 Posting Pro

Fx decided not to support mp3.
but an 'ogg vorbis' copy might work.

Troy III 272 Posting Pro
            <img onclick="changeImage(this,'/folder/images/23.jpg');
                                src="/folder/images/23_thumb.jpg" alt="">
            <a href="theurl">
                <span>this is it</span>
                <h3>This is it</h3>
                <p class="caption">lorem ipsum...</p>
            </a>
Troy III 272 Posting Pro

yes it would.
check for the >>line<< and >>source<< of the "error code" and go get that string corrected.
p.s.: you don't even need the error console to tell you where to look, because its the file and the line of code you or someone else added or modified just before this error ocurred.

Troy III 272 Posting Pro

Of course you can...
Try:

time="10.29";
if ( time < 10.30 ){console.log("it is")} else {console.log("it isn't")};
>>"it is"

time="10.31";
if ( time < 10.30 ){console.log("it is")} else {console.log("it isn't")};
>>"it isn't"
Troy III 272 Posting Pro

Don't worry about var module = instance || {};. It's just defensive programming.

I understand you concern,
but module EQ instance OR {}, is a perfect EMT ( error-masking-tool ), it defends your eyes from seeing some otherwise pretty obvious errors. Nothing beneficiary from that.

This line: "var Parousia = {};" is fundamental. So if for some unknown reason it went missing while having thee "defensive programming" line of code in place - there'll be no way to find out why is the whole app - "a sudden fail!?" - because you will be getting some completely unrelated error on some perfectly sound line of code which will confuse you even more or make you loose it completely.

Doing "var module = instance || {};" will not guard anything! In case of a missing global - You will be operating on a totally inaccessible local object instead of your targeted Parousia.

Now back to troubleshooting...

You have, from what I can see there, a property definition such as:

    Parousia.minion = (function() {
            var module = {};

            module.Unit = function() {
                this.id = 0;
                ...
                }
            }

            return module;
    }())

It should be:

    Parousia.minion = (function() {
            var module = {};

            module.Unit = function() {
                 this.id = 0;
                 ...
                 }
            return module;
    }());

And you have:

    var Parousia = {};
    (function (instance) {
        var module = instance || {};

        module.CANVASHEIGHT = 500;
        ...
        }
    }(Parousia));

It must be:

    var Parousia = …
Troy III 272 Posting Pro

what do you mean by

var module = instance || {};

is it deliberate?

Troy III 272 Posting Pro

a quick patch:

    reg.onclick = function(){createReg(cell7.id)}
Troy III 272 Posting Pro

that would be:

navigator.language

and that would indicate the client language used in the system by that client on that terminal.

DarkMonarch commented: helpful tip +0
Troy III 272 Posting Pro

I would have most probably hit the ESC key before all this collateral code is loaded

<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
    <script type="text/javascript" src="js/process.js"></script>
    <script type="text/javascript" src="js/jquery.ui.core.js"></script>
    <script type="text/javascript" src="js/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="js/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="js/jquery.ui.slider.js"></script>

Just looking at it makes me go click on the x sign of the tab immediately.

Troy III 272 Posting Pro

Assuming there are no scripting errors on your code
you should try it with a defer attribute:

<script type="text/javascript" [B]defer[/B]>
 	$(function() {
		var dates = $( "#from, #to" )....
Troy III 272 Posting Pro

...
so, in order to solve possible problems with this I suggest you do some scripting for cross-browser normalization like

var text = document.body.textContent ? "textContent" : "innerText";
// which will enable you to access and modify the text content using:
   oElement[text]; >> "this element plain text content"
// or assign  
   oElement[text] = "this element new plain text"

And of course mark the thread solved.
p.s.:
(Prototyping it, -is currently a no go.)

Troy III 272 Posting Pro

Nice..,
in case you don't want the whole message, except the "good morning" salutation when time is less than 10, -you can move your script element up again,
and of course: mark the thread solved!

happy learning's.

Troy III 272 Posting Pro

Your question was:
"... if the time is more than 10.. the page will be directed to a another specific page .... anyone can help on this ?"
The answer is

<html>
<body>

<p>This example demonstrates the If statement.</p>
<p>If the time on your browser is less than 10, you will get a "Good morning" greeting.</p>
<p>Otherwise it will navigate you to a different page.</p>

<script type="text/javascript">
var d = new Date();
var time = d.getHours();

if (time > 10 ) 
  {
  location.href = "http://www.yourdomain.com/theOtherPage";
  }
else
  {
   document.write( "<b>Good morning</b>" );
  }
</script>
</body>
</html>

Script element is moved under the content to prevent overwriting your message.

Troy III 272 Posting Pro

The only browser that doesn't support the original innerText property and method is firefox.
It's not IE's fault that someone else took its feature and called it "my invention" by changing its original name. Never mind that it will cause the web to break! Which in return is its exact aim and the reason of renaming your tools in the first place.

Anyhow:
Using the innerHTML as an alternative to innerText was always possible but not always safe. It depends on what you are trying to do. If you are using it as a property or as a method which makes the main difference. Let's exemplify the distinction:

some div content:
"div with a [B]bold[/B] element"
used as properties of the element will return:

div.innerText >> "div with a bold element"
div.innerHTML >> "div with a <b>bold</b> element"

whereas, using them as methods for the same content
"div with a <b>bold</b> element"
will give you a:

div.innerText = "div with a <b>bold</b> element"
>>  "div with a <b>bold</b> element"
div.innerHTML="div with a <b>bold</b> element"
>> "div with a [b]bold[/b] element"

So it is safe to use, as long as the tool you are using, will do what you are aiming to.

Troy III 272 Posting Pro

And probably have no idea where did; nor when did xhtml4.0 came out neither?!
Mark the thread as solved and stop spamming the forum. IE will forgive an omission or two but will not tolerate the ignorance of an evil man.

Troy III 272 Posting Pro

So how do you translate this to English than?cite: "I want to know if it is possible (and if so, how) to trigger the click event that displays the enquiry form on the contact page if the page is accessed via the above link?"
Anyways, thanks for sharing with the community.
In javascript at least, you don't need to call for triggers, you simply do element.click(); and its clicked, which is so much cleaner.

and or for a completion sake as simple as:

location.search.match("part_number")?
oElement.click() : 0;

Ain't that twice as clean and far more simple?

But once again [just for the sake of curiosity ]
Trigger click event if page loaded from a certain referring URL
how do you translate this question into what you are saying now without some powerful trans-mutational alchemy?

Troy III 272 Posting Pro

And sorry for asking but...:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Strict//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<a id='cart' href='/tires/cart'> Your Cart - (empty)</a><head>
	<title>Tires - Wholesale</title>

Why is that (red) line of code sitting there.
Syntax Error report is absolutely correct 2 line <a> tag in the document head;
Did you do this deliberately? Because I'm pretty sure you did...

Troy III 272 Posting Pro

1. Sorry for googleapis, my computer was blocking it... (had some attacks from there)

2. This:

;(function($){
$.fn.slideto = function(options) {
...

should not break a thing ever.
its an amulet-like syntax that will always guard you from unepected js voodoo.

() [parens] can interact in a great distance and some comment might be fooling you that the line break is an established fact, but it might just so happen that an external script at the end of all lines didn't have a line terminator and might have even been omitted knowing that its the end of the file that will terminate not only the line but the script as a whole. But that's not the case -because external scripts will all be appended as if residing in one single and uninterrupted document. So if another js file begins with (... without a leading ; it will be considered a function call of some end-declaration from the previous file.


3. Why don't you try correcting the:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Strict//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

into

<!DOCTYPE html>
<html lang="en">

first, -and see what happens...
Anyway, you'll need some patience because this error will not be easy that to locate...;

in jquery-ui.min.js I've noticed an unnecessary line termination in code

...[0].offsetWidth,
height:d[g]...

which depending on the parser - might also cause problems.

Troy III 272 Posting Pro

http://i44.tinypic.com/dr9vlh.png
I cant even see the "show more" anywhere on your supposedly working browser let alone be able to fix it in explorer.

p.s:
1. linked scripts on the header load async., you slideto.js may be loading faster!
2.I suggest you always use ";" in front of self invoking functions, - I mean always. i.e:

;(function($){
$.fn.slideto = function(options) {
//and its never ever a bad idea to also finish it with one
);

I'm saying this for the first time in public and its a great advice.

3. and lastly -please check if the jQuery file is in the right place.
{now that I've checked, none of them are ! They are missing, try moving them on your own domain ajax google apis are either refusing to serve you, or are down or perhaps IE is refusing to load cross-domain scripts. But the same is happening with chrome:
Failed to load resource https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js ...
}

Troy III 272 Posting Pro

Nope that's not really true -just came back from your http://stmarytheboltons.org.uk/hall/index.html -and the code is working perfectly, on all browser modes quirks/standard (ie7 ie8 ie9) you name it. Other visitors can confirm this too.
p.s.:
since you are using .html extension please hold the shift-key while pressing F5 to refresh the page.

Troy III 272 Posting Pro
document.referrer=="that location string"
yourLinkElement.click();
Troy III 272 Posting Pro

you have an image with an ID = "next" on your document collection and you are not declaring it as a variable, meaning you are referencing to an already defined existing image object and trying make it a string on the fly, you cannot nullify that image and reassign a string instead. Secondly, you are using an obsolete doctype for the document. Correcting this will suffice...:i.e: <!DOCTYPE HTML>

Troy III 272 Posting Pro

now you see how easy it was, you should be more patient when asking people for help giving nothing in return, so even if their given code may prove to be wrong - never go "eeekkk" on them because even then, they've done it with their best intentions and were only trying to help by offering the best they've got.
'Cause you see, you didn't even bother to mark the tread as solved, even though there is no other method for changing the color of the string in place and on the fly, so that others may benefit too.

stay cool.

Troy III 272 Posting Pro

so what?
I never gave you the green code version for you to go "ekkkkk"
-how hard can it be to simply replace content from this:

document.write("<br>3+2 = "+answer1+" is incorrect! - "+("The correct answer is 5.").fontcolor('red'));

to this:

document.write("<br>3+2 = "+answer10+(" The answer is correct ").fontcolor('red'));

or removing the parens altogether since they may be confusing instead of helping

document.write("<br>3+2 = "+answer1+" is incorrect! - "+"The correct answer is 5.".fontcolor('red'));
document.write("<br>3+2 = "+answer10+" The answer is correct ".fontcolor('red'));
Troy III 272 Posting Pro

What don't work?!!
that don't work because you also lack copy-paste skills

Troy III 272 Posting Pro

Yes, but I would use "green" color for the correct one :p

Troy III 272 Posting Pro

hi i would like to change just part of my code to change the color of my answer to my maths game see the code

document.write("<br>3+2 = " + answer1 + " is incorrect - the correct answer is 5");

see where it says the answer is 5 i would like to change it to red but cant find how to do it

thanks

document.write(
      "<br>3+2 = "+answer1+" is incorrect! - "+("The correct answer is 5.").fontcolor('red'));
Troy III 272 Posting Pro

What do you mean by: form.elements.value = input; (me confused!?!) or, which element exactly?

And you won't need this: "grade = Math.round((grade * 0.2));" unless you are interested to return F on all inputs from 100 down to 0, (at least not with the route taken).

Anyway, you can try this :
(it should work if I understood the task correctly; and for a better user experience you might want to split your function in two )

function calcGrade() {
                var form = document.getElementById("form");
                var finalGrade = document.getElementById("final-grade");
                var field = form.elements['test1'];     
		var input = field.value, grade, max = 100, min = 0;

		if(input = parseInt(input, 10)){
			field.value = 
			grade = input > max ? grade = max : 
				input < min ? grade = min : 
				input;
			finalGrade.value =
				(grade < 60) ? "F" :
				(grade < 70) ? "D" :
				(grade < 80) ? "C" :
				(grade < 90) ? "B" :
				(grade <100) ? "A" : "!";
	            }
	    }
Troy III 272 Posting Pro

have you tried to spell the "lentgh" correctly?

Troy III 272 Posting Pro

[selector] { position : fixed; ... }