From e4340544519c09a0c6e43fba2b18858d1caa68d0 Mon Sep 17 00:00:00 2001 From: AntonMrt <antonmartenov@gmail.com> Date: Mon, 9 Sep 2024 00:56:11 +0300 Subject: [PATCH] test --- docs/README.md | 26 +++---- docs/_media/DevToolsDavis-updown-curves.svg | 37 +++++++++ docs/index.html | 14 +++- docs/sw.js | 83 +++++++++++++++++++++ 4 files changed, 143 insertions(+), 17 deletions(-) create mode 100644 docs/_media/DevToolsDavis-updown-curves.svg create mode 100644 docs/sw.js diff --git a/docs/README.md b/docs/README.md index e90f794..0fe1a69 100644 --- a/docs/README.md +++ b/docs/README.md @@ -82,19 +82,19 @@ std::vector<std::vector<double>> values = {{30.3, 40, 98, 76} </details> <details> - <summary> Example 3 </summary> - - ```cpp - #include "davis.h" - - int vals[] = {2, 6, 4, -34, 56, 33, 2, 15}; - auto config = dv::Config(); - config.heatmap.title = "Custom title"; // change default settings to custom for heatmap - config.heatmap.xLabel = "Custom xLabel"; // change default settings to custom for heatmap - config.heatmap.yLabel = "Custom yLabel"; // change default settings to custom for heatmap - bool result = dv::show(vals, sizeof(vals) / sizeof(vals[0]), "htmlPageName", config); - ``` -  +<summary>Example 3</summary> + +```cpp +#include "davis.h" + +int vals[] = {2, 6, 4, -34, 56, 33, 2, 15 }; +auto config = dv::Config(); +config.heatmap.title = "Custom title"; // change default settings to custom for heatmap +config.heatmap.xLabel = "Custom xLabel"; // change default settings to custom for heatmap +config.heatmap.yLabel = "Custom yLabel"; // change default settings to custom for heatmap +bool result = dv::show(vals, sizeof(vals) / sizeof(vals[0]), "htmlPageName", config); +``` + </details> # 💻 Usage diff --git a/docs/_media/DevToolsDavis-updown-curves.svg b/docs/_media/DevToolsDavis-updown-curves.svg new file mode 100644 index 0000000..84451fe --- /dev/null +++ b/docs/_media/DevToolsDavis-updown-curves.svg @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<!-- Creator: CorelDRAW --> +<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="119.044mm" height="54.7138mm" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" +viewBox="0 0 8903.59 4092.17" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xodm="http://www.corel.com/coreldraw/odm/2003"> + <defs> + <style type="text/css"> + <![CDATA[ + .fil2 {fill:#1699DD;fill-rule:nonzero} + .fil1 {fill:#4BB8F2;fill-rule:nonzero} + .fil3 {fill:#FFA940;fill-rule:nonzero} + .fil0 {fill:#2490D0;fill-rule:nonzero} + ]]> + </style> + </defs> + <g id="Слой_x0020_1"> + <metadata id="CorelCorpID_0Corel-Layer"/> + <path class="fil0" d="M3297.13 2728.88c-90.86,0 -172.98,-15.43 -246.36,-46.3 -73.39,-30.87 -131.92,-78.62 -175.6,-143.26 -43.68,-64.65 -65.52,-145.31 -65.52,-241.99 0,-150.27 40.19,-264.41 120.56,-342.46 80.37,-78.04 194.52,-117.06 342.45,-117.06 146.76,0 257.71,37.85 332.85,113.56 75.13,75.71 112.69,185.21 112.69,328.48 0,40.76 -18.63,61.15 -55.91,61.15l-641.23 0c0,76.88 26.79,135.99 80.37,177.34 53.58,41.35 128.13,62.03 223.64,62.03 92.02,0 174.72,-20.96 248.11,-62.9 8.15,-4.66 14.56,-6.99 19.22,-6.99 8.15,0 14.55,5.24 19.21,15.72l41.94 75.14c3.49,6.99 5.24,13.4 5.24,19.21 0,8.16 -5.24,15.73 -15.73,22.71 -47.75,29.12 -99.3,50.67 -154.63,64.65 -55.33,13.98 -119.1,20.96 -191.32,20.96zm218.4 -517.17c0,-72.22 -20.1,-128.71 -60.28,-169.48 -40.19,-40.77 -100.46,-61.16 -180.83,-61.16 -81.54,0 -144.15,20.97 -187.83,62.9 -43.68,41.94 -65.53,97.85 -65.53,167.74l494.47 0z"/> + <path id="_1" class="fil0" d="M4272.07 2702.67c-16.3,0 -28.53,-3.2 -36.69,-9.61 -8.16,-6.4 -16.31,-17.76 -24.46,-34.07l-351.19 -746.06c-3.5,-6.99 -5.24,-13.98 -5.24,-20.97 0,-8.15 2.62,-14.85 7.86,-20.09 5.24,-5.24 12.52,-7.86 21.84,-7.86l145.02 0c15.14,0 26.21,2.62 33.19,7.86 6.99,5.24 13.4,14.85 19.22,28.82l234.13 545.13 234.12 -545.13c5.83,-12.81 12.52,-22.13 20.1,-27.95 7.57,-5.83 18.92,-8.74 34.07,-8.74l145.02 0c9.31,0 16.6,2.62 21.84,7.86 5.24,5.24 7.86,11.94 7.86,20.09 0,6.99 -1.75,13.98 -5.24,20.97l-351.19 746.06c-8.15,16.3 -16.31,27.67 -24.46,34.07 -8.15,6.41 -20.38,9.61 -36.69,9.61l-89.11 0z"/> + <path id="_2" class="fil0" d="M5112.49 2702.67c-23.3,0 -40.19,-5.24 -50.67,-15.72 -10.49,-10.49 -15.73,-26.21 -15.73,-47.18l0 -953.98 -305.76 0c-23.3,0 -39.31,-4.66 -48.05,-13.98 -8.74,-9.32 -13.1,-25.05 -13.1,-47.18l0 -47.17c0,-22.13 4.37,-38.15 13.1,-48.05 8.74,-9.9 24.75,-14.85 48.05,-14.85l835.17 0c23.3,0 39.6,4.95 48.92,14.85 9.32,9.9 13.98,25.92 13.98,48.05l0 47.17c0,22.13 -4.66,37.86 -13.98,47.18 -9.32,9.32 -25.62,13.98 -48.92,13.98l-305.77 0 0 953.98c0,20.96 -4.94,36.69 -14.85,47.18 -9.9,10.48 -27.08,15.72 -51.55,15.72l-90.85 0z"/> + <path id="_3" class="fil0" d="M6012.3 2728.88c-151.42,0 -268.2,-39.89 -350.32,-119.68 -82.11,-79.79 -123.18,-188.41 -123.18,-325.85 0,-137.45 41.06,-246.07 123.18,-325.85 82.12,-79.79 198.9,-119.68 350.32,-119.68 151.42,0 268.49,39.89 351.19,119.68 82.71,79.79 124.05,188.41 124.05,325.85 0,137.45 -41.35,246.07 -124.05,325.85 -82.7,79.79 -199.76,119.68 -351.19,119.68zm0 -164.24c82.7,0 145.6,-23.88 188.7,-71.64 43.1,-47.75 64.64,-117.65 64.64,-209.67 0,-90.86 -21.55,-159.87 -64.64,-207.05 -43.1,-47.17 -106,-70.76 -188.7,-70.76 -81.54,0 -144.15,23.59 -187.83,70.76 -43.68,47.18 -65.53,116.19 -65.53,207.05 0,90.86 21.85,160.45 65.53,208.79 43.68,48.34 106.29,72.51 187.83,72.51z"/> + <path id="_4" class="fil0" d="M7053.64 2728.88c-151.42,0 -268.2,-39.89 -350.32,-119.68 -82.11,-79.79 -123.18,-188.41 -123.18,-325.85 0,-137.45 41.06,-246.07 123.18,-325.85 82.12,-79.79 198.9,-119.68 350.32,-119.68 151.42,0 268.49,39.89 351.19,119.68 82.71,79.79 124.05,188.41 124.05,325.85 0,137.45 -41.35,246.07 -124.05,325.85 -82.7,79.79 -199.76,119.68 -351.19,119.68zm0 -164.24c82.7,0 145.6,-23.88 188.7,-71.64 43.1,-47.75 64.64,-117.65 64.64,-209.67 0,-90.86 -21.55,-159.87 -64.64,-207.05 -43.1,-47.17 -106,-70.76 -188.7,-70.76 -81.54,0 -144.15,23.59 -187.83,70.76 -43.68,47.18 -65.53,116.19 -65.53,207.05 0,90.86 21.85,160.45 65.53,208.79 43.68,48.34 106.29,72.51 187.83,72.51z"/> + <path id="_5" class="fil0" d="M7764.75 2702.67c-23.29,0 -39.89,-5.24 -49.79,-15.72 -9.9,-10.49 -14.85,-26.21 -14.85,-47.18l0 -1060.56c0,-22.13 4.95,-38.44 14.85,-48.92 9.9,-10.48 26.5,-15.72 49.79,-15.72l92.61 0c23.3,0 40.19,5.24 50.66,15.72 10.49,10.49 15.73,26.79 15.73,48.92l0 1060.56c0,20.96 -4.95,36.69 -14.85,47.18 -9.9,10.48 -27.08,15.72 -51.54,15.72l-92.61 0z"/> + <path id="_6" class="fil0" d="M8493.35 2728.88c-69.89,0 -138.04,-7.28 -204.43,-21.84 -66.39,-14.56 -123.47,-36.4 -171.22,-65.52 -15.15,-8.15 -22.71,-16.9 -22.71,-26.21 0,-6.99 2.33,-13.4 6.99,-19.22l48.92 -85.61c5.83,-10.49 11.65,-15.72 17.47,-15.72 5.83,0 13.4,2.91 22.71,8.74 34.94,20.96 78.05,38.44 129.29,52.41 51.26,13.98 98.43,20.96 141.53,20.96 66.39,0 113.86,-6.69 142.4,-20.09 28.53,-13.4 42.8,-37.57 42.8,-72.51 0,-19.8 -5.53,-35.82 -16.6,-48.05 -11.07,-12.24 -27.67,-23.01 -49.8,-32.33 -22.13,-9.32 -58.82,-22.13 -110.07,-38.44 0,0 -19.22,-6.4 -57.66,-19.21 -66.4,-22.13 -119.4,-43.68 -159,-64.65 -39.6,-20.96 -70.18,-47.46 -91.73,-79.5 -21.55,-32.03 -32.33,-72.51 -32.33,-121.43 0,-79.21 33.48,-139.49 100.46,-180.83 66.98,-41.35 154.05,-62.03 261.21,-62.03 130.46,0 242.87,27.95 337.22,83.86 15.14,8.15 22.71,16.89 22.71,26.21 0,5.83 -2.91,13.4 -8.74,22.71l-47.17 75.13c-6.99,10.49 -12.81,15.72 -17.47,15.72 -4.66,0 -11.65,-2.91 -20.96,-8.74 -30.29,-18.63 -66.69,-33.48 -109.2,-44.55 -42.51,-11.06 -85.32,-16.6 -128.42,-16.6 -58.24,0 -101.05,6.12 -128.43,18.35 -27.37,12.23 -41.05,35.82 -41.05,70.76 0,30.28 16.01,54.16 48.05,71.64 32.03,17.47 87.65,38.44 166.86,62.9l57.66 17.47c90.85,29.12 154.63,63.48 191.32,103.09 36.69,39.6 55.04,89.11 55.04,148.51 0,72.22 -31.74,131.04 -95.23,176.46 -63.48,45.43 -156.96,68.14 -280.43,68.14z"/> + <path class="fil1" d="M1469.77 1235.04c73.4,73.15 144.57,144.65 219.3,219.77 41.23,41.72 80.2,78.64 116.2,118.25 32.1,35.33 43.55,68.89 12.33,104.48 -43.48,49.58 -89.76,97.59 -140.2,139.86 -34.41,28.84 -62.87,23.55 -97.81,-7.19 -43.55,-38.32 -84.72,-79.35 -126.92,-119.21 -71.2,-71.61 -142.4,-143.21 -215.54,-216.15 -29.97,-29.89 -57.78,-58.67 -86.08,-86.98 -185.93,-186.07 -371.95,-372.03 -557.95,-558.02 -26.98,-26.97 -27.03,-26.98 -54.75,0.73 -99.77,99.74 -199.47,199.55 -299.3,299.23 -37.19,37.13 -65.08,39.96 -103.93,4.87 -40.45,-36.53 -78.75,-75.64 -115.89,-115.57 -25.14,-27.04 -25,-56.59 -3.34,-87.18 8.87,-12.54 19.73,-23.81 30.63,-34.72 283.71,-283.93 567.55,-567.73 851.38,-851.54 4.5,-4.5 9.03,-8.99 13.71,-13.31 46.48,-42.94 80.16,-43.37 125.39,0.01 31.51,30.24 62.17,61.39 92.43,92.88 31.82,33.12 45.59,71.12 -2.36,117.59 -102.61,99.43 -202.25,201.91 -303.93,302.31 -16.48,16.28 -18.57,26.34 -0.97,43.84 215.54,214.36 430.36,429.46 647.6,646.03z"/> + <path class="fil2" d="M1523.94 1185.51c130.53,-130.71 208.86,-209.55 339.53,-340.13 8.98,-8.97 18.81,-17.24 29.02,-24.79 31.13,-23.03 58.74,-22.56 89.98,1.04 7.97,6.01 16.13,12 23.13,19.06 130.8,131.71 265.01,260.27 391.03,396.41 110.14,118.99 196.16,254.3 229.41,417.6 30.09,147.75 3.43,285.75 -69.06,415.43 -100.47,179.74 -241.81,322.59 -412.25,435.59 -129.17,85.64 -272.52,129.54 -429.18,111.47 -130,-14.98 -245.6,-67.71 -352.5,-142.61 -101.38,-71.04 -184.99,-160.94 -272.03,-247.35 -77.49,-76.94 -154.6,-154.26 -231.65,-231.63 -55.87,-56.11 -56.37,-89.47 -0.7,-145.41 123.9,-124.46 195.81,-198 322.94,-323.68 80.94,81.95 153.23,154.35 217.9,218.24 -95.34,95.38 -137.72,137.74 -232.59,232.61 42.67,42.67 82.01,81.69 121,121.07 63.35,63.97 125.65,129.02 202.63,177.54 132.15,83.3 268.32,101.31 410.58,26.63 133.03,-69.83 237.3,-172.99 331.49,-287.51 52.35,-63.66 95.91,-132.86 117.72,-213.17 35.54,-130.82 1.14,-249.93 -81.14,-350.27 -81.64,-99.56 -176.24,-188.46 -264.77,-282.41 -15.86,-16.84 -24.65,-4.81 -35.2,5.76 -93.25,93.36 -130.91,137.63 -226.25,229.43 -73.16,-72.99 -146.64,-146.36 -219.04,-218.92z"/> + <path class="fil3" d="M1469.77 1235.04c73.4,73.15 144.57,144.65 219.3,219.77 41.23,41.72 80.2,78.64 116.2,118.25 32.1,35.33 43.55,68.89 12.33,104.48 -43.48,49.58 -89.76,97.59 -140.2,139.86 -34.41,28.84 -62.87,23.55 -97.81,-7.19 -43.55,-38.32 -84.72,-79.35 -126.92,-119.21 -71.2,-71.61 -142.4,-143.21 -215.54,-216.15 -29.97,-29.89 -57.78,-58.67 -86.08,-86.98 -185.93,-186.07 -371.95,-372.03 -557.95,-558.02 -26.98,-26.97 -27.03,-26.98 -54.75,0.73 -99.77,99.74 -199.47,199.55 -299.3,299.23 -37.19,37.13 -65.08,39.96 -103.93,4.87 -40.45,-36.53 -78.75,-75.64 -115.89,-115.57 -25.14,-27.04 -25,-56.59 -3.34,-87.18 8.87,-12.54 19.73,-23.81 30.63,-34.72 283.71,-283.93 567.55,-567.73 851.38,-851.54 4.5,-4.5 9.03,-8.99 13.71,-13.31 46.48,-42.94 80.16,-43.37 125.39,0.01 31.51,30.24 62.17,61.39 92.43,92.88 31.82,33.12 45.59,71.12 -2.36,117.59 -102.61,99.43 -202.25,201.91 -303.93,302.31 -16.48,16.28 -18.57,26.34 -0.97,43.84 215.54,214.36 430.36,429.46 647.6,646.03z"/> + <path class="fil0" d="M1523.94 1185.51c130.53,-130.71 208.86,-209.55 339.53,-340.13 8.98,-8.97 18.81,-17.24 29.02,-24.79 31.13,-23.03 58.74,-22.56 89.98,1.04 7.97,6.01 16.13,12 23.13,19.06 130.8,131.71 265.01,260.27 391.03,396.41 110.14,118.99 196.16,254.3 229.41,417.6 30.09,147.75 3.43,285.75 -69.06,415.43 -100.47,179.74 -241.81,322.59 -412.25,435.59 -129.17,85.64 -272.52,129.54 -429.18,111.47 -130,-14.98 -245.6,-67.71 -352.5,-142.61 -101.38,-71.04 -184.99,-160.94 -272.03,-247.35 -77.49,-76.94 -154.6,-154.26 -231.65,-231.63 -55.87,-56.11 -56.37,-89.47 -0.7,-145.41 123.9,-124.46 195.81,-198 322.94,-323.68 80.94,81.95 153.23,154.35 217.9,218.24 -95.34,95.38 -137.72,137.74 -232.59,232.61 42.67,42.67 82.01,81.69 121,121.07 63.35,63.97 125.65,129.02 202.63,177.54 132.15,83.3 268.32,101.31 410.58,26.63 133.03,-69.83 237.3,-172.99 331.49,-287.51 52.35,-63.66 95.91,-132.86 117.72,-213.17 35.54,-130.82 1.14,-249.93 -81.14,-350.27 -81.64,-99.56 -176.24,-188.46 -264.77,-282.41 -15.86,-16.84 -24.65,-4.81 -35.2,5.76 -93.25,93.36 -130.91,137.63 -226.25,229.43 -73.16,-72.99 -146.64,-146.36 -219.04,-218.92z"/> + <path class="fil3" d="M4833.68 4069.04c-20.56,0 -35.2,-4.62 -43.94,-13.87 -8.74,-9.25 -13.1,-23.13 -13.1,-41.62l0 -935.77c0,-19.53 4.37,-33.92 13.1,-43.17 8.74,-9.25 23.38,-13.87 43.94,-13.87l308.32 0c173.69,0 306.53,41.62 398.52,124.87 91.98,83.25 137.98,216.34 137.98,399.29 0,349.44 -178.84,524.15 -536.49,524.15l-308.32 0zm320.66 -149.54c108.94,0 190.91,-28.26 245.89,-84.79 54.98,-56.52 82.47,-153.13 82.47,-289.82 0,-136.7 -27.49,-233.05 -82.47,-289.06 -54.99,-56.01 -136.95,-84.02 -245.89,-84.02l-180.37 0 0 747.69 180.37 0z"/> + <path id="_1_0" class="fil3" d="M5755.58 4069.04c-17.47,0 -26.21,-7.71 -26.21,-23.13 0,-6.16 1.54,-12.85 4.62,-20.04l406.99 -965.07c6.17,-15.41 12.85,-25.95 20.04,-31.6 7.2,-5.65 17.47,-8.48 30.83,-8.48l84.79 0c14.39,0 24.92,2.83 31.61,8.48 6.68,5.65 13.1,16.19 19.27,31.6l406.99 965.07c3.09,7.19 4.63,13.87 4.63,20.04 0,15.41 -8.74,23.13 -26.21,23.13l-134.12 0c-13.36,0 -22.86,-1.8 -28.52,-5.39 -5.65,-3.6 -11.05,-11.05 -16.19,-22.36l-87.87 -215.83 -425.49 0 -86.33 215.83c-5.14,11.3 -10.54,18.76 -16.19,22.36 -5.65,3.6 -15.16,5.39 -28.53,5.39l-134.12 0zm641.32 -386.95l-163.41 -403.91 -163.41 403.91 326.83 0z"/> + <path id="_2_1" class="fil3" d="M7076.76 4069.04c-14.39,0 -24.92,-2.57 -31.61,-7.71 -6.68,-5.14 -13.1,-15.41 -19.27,-30.83l-400.83 -966.61c-3.08,-6.16 -4.62,-12.33 -4.62,-18.5 0,-7.2 2.31,-13.1 6.93,-17.73 4.63,-4.63 11.05,-6.94 19.27,-6.94l132.58 0c13.37,0 23.64,2.57 30.84,7.71 7.2,5.14 12.84,13.36 16.96,24.67l291.37 739.98 291.37 -739.98c4.11,-11.31 9.77,-19.53 16.96,-24.67 7.19,-5.14 17.47,-7.71 30.83,-7.71l132.58 0c8.23,0 14.65,2.31 19.27,6.94 4.62,4.62 6.94,10.53 6.94,17.73 0,6.16 -1.55,12.33 -4.63,18.5l-399.28 966.61c-6.17,15.41 -12.85,25.69 -20.04,30.83 -7.2,5.14 -17.99,7.71 -32.38,7.71l-83.24 0z"/> + <path id="_3_2" class="fil3" d="M7824.45 4069.04c-20.56,0 -35.2,-4.62 -43.94,-13.87 -8.74,-9.25 -13.1,-23.13 -13.1,-41.62l0 -935.77c0,-19.53 4.37,-33.92 13.1,-43.17 8.74,-9.25 23.38,-13.87 43.94,-13.87l81.7 0c20.55,0 35.46,4.62 44.71,13.87 9.24,9.25 13.87,23.64 13.87,43.17l0 935.77c0,18.5 -4.37,32.37 -13.1,41.62 -8.74,9.25 -23.9,13.87 -45.48,13.87l-81.7 0z"/> + <path id="_4_3" class="fil3" d="M8521.27 4092.17c-72.97,0 -144.66,-7.97 -215.06,-23.9 -70.4,-15.93 -126.68,-38.29 -168.81,-67.06 -13.36,-9.25 -20.04,-17.47 -20.04,-24.67 0,-7.2 2.06,-13.37 6.16,-18.5l50.87 -80.16c6.17,-9.25 11.82,-13.87 16.96,-13.87 5.14,0 11.82,2.57 20.04,7.7 38.03,22.62 82.22,40.86 132.58,54.73 50.36,13.87 101.23,20.81 152.62,20.81 69.89,0 122.56,-11.56 158.01,-34.68 35.46,-23.13 53.19,-60.38 53.19,-111.77 0,-30.84 -6.69,-55.5 -20.04,-74 -13.36,-18.5 -32.89,-34.43 -58.58,-47.79 -25.69,-13.36 -67.31,-31.35 -124.87,-53.96l-35.46 -13.87c-66.8,-26.72 -122.05,-52.41 -165.72,-77.08 -43.69,-24.67 -79.91,-57.04 -108.69,-97.13 -28.78,-40.08 -43.16,-88.9 -43.16,-146.46 0,-93.52 35.71,-165.72 107.14,-216.6 71.43,-50.87 165.21,-76.31 281.35,-76.31 70.92,0 132.32,6.68 184.23,20.04 51.9,13.36 96.86,33.91 134.9,61.67 12.33,9.24 18.5,17.98 18.5,26.21 0,6.16 -2.06,11.82 -6.16,16.96l-49.33 80.16c-6.17,9.25 -11.31,13.88 -15.42,13.88 -4.11,0 -10.79,-3.09 -20.04,-9.25 -65.78,-42.14 -147.48,-63.21 -245.12,-63.21 -64.75,0 -113.56,11.82 -146.45,35.46 -32.89,23.63 -49.33,61.15 -49.33,112.54 0,31.85 6.93,57.29 20.81,76.31 13.87,19.01 34.17,35.2 60.89,48.56 26.72,13.37 69.89,31.35 129.5,53.96l38.54 15.41c75.02,29.8 133.61,57.3 175.75,82.47 42.14,25.18 74.77,56.53 97.89,94.04 23.13,37.51 34.69,85.56 34.69,144.14 0,88.39 -33.15,158.02 -99.44,208.89 -66.29,50.87 -160.59,76.31 -282.89,76.31z"/> + </g> +</svg> diff --git a/docs/index.html b/docs/index.html index f4ad6ac..0aa540a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,3 +1,9 @@ +<script> + if (typeof navigator.serviceWorker !== 'undefined') { + navigator.serviceWorker.register('sw.js') + } +</script> + <!DOCTYPE html> <html lang="en"> <head> @@ -14,6 +20,7 @@ window.$docsify = { name: 'DAVIS', repo: 'https://github.com/DevToolsOrganization/matrix-data-visualization-DAVIS.git', + logo: '/_media/DevToolsDavis-updown-curves.svg', loadSidebar: true, subMaxLevel: 3, @@ -43,9 +50,8 @@ <script src="//cdn.jsdelivr.net/npm/docsify@latest/lib/plugins/search.min.js"></script> <script src="//cdn.jsdelivr.net/npm/docsify@latest/lib/plugins/zoom-image.min.js"></script> <script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-markdown.min.js"></script> -<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script> -<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-ruby.min.js"></script> -<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-yaml.min.js"></script> -<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-less.min.js"></script> +<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script> +<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-cpp.min.js"></script> + </html> diff --git a/docs/sw.js b/docs/sw.js new file mode 100644 index 0000000..ab3dbd3 --- /dev/null +++ b/docs/sw.js @@ -0,0 +1,83 @@ +/* =========================================================== + * docsify sw.js + * =========================================================== + * Copyright 2016 @huxpro + * Licensed under Apache 2.0 + * Register service worker. + * ========================================================== */ + +const RUNTIME = 'docsify' +const HOSTNAME_WHITELIST = [ + self.location.hostname, + 'fonts.gstatic.com', + 'fonts.googleapis.com', + 'cdn.jsdelivr.net' +] + +// The Util Function to hack URLs of intercepted requests +const getFixedUrl = (req) => { + var now = Date.now() + var url = new URL(req.url) + + // 1. fixed http URL + // Just keep syncing with location.protocol + // fetch(httpURL) belongs to active mixed content. + // And fetch(httpRequest) is not supported yet. + url.protocol = self.location.protocol + + // 2. add query for caching-busting. + // Github Pages served with Cache-Control: max-age=600 + // max-age on mutable content is error-prone, with SW life of bugs can even extend. + // Until cache mode of Fetch API landed, we have to workaround cache-busting with query string. + // Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190 + if (url.hostname === self.location.hostname) { + url.search += (url.search ? '&' : '?') + 'cache-bust=' + now + } + return url.href +} + +/** + * @Lifecycle Activate + * New one activated when old isnt being used. + * + * waitUntil(): activating ====> activated + */ +self.addEventListener('activate', event => { + event.waitUntil(self.clients.claim()) +}) + +/** + * @Functional Fetch + * All network requests are being intercepted here. + * + * void respondWith(Promise<Response> r) + */ +self.addEventListener('fetch', event => { + // Skip some of cross-origin requests, like those for Google Analytics. + if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) { + // Stale-while-revalidate + // similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale + // Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1 + const cached = caches.match(event.request) + const fixedUrl = getFixedUrl(event.request) + const fetched = fetch(fixedUrl, { cache: 'no-store' }) + const fetchedCopy = fetched.then(resp => resp.clone()) + + // Call respondWith() with whatever we get first. + // If the fetch fails (e.g disconnected), wait for the cache. + // If there’s nothing in cache, wait for the fetch. + // If neither yields a response, return offline pages. + event.respondWith( + Promise.race([fetched.catch(_ => cached), cached]) + .then(resp => resp || fetched) + .catch(_ => { /* eat any errors */ }) + ) + + // Update the cache with the version we fetched (only for ok status) + event.waitUntil( + Promise.all([fetchedCopy, caches.open(RUNTIME)]) + .then(([response, cache]) => response.ok && cache.put(event.request, response)) + .catch(_ => { /* eat any errors */ }) + ) + } +}) \ No newline at end of file