2 * Copyright (c) 2015 - 2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 var className = "AirConditioner";
19 var capabilities = [capabilitySwitch, capabilityIlluminanceMeasurement, capabilityDoorControl];
21 window.onload = function () {
22 console.log("version : 0.0.1");
25 document.body.addEventListener('click', function () {
31 console.log("-----------init-----------");
32 scplugin.manager.getOCFDevices(getOCFDeviceCB);
35 function getOCFDeviceCB(devices) {
36 console.log("getOCFDeviceCB : " + devices.length);
38 for (var i in devices) {
39 console.log("deviceHandle: " + devices[i].deviceHandle);
40 console.log("deviceName: " + devices[i].deviceName);
41 console.log("deviceType: " + devices[i].deviceType);
42 console.log("metadata: " + devices[i].metadata);
45 setMainDevice(devices[0]);
46 ocfDevice.subscribe(onRepresentCallback);
48 for (var i = 0; i < capabilities.length; i++) {
49 capabilities[i].update();
53 function onRepresentCallback(result, deviceHandle, uri, rcsJsonString) {
54 for (var i = 0; i < capabilities.length; i++) {
55 if ( capabilities[i].href == uri) {
56 capabilities[i].onRepresentCallback(result, deviceHandle, uri, rcsJsonString);
61 function setMainDevice(device) {
62 scplugin.log.debug(className, arguments.callee.name, "set ocf device : " + device.deviceName);
66 function backAction() {
67 scplugin.manager.close();
70 function onPowerBtnClicked() {
71 capabilitySwitch.powerToggle();
74 function checkAutoMode() {
75 if (autoModeBool = 1) {
83 function onSetBlindAutoModeClicked() {
84 if (capabilityDoorControl.autoControl == "false") { //unchecked;
85 if (capabilityDoorControl.doorState == "openState") capabilityDoorControl.set("opening");
86 else capabilityDoorControl.set("closing");
87 capabilityDoorControl.autoControl = "true"; // true;
88 // document.getElementById("autoMode").style.backgroundColor = "#3695dd";
89 // document.getElementById("autoMode").style.color = "white";
90 // document.getElementById("autoMode").style.borderColor = "#3695dd";
91 // document.getElementById("autoMode").value = "AUTO ON"
95 if (capabilityDoorControl.doorState == "openState") capabilityDoorControl.set("opened");
96 else capabilityDoorControl.set("closed");
97 capabilityDoorControl.autoControl = "false";
99 // document.getElementById("autoMode").style.backgroundColor = "white";
100 // document.getElementById("autoMode").style.color = "#b4b4b4";
101 // document.getElementById("autoMode").style.borderColor = "#b4b4b4";
102 // document.getElementById("autoMode").value = "AUTO OFF"
106 function autoMode_on(onoff) {
107 var autoModeArea = document.getElementById("autoMode");
109 autoModeArea.style.backgroundColor = "#3695dd";
110 autoModeArea.style.color = "white";
111 autoModeArea.style.borderColor = "#3695dd";
112 autoModeArea.value = "AUTO ON";
114 autoModeArea.style.backgroundColor = "white";
115 autoModeArea.style.color = "#b4b4b4";
116 autoModeArea.style.borderColor = "#b4b4b4";
117 autoModeArea.value = "AUTO OFF";
120 //capabilityDoorControl.doorState == "closed" || capabilityDoorControl.doorState == "closed";
121 /* document.getElementById("cancel_button").style.visibility = "hidden"; "visible";
122 document.getElementById("ready_text1").style.display = "inherit";
123 document.getElementById("ready_text2").style.display = "inherit";
124 document.getElementById("run_text1").style.display = "none";
125 document.getElementById("run_text2").style.display = "none";
126 document.getElementById("run_text3").style.display = "none";
129 function onSetBlindUpDnClicked(updnValue) {
131 var SelectedDoorState;
132 if (updnValue == 0) {
133 capabilityDoorControl.set("closed");
134 capabilityDoorControl.doorState = "closeState";
137 capabilityDoorControl.set("opened");
138 capabilityDoorControl.doorState = "openState";
140 // event.stopPropagation();
143 function blind_up_Action() {
144 capabilityDoorControl.blind_up_control();
147 function blind_dn_Action() {
148 capabilityDoorControl.blind_dn_control();
151 function blind_auto_Action() {
152 // auto_button_toggle();
153 capabilityDoorControl.blind_auto_control();