diff options
| -rw-r--r-- | .idea/workspace.xml | 223 | ||||
| -rw-r--r-- | web/js/realtime.js | 63 | 
2 files changed, 169 insertions, 117 deletions
| diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2cf848a..983780f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,8 @@  <project version="4">    <component name="ChangeListManager">      <list default="true" id="c02a68ca-4895-49ef-94e1-572ab8cf87ba" name="Default" comment=""> -      <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$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> +      <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" />      <option name="TRACKING_ENABLED" value="true" /> @@ -20,8 +21,8 @@        <file leaf-file-name="HomeController.php" pinned="false" current-in-tab="false">          <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php">            <provider selected="true" editor-type-id="text-editor"> -            <state relative-caret-position="378"> -              <caret line="33" column="8" lean-forward="false" selection-start-line="33" selection-start-column="8" selection-end-line="34" selection-end-column="80" /> +            <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" />                <folding>                  <element signature="e#6#87#0#PHP" expanded="true" />                  <element signature="e#122#181#0#PHP" expanded="true" /> @@ -30,44 +31,21 @@            </provider>          </entry>        </file> -      <file leaf-file-name="NewDataController.php" pinned="false" current-in-tab="false"> -        <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php"> -          <provider selected="true" editor-type-id="text-editor"> -            <state relative-caret-position="446"> -              <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" /> -              </folding> -            </state> -          </provider> -        </entry> -      </file> -      <file leaf-file-name="index.html.twig" pinned="false" current-in-tab="false"> +      <file leaf-file-name="index.html.twig" pinned="false" current-in-tab="true">          <entry file="file://$PROJECT_DIR$/app/Resources/views/default/index.html.twig">            <provider selected="true" editor-type-id="text-editor"> -            <state relative-caret-position="198"> -              <caret line="11" column="28" lean-forward="false" selection-start-line="11" selection-start-column="28" selection-end-line="11" selection-end-column="28" /> +            <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" />                <folding />              </state>            </provider>          </entry>        </file> -      <file leaf-file-name="realtime.js" pinned="false" current-in-tab="true"> +      <file leaf-file-name="realtime.js" pinned="false" current-in-tab="false">          <entry file="file://$PROJECT_DIR$/web/js/realtime.js">            <provider selected="true" editor-type-id="text-editor"> -            <state relative-caret-position="468"> -              <caret line="26" column="25" lean-forward="false" selection-start-line="26" selection-start-column="25" selection-end-line="26" selection-end-column="25" /> -              <folding /> -            </state> -          </provider> -        </entry> -      </file> -      <file leaf-file-name="app.php" pinned="false" current-in-tab="false"> -        <entry file="file://$PROJECT_DIR$/web/app.php"> -          <provider selected="true" editor-type-id="text-editor"> -            <state relative-caret-position="216"> -              <caret line="12" column="1" lean-forward="false" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" /> +            <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> @@ -83,6 +61,9 @@      </option>    </component>    <component name="FindInProjectRecents"> +    <findStrings> +      <find>Co</find> +    </findStrings>      <replaceStrings>        <replace />      </replaceStrings> @@ -185,35 +166,6 @@                <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" />                <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" />              </path> -            <path> -              <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" /> -              <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="app" type="2a2b976b:PhpTreeStructureProvider$1" /> -            </path> -            <path> -              <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" /> -              <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="app" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="config" type="2a2b976b:PhpTreeStructureProvider$1" /> -            </path> -            <path> -              <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" /> -              <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="src" type="2a2b976b:PhpTreeStructureProvider$1" /> -            </path> -            <path> -              <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" /> -              <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="src" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="AppBundle" type="2a2b976b:PhpTreeStructureProvider$1" /> -            </path> -            <path> -              <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" /> -              <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="src" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="AppBundle" type="2a2b976b:PhpTreeStructureProvider$1" /> -              <item name="Controller" type="2a2b976b:PhpTreeStructureProvider$1" /> -            </path>            </expand>            <select />          </subPane> @@ -262,33 +214,34 @@        <workItem from="1511346717882" duration="176000" />        <workItem from="1511347081605" duration="1264000" />        <workItem from="1511428524892" duration="6187000" /> -      <workItem from="1511512197156" duration="4678000" /> +      <workItem from="1511512197156" duration="4902000" /> +      <workItem from="1511783758597" duration="3295000" />      </task>      <servers />    </component>    <component name="TimeTrackingManager"> -    <option name="totallyTimeSpent" value="12856000" /> +    <option name="totallyTimeSpent" value="16375000" />    </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.12898003" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> +      <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" />        <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39968404" sideWeight="0.5036573" order="7" side_tool="true" content_ui="tabs" />        <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> -      <window_info id="Find" 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="1" 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="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="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="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" />        <window_info id="Message" 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="0" side_tool="false" content_ui="tabs" />        <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />        <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />        <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> +      <window_info id="Find" 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="1" side_tool="false" content_ui="tabs" />        <window_info id="Ant Build" active="false" anchor="right" 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" />      </layout>    </component> @@ -308,6 +261,60 @@      <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php">        <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> +            <element signature="e#6#87#0#PHP" expanded="true" /> +            <element signature="e#122#181#0#PHP" expanded="true" /> +          </folding> +        </state> +      </provider> +    </entry> +    <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php"> +      <provider selected="true" editor-type-id="text-editor"> +        <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" /> +          </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="198"> +          <caret line="11" column="28" lean-forward="false" selection-start-line="11" selection-start-column="28" selection-end-line="11" selection-end-column="28" /> +          <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="468"> +          <caret line="26" column="25" lean-forward="false" selection-start-line="26" selection-start-column="25" selection-end-line="26" selection-end-column="25" /> +          <folding /> +        </state> +      </provider> +    </entry> +    <entry file="file://$PROJECT_DIR$/tests/AppBundle/Controller/DefaultControllerTest.php"> +      <provider selected="true" editor-type-id="text-editor"> +        <state relative-caret-position="270"> +          <caret line="15" column="32" lean-forward="true" selection-start-line="15" selection-start-column="32" selection-end-line="15" selection-end-column="32" /> +          <folding /> +        </state> +      </provider> +    </entry> +    <entry file="file://$PROJECT_DIR$/web/app.php"> +      <provider selected="true" editor-type-id="text-editor"> +        <state relative-caret-position="216"> +          <caret line="12" column="1" lean-forward="false" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" /> +          <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="0">            <caret line="0" column="5" lean-forward="true" selection-start-line="0" selection-start-column="5" selection-end-line="0" selection-end-column="5" />            <folding>              <element signature="e#6#87#0#PHP" expanded="true" /> @@ -328,7 +335,6 @@        <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> @@ -336,7 +342,6 @@        <provider selected="true" editor-type-id="text-editor">          <state relative-caret-position="468">            <caret line="26" column="82" lean-forward="false" selection-start-line="26" selection-start-column="82" selection-end-line="26" selection-end-column="82" /> -          <folding />          </state>        </provider>      </entry> @@ -344,7 +349,6 @@        <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> @@ -352,7 +356,6 @@        <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> @@ -360,7 +363,6 @@        <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> @@ -368,7 +370,6 @@        <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> @@ -388,25 +389,15 @@        <provider selected="true" editor-type-id="text-editor">          <state relative-caret-position="18">            <caret line="26" column="82" lean-forward="false" selection-start-line="26" selection-start-column="82" selection-end-line="26" selection-end-column="82" /> -          <folding />          </state>        </provider>      </entry>      <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/DefaultController.php" />      <entry file="file://$PROJECT_DIR$/src/AppBundle/View/Home.php" /> -    <entry file="file://$PROJECT_DIR$/tests/AppBundle/Controller/DefaultControllerTest.php"> -      <provider selected="true" editor-type-id="text-editor"> -        <state relative-caret-position="270"> -          <caret line="15" column="95" lean-forward="true" selection-start-line="15" selection-start-column="95" selection-end-line="15" selection-end-column="95" /> -          <folding /> -        </state> -      </provider> -    </entry>      <entry file="file://$PROJECT_DIR$/.gitignore">        <provider selected="true" editor-type-id="text-editor">          <state relative-caret-position="288">            <caret line="16" column="13" lean-forward="true" selection-start-line="16" selection-start-column="13" selection-end-line="16" selection-end-column="13" /> -          <folding />          </state>        </provider>      </entry> @@ -414,18 +405,10 @@        <provider selected="true" editor-type-id="text-editor">          <state relative-caret-position="144">            <caret line="10" column="14" lean-forward="true" selection-start-line="10" selection-start-column="14" selection-end-line="10" selection-end-column="14" /> -          <folding /> -        </state> -      </provider> -    </entry> -    <entry file="file://$PROJECT_DIR$/.web-server-pid"> -      <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> +    <entry file="file://$PROJECT_DIR$/.web-server-pid" />      <entry file="file://$PROJECT_DIR$/app/Resources/views/base.html.twig">        <provider selected="true" editor-type-id="text-editor">          <state relative-caret-position="180"> @@ -434,19 +417,10 @@          </state>        </provider>      </entry> -    <entry file="file://$PROJECT_DIR$/web/app.php"> -      <provider selected="true" editor-type-id="text-editor"> -        <state relative-caret-position="216"> -          <caret line="12" column="1" lean-forward="false" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" /> -          <folding /> -        </state> -      </provider> -    </entry>      <entry file="file://$PROJECT_DIR$/src/AppBundle/AppBundle.php">        <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> @@ -454,14 +428,13 @@        <provider selected="true" editor-type-id="text-editor">          <state relative-caret-position="-184">            <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> -    <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php"> +    <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php">        <provider selected="true" editor-type-id="text-editor"> -        <state relative-caret-position="378"> -          <caret line="33" column="8" lean-forward="false" selection-start-line="33" selection-start-column="8" selection-end-line="34" selection-end-column="80" /> +        <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" /> @@ -469,29 +442,45 @@          </state>        </provider>      </entry> -    <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php"> +    <entry file="file://$PROJECT_DIR$/tests/AppBundle/Controller/DefaultControllerTest.php">        <provider selected="true" editor-type-id="text-editor"> -        <state relative-caret-position="446"> -          <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" /> -          </folding> +        <state relative-caret-position="270"> +          <caret line="15" column="32" lean-forward="false" selection-start-line="15" selection-start-column="32" selection-end-line="15" selection-end-column="32" /> +          <folding />          </state>        </provider>      </entry> -    <entry file="file://$PROJECT_DIR$/app/Resources/views/default/index.html.twig"> +    <entry file="file://$PROJECT_DIR$/web/app.php">        <provider selected="true" editor-type-id="text-editor"> -        <state relative-caret-position="198"> -          <caret line="11" column="28" lean-forward="false" selection-start-line="11" selection-start-column="28" selection-end-line="11" selection-end-column="28" /> +        <state relative-caret-position="216"> +          <caret line="12" column="1" lean-forward="false" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" />            <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="468"> -          <caret line="26" column="25" lean-forward="false" selection-start-line="26" selection-start-column="25" selection-end-line="26" selection-end-column="25" /> +        <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" /> +          <folding> +            <element signature="e#6#87#0#PHP" expanded="true" /> +            <element signature="e#122#181#0#PHP" expanded="true" /> +          </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" />            <folding />          </state>        </provider> diff --git a/web/js/realtime.js b/web/js/realtime.js index 4526e5e..f0158a2 100644 --- a/web/js/realtime.js +++ b/web/js/realtime.js @@ -1,3 +1,45 @@ +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], +        aq: [0, 50, 51, 100, 101, 150, 151, 200, 201, 300, 301, 400, 401, 500] +    }, +    So: { +        breakpoints: [0.000, 0.034, 0.035, 0.144, 0.145, 0.224, 0.225, 0.304, 0.305, 0.604, 0.605, 0.804, 0.805, 1.004], +        aq:[0, 50, 51, 100, 101, 150, 151, 200, 201, 300, 301, 400, 401, 500] +    }, +    No: { +        breakpoints: [0.65, 1.24, 1.25, 1.64, 1.65, 2.04], +        aq:[201, 300, 301, 400, 401, 500] +    } +}; + + +var calculateAQI = function(gasName, concentration) { +    var bpLow,bpHi; +    var bpLowIndex, bpHiIndex; + +    table[gasName].breakpoints.forEach(function(value, index) { +        if(value < concentration && table[gasName].breakpoints[index + 1] > concentration) { +            bpLow = value; +            bpLowIndex = index; +        } + +        if(value > concentration && table[gasName].breakpoints[index - 1] < concentration) { +            bpHi = value; +            bpHiIndex = index; +        } + +    }); + + + +    var airQualityIndex = ((table[gasName].aq[bpHiIndex] - table[gasName].aq[bpLowIndex]) / (bpHi - bpLow)) * (concentration - bpLow) + table[gasName].aq[bpLowIndex]; + +    return airQualityIndex; + +} + +  function update() {      var data; @@ -14,6 +56,14 @@ function update() {              table[2].textContent = data.No;              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 max = Math.max(...indexes); +            console.log(max); +          })          .catch(function(error) {              console.log(error); @@ -25,3 +75,16 @@ function update() {  }  setInterval(update, 60000); + + + + + + + + + + + + + |