Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonMrt committed Sep 8, 2024
1 parent 768d930 commit e434054
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 17 deletions.
26 changes: 13 additions & 13 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
![chart](https://github.com/valvals/devtools/assets/104432560/43903324-f49c-42f3-9ef1-3cb7e95a786d)
<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);
```
![chart](https://github.com/valvals/devtools/assets/104432560/43903324-f49c-42f3-9ef1-3cb7e95a786d)
</details>
# 💻 Usage
Expand Down
37 changes: 37 additions & 0 deletions docs/_media/DevToolsDavis-updown-curves.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script>
if (typeof navigator.serviceWorker !== 'undefined') {
navigator.serviceWorker.register('sw.js')
}
</script>

<!DOCTYPE html>
<html lang="en">
<head>
Expand All @@ -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,
Expand Down Expand Up @@ -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>
83 changes: 83 additions & 0 deletions docs/sw.js
Original file line number Diff line number Diff line change
@@ -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 */ })
)
}
})

0 comments on commit e434054

Please sign in to comment.