aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarwolaethblack <a.unal677@gmail.com>2017-11-27 14:14:23 +0100
committermarwolaethblack <a.unal677@gmail.com>2017-11-27 14:14:23 +0100
commitf7e9434a00b9001d16a28f3aaab4d4b0696dc12c (patch)
tree6dc279bf9e6df0880e0194150f3736bd764fe6b4
parent664b85ca0b3ee6bd2ee2e1a28864540ac4bdcbaf (diff)
air quality index done
-rw-r--r--.idea/workspace.xml67
-rw-r--r--app/Resources/views/default/index.html.twig2
-rw-r--r--web/js/realtime.js29
3 files changed, 64 insertions, 34 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 983780f..522e0a3 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,6 +3,7 @@
<component name="ChangeListManager">
<list default="true" id="c02a68ca-4895-49ef-94e1-572ab8cf87ba" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/Resources/views/default/index.html.twig" afterPath="$PROJECT_DIR$/app/Resources/views/default/index.html.twig" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/web/js/realtime.js" afterPath="$PROJECT_DIR$/web/js/realtime.js" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -22,30 +23,32 @@
<entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="338">
- <caret line="34" column="80" lean-forward="false" selection-start-line="34" selection-start-column="80" selection-end-line="35" selection-end-column="0" />
+ <caret line="34" column="80" lean-forward="false" selection-start-line="34" selection-start-column="80" selection-end-line="34" selection-end-column="80" />
<folding>
<element signature="e#6#87#0#PHP" expanded="true" />
<element signature="e#122#181#0#PHP" expanded="true" />
+ <marker date="1511787169553" expanded="true" signature="328:1132" ph="{...}" />
+ <marker date="1511787169553" expanded="true" signature="418:528" ph="{...}" />
</folding>
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="index.html.twig" pinned="false" current-in-tab="true">
+ <file leaf-file-name="index.html.twig" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/Resources/views/default/index.html.twig">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="234">
- <caret line="13" column="25" lean-forward="false" selection-start-line="13" selection-start-column="25" selection-end-line="13" selection-end-column="25" />
+ <state relative-caret-position="360">
+ <caret line="20" column="70" lean-forward="false" selection-start-line="20" selection-start-column="70" selection-end-line="20" selection-end-column="70" />
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="realtime.js" pinned="false" current-in-tab="false">
+ <file leaf-file-name="realtime.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/web/js/realtime.js">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="666">
- <caret line="64" column="29" lean-forward="false" selection-start-line="64" selection-start-column="29" selection-end-line="64" selection-end-column="29" />
+ <state relative-caret-position="180">
+ <caret line="91" column="25" lean-forward="false" selection-start-line="91" selection-start-column="25" selection-end-line="91" selection-end-column="25" />
<folding />
</state>
</provider>
@@ -83,8 +86,8 @@
<option value="$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php" />
<option value="$PROJECT_DIR$/bin/console" />
<option value="$PROJECT_DIR$/src/AppBundle/Controller/NewData.php" />
- <option value="$PROJECT_DIR$/app/Resources/views/default/index.html.twig" />
<option value="$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php" />
+ <option value="$PROJECT_DIR$/app/Resources/views/default/index.html.twig" />
<option value="$PROJECT_DIR$/web/js/realtime.js" />
</list>
</option>
@@ -215,16 +218,15 @@
<workItem from="1511347081605" duration="1264000" />
<workItem from="1511428524892" duration="6187000" />
<workItem from="1511512197156" duration="4902000" />
- <workItem from="1511783758597" duration="3295000" />
+ <workItem from="1511783758597" duration="4570000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
- <option name="totallyTimeSpent" value="16375000" />
+ <option name="totallyTimeSpent" value="17650000" />
</component>
<component name="ToolWindowManager">
<frame x="67" y="25" width="1853" height="925" extended-state="6" />
- <editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.12844037" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@@ -233,7 +235,7 @@
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25458997" sideWeight="0.4848485" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25458997" sideWeight="0.4848485" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39968404" sideWeight="0.49634275" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
@@ -265,6 +267,8 @@
<folding>
<element signature="e#6#87#0#PHP" expanded="true" />
<element signature="e#122#181#0#PHP" expanded="true" />
+ <marker date="1511787169553" expanded="true" signature="328:1132" ph="{...}" />
+ <marker date="1511787169553" expanded="true" signature="418:528" ph="{...}" />
</folding>
</state>
</provider>
@@ -274,8 +278,8 @@
<state relative-caret-position="666">
<caret line="37" column="40" lean-forward="false" selection-start-line="37" selection-start-column="40" selection-end-line="37" selection-end-column="40" />
<folding>
- <element signature="e#6#87#0#PHP" expanded="true" />
- <element signature="e#122#181#0#PHP" expanded="true" />
+ <element signature="e#6#87#0#PHP" expanded="false" />
+ <element signature="e#122#181#0#PHP" expanded="false" />
</folding>
</state>
</provider>
@@ -319,6 +323,8 @@
<folding>
<element signature="e#6#87#0#PHP" expanded="true" />
<element signature="e#122#181#0#PHP" expanded="true" />
+ <marker date="1511787169553" expanded="true" signature="328:1132" ph="{...}" />
+ <marker date="1511787169553" expanded="true" signature="418:528" ph="{...}" />
</folding>
</state>
</provider>
@@ -335,6 +341,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="13" lean-forward="false" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
+ <folding />
</state>
</provider>
</entry>
@@ -349,6 +356,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <folding />
</state>
</provider>
</entry>
@@ -356,6 +364,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <folding />
</state>
</provider>
</entry>
@@ -363,6 +372,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <folding />
</state>
</provider>
</entry>
@@ -370,6 +380,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="13" lean-forward="false" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
+ <folding />
</state>
</provider>
</entry>
@@ -436,8 +447,8 @@
<state relative-caret-position="428">
<caret line="37" column="40" lean-forward="false" selection-start-line="37" selection-start-column="40" selection-end-line="37" selection-end-column="40" />
<folding>
- <element signature="e#6#87#0#PHP" expanded="true" />
- <element signature="e#122#181#0#PHP" expanded="true" />
+ <element signature="e#6#87#0#PHP" expanded="false" />
+ <element signature="e#122#181#0#PHP" expanded="false" />
</folding>
</state>
</provider>
@@ -458,29 +469,31 @@
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/web/js/realtime.js">
- <provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="666">
- <caret line="64" column="29" lean-forward="false" selection-start-line="64" selection-start-column="29" selection-end-line="64" selection-end-column="29" />
- <folding />
- </state>
- </provider>
- </entry>
<entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="338">
- <caret line="34" column="80" lean-forward="false" selection-start-line="34" selection-start-column="80" selection-end-line="35" selection-end-column="0" />
+ <caret line="34" column="80" lean-forward="false" selection-start-line="34" selection-start-column="80" selection-end-line="34" selection-end-column="80" />
<folding>
<element signature="e#6#87#0#PHP" expanded="true" />
<element signature="e#122#181#0#PHP" expanded="true" />
+ <marker date="1511787169553" expanded="true" signature="328:1132" ph="{...}" />
+ <marker date="1511787169553" expanded="true" signature="418:528" ph="{...}" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/Resources/views/default/index.html.twig">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="234">
- <caret line="13" column="25" lean-forward="false" selection-start-line="13" selection-start-column="25" selection-end-line="13" selection-end-column="25" />
+ <state relative-caret-position="360">
+ <caret line="20" column="70" lean-forward="false" selection-start-line="20" selection-start-column="70" selection-end-line="20" selection-end-column="70" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/web/js/realtime.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="180">
+ <caret line="91" column="25" lean-forward="false" selection-start-line="91" selection-start-column="25" selection-end-line="91" selection-end-column="25" />
<folding />
</state>
</provider>
diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig
index 36180cb..1ec4bd6 100644
--- a/app/Resources/views/default/index.html.twig
+++ b/app/Resources/views/default/index.html.twig
@@ -17,6 +17,8 @@
</tr>
</table>
</div>
+ <p id="aq"></p>
+ <img src="https://www.ourair.org/wp-content/uploads/AQItable.gif">
{% endblock %}
{% block javascripts %}
<script src="{{ asset('js/realtime.js') }}"></script>
diff --git a/web/js/realtime.js b/web/js/realtime.js
index f0158a2..27cb25c 100644
--- a/web/js/realtime.js
+++ b/web/js/realtime.js
@@ -1,3 +1,14 @@
+function arrayMax(arr) {
+ var len = arr.length, max = -Infinity;
+ while (len--) {
+ if (arr[len] > max) {
+ max = arr[len];
+ }
+ }
+ return max;
+};
+
+
const table = {
Co: {
breakpoints: [0, 4.4, 4.5, 9.4, 9.5, 12.4, 12.5, 15.4, 15.5, 30.4, 30.5, 40.4, 40.5, 50.4],
@@ -14,7 +25,7 @@ const table = {
};
-var calculateAQI = function(gasName, concentration) {
+function calculateAQI(gasName, concentration) {
var bpLow,bpHi;
var bpLowIndex, bpHiIndex;
@@ -57,12 +68,16 @@ function update() {
table[3].textContent = data.So;
var indexes = [];
- indexes.push(calculateAQI("Co", data.Co));
- indexes.push(calcaulteAQI("No", data.No));
- indexes.push(calculateAQI("So", data.So));
+ var CO = isNaN(calculateAQI("Co", data.Co)) ? 0 : calculateAQI("Co", data.Co);
+ var SO = isNaN(calculateAQI("So", data.So)) ? 0 : calculateAQI("So", data.So);
+ var NO = isNaN(calculateAQI("No", data.No)) ? 0 : calculateAQI("No", data.No);
+ indexes.push(CO);
+ indexes.push(NO);
+ indexes.push(SO);
+
+ var max = arrayMax(indexes);
- var max = Math.max(...indexes);
- console.log(max);
+ document.querySelector("#aq").innerHTML = `The current air quality index is <strong>${max}</strong>`;
})
.catch(function(error) {
@@ -74,7 +89,7 @@ function update() {
}
-setInterval(update, 60000);
+setInterval(update, 10000);