Subversion Repositories portal2

Rev

Rev 597 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*  emg - Energy Monitoring & Graphing
*  Copyright (C) 2006-2012 Romain Lievin
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/


function addEvent(element, event, func)
{
    if (element.addEventListener)
        { // Si notre élément possède la méthode addEventListener()
        element.addEventListener(event, func, false);
    } else
        { // Si notre élément ne possède pas la méthode addEventListener() ie IE!
        element.attachEvent('on' + event, func);
    }
}

var listbox = document.getElementById('form_device_type');

var listbox_listener = function()       // DOM-0 way of connecting events
{
        var form_device_url_label = document.getElementById('form_device_url_');

        if(listbox.value == 'local')
        {
                form_device_url_label.innerHTML = 'Path:';
        }
        else if(listbox.value == 'remote')
        {
                form_device_url_label.innerHTML = 'URL:';
        }
};

//listbox.addEventListener('change', listbox_listener, false);
//document.addEventListener('onload', listbox_listener, false);
addEvent(listbox, 'change', listbox_listener);
addEvent(document, 'load', listbox_listener);

/***********************************************/

var checkbox = document.getElementById('form_device_ssl_enabled');

var checkbox_listener = function ()
{
        if(checkbox.checked)
        {
                document.getElementById('form_device_ssl_crt').disabled = false;
                document.getElementById('form_device_ssl_key').disabled = false;
                document.getElementById('form_device_ssl_ca').disabled = false;
        }
        else
        {
                document.getElementById('form_device_ssl_crt').disabled = true;
                document.getElementById('form_device_ssl_key').disabled = true;
                document.getElementById('form_device_ssl_ca').disabled = true;
        }
}

//checkbox.addEventListener('change', checkbox_listener, false);
//document.addEventListener('onload', checkbox_listener, false);
addEvent(checkbox, 'change', checkbox_listener);
addEvent(document, 'load', checkbox_listener);