/**
 * Copyright (C) 2020 to the present, Crestron Electronics, Inc.
 * All rights reserved.
 * No part of this software may be reproduced in any form, machine
 * or natural, without the express written consent of Crestron Electronics.
 * Use of this source code is subject to the terms of the Crestron Software License Agreement 
 * under which you licensed this source code.  
 *
 * This code was automatically generated by Crestron's code generation tool.
*/
/* jslint es6 */

const uncontrolledSourcesModule = (function () {
    'use strict';

    /**
     * 
     * @param {*} isSourceSynced 
     * @param {*} selectedObject 
     * @param {*} presentationObject 
     */
    function setUncontrolledSourceView(isSourceSynced, selectedObject) {
        const syncImage = document.getElementById("sourceSyncStatus");
        const outOfSycMsgEl = document.getElementById("outOfSyncMsg");
        const stopBtnSourcePresent = document.getElementById("stopBtnSourcePresent");
        let url = '';
        avfUtility.log({ isSourceSynced });
        avfUtility.log({ selectedObject });
        if (selectedObject) {
            if (avfUtility.isValidInput(selectedObject.getAttribute("selectedDeviceName"))) {
                document.getElementById("sourcDeviceName").innerHTML = selectedObject.getAttribute("selectedDeviceName");
            }
            if (avfUtility.isValidInput(selectedObject.getAttribute("iconNameSelected"))) {
                document.getElementById("sourceImageIcon").setAttribute("iconUrl", selectedObject.getAttribute("iconNameSelected"));
            }
        }
        if (isSourceSynced) {
            outOfSycMsgEl.style.display = 'none';
            stopBtnSourcePresent.style.display = 'block';
            url = `./app/project/assets/img/avf/greenup.png`;
        } else {
            outOfSycMsgEl.style.display = 'block';
            stopBtnSourcePresent.style.display = 'none';
            url = `./app/project/assets/img/avf/redup.png`;
        }
        syncImage.setAttribute("url", url);
        syncImage.getElementsByTagName('img')[0].setAttribute("src", url);
        avfUtility.log('image URL for syncstatus > ', syncImage.getAttribute('url'));
    }

    return {
        setUncontrolledSourceView
    };

}());