Exemples JavaScript

Afficher votre image en retour d’état des relais.

// Loop over all the LEDs
for(var i = 0; i < 8; i++) {
  if(getXMLValue(xmlData, 'led' + i) == '1') {
    document.getElementById('led' + i).innerHTML = '<img src="./image1.jpg">';
  } else {
    document.getElementById('led' + i).innerHTML = '<img src="./image2.jpg">';
  }
}

Copier ce code dans votre page et vos 2 images dans le répertoire web de la carte.

Affecter les entrées aux relais « Mode poussoir » :

// Loop over all the buttons
for(i = 0; i < 4; i++) {
	if(getXMLValue(xmlData, 'btn'+i) == 'up') // If button is up
	{
		document.getElementById('btn' + i).innerHTML = '0';
		if(stateChanged0 == 1 && i == 3)
		   switchLED0 = 1;
		//if(i==3)   // If button 0 is pressed, put the button state in currentState
	  //  currentState = 0;
}
else  // If buton is down
	{
	  document.getElementById('btn' + i).innerHTML = '1';
	  stateChanged0 = 1;
	  //if(i==3)  // If button 0 is pressed, put the button state in currentState
	  //  currentState = 1;
}
}

// Update analog value
document.getElementById('an1').innerHTML = getXMLValue(xmlData, 'an1');
	
document.getElementById('an2').innerHTML = getXMLValue(xmlData, 'an2');

// Update the time value
document.getElementById('time0').innerHTML = getXMLValue(xmlData, 'time0');

// Impulse mode
// Check the state of the button changed from the last time we checked
// This check is made to prevent LED flashing when pressing and releasing the button
//if (lastState != currentState) // If the state changed

//{
// newAJAXCommand(‹ leds.cgi?led=0 ›); // Call the function that switch the LED (same function as clicking on the LED)
// lastState = currentState; // Update the last state
//}

// Push mode
if (switchLED0 == 1) // If the state changed
{
switchLED0 = 0; // Reset variable to avoid LED flashing
stateChanged0 = 0;
newAJAXCommand(‹ leds.cgi?led=0 ›); // Call the function that switch the LED (same function as clicking on the LED)
}

}
setTimeout(« newAJAXCommand(‹ status.xml ›, updateStatus, true) »,500);
//–>

Mode Interrupteur :

// Loop over all the buttons
for(i = 0; i < 4; i++) {
if(getXMLValue(xmlData, ‹ btn ›+i) == ‹ up ›) // If button is up
{
document.getElementById(‹ btn › + i).innerHTML = ‹ 0 ›;
if(i==3) // If button 0 is pressed, put the button state in currentState
currentState = 0;
}
else // If buton is down
{
document.getElementById(‹ btn › + i).innerHTML = ‹ 1 ›;
if(i==3) // If button 0 is pressed, put the button state in currentState
currentState = 1;
}
}

Code pour une redirection automatique sur iPhone vers la page iPreset.

[quote]// Detection iPhone
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
if (document.cookie.indexOf(« iphone_redirect=false ») == -1)
window.location = « ./ipreset.htm »;

[/quote]

Pour les HTC.

[quote]// Detection HTC
if((navigator.userAgent.match(/^HTC[P_-]/i)) || (navigator.userAgent.match(/Windows CE; IEMobile/i))) {
if (document.cookie.indexOf(« HTC_redirect=false ») == -1)
window.location = « ./ipreset.htm »;

[/quote]

userAgent pour les mobiles Android.

[quote](navigator.userAgent.match(/Android/i)

[/quote]

Thks!

Bonjour à tous,
Je voudrais faire de ma carte ipx 800 une entrale d’alarme, je voulais savoir si quelqu’un avais un js qui ferait que par exemple quand l’entrée digitale 1 est enclenchée, sa active le relai 1 et 3 par exenple.

cdlt,
Dylan

1 « J'aime »

salut a tous, jai essayer de mettre ce script sur index.html :

// Loop over all the buttons
for(i = 0; i < 4; i++) {
if(getXMLValue(xmlData, ‹ btn ›+i) == ‹ up ›) // If button is up
{
document.getElementById(‹ btn › + i).innerHTML = ‹ 0 ›;
if(i==3) // If button 0 is pressed, put the button state in currentState
currentState = 0;
}
else // If buton is down
{
document.getElementById(‹ btn › + i).innerHTML = ‹ 1 ›;
if(i==3) // If button 0 is pressed, put the button state in currentState
currentState = 1;
}
}

, mai sa fait complètement planter la page et les compteurs dentrees, je voulais savoir si il était possible davoir la page complète, et avoir plus de détails sur lutilisation de ce script.

merci davamnce

Personne?