// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification // for details on configuring this project to bundle and minify static web assets. // Write your JavaScript code. $(function() { if ($("#login_card").length == 0) { $.ajax({ type: "GET", url: "/Index?handler=JsonData", contentType: "application/json", dataType: "json", success: function (response) { $("#json_data").val(response).change(); }, failure: function (response) { alert(response); } }); } }); $("#json_data").change(function() { var jsonData = JSON.parse($("#json_data").val()); console.log(jsonData); $("#vehicle_name").html(jsonData.display_name); $("#vehicle_vin").html(jsonData.vin); $("#battery_level").html(jsonData.charge_state.battery_level); $("#battery_range").html(jsonData.charge_state.battery_range); $("#range_units").html(jsonData.gui_settings.gui_distance_units.includes("mi") ? " mi" : " km"); $("#locate_vehicle_btn").attr("href", "https://whoogle.nmare.net/search?q=" + jsonData.drive_state.latitude + "," + jsonData.drive_state.longitude); $("#climate_status").html(jsonData.climate_state.is_climate_on.includes("true") ? "On" : "Off"); /* if (jsonData.gui_settings.gui_temperature_units.includes("F")) { jsonData.climate_state.outside_temp = ((jsonData.climate_state.outside_temp * 1.8) + 32).toFixed(0); jsonData.climate_state.inside_temp = ((jsonData.climate_state.inside_temp * 1.8) + 32).toFixed(0); jsonData.climate_state.driver_temp_setting = ((jsonData.climate_state.driver_temp_setting * 1.8) + 32).toFixed(0); } */ $("#outside_temp").html(jsonData.climate_state.outside_temp); $("#inside_temp").html(jsonData.climate_state.inside_temp); $("#climate_setting").val(jsonData.climate_state.driver_temp_setting) $(".temp_units").html(jsonData.gui_settings.gui_temperature_units); if (jsonData.vehicle_state.locked == "true") { $("#lock_unlock_btn").html("Unlock") $("#lock_unlock_btn").attr("href", "/?handler=Command&command=door_unlock") } if (!jsonData.charge_state.charging_state.includes("Disconnected")) { $("#charge_state_card").css("display", "flex"); $("#connected_cable").html(jsonData.charge_state.conn_charge_cable); if (jsonData.charge_state.minutes_to_full_charge != 0 ) { $("#till_full").css("display", "block"); $("#time_to_full").html(jsonData.charge_state.minutes_to_full_charge); $("#charge_ctrl_btn").html("Stop Charging") $("#charge_ctrl_btn").attr("href", "/?handler=Command&command=charge_stop"); } else { $("#charge_ctrl_btn").html("Start Charging") $("#charge_ctrl_btn").attr("href", "/?handler=Command&command=charge_start"); } if (jsonData.charge_state.fast_charger_brand.includes("Tesla")) { $("#connection_ind").html("Supercharging") } else { $("#connection_ind").html(jsonData.charge_state.charging_state) } } $(".card-deck").css("display", "flex"); });