summaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2021-04-22 16:17:42 -0700
committerOmar Rizwan <omar@omar.website>2021-04-22 16:17:42 -0700
commit4c30d9f9894236ed27e6542b8d7d0a4fa677f2b0 (patch)
tree1d4e0bbaeee7e2b963429318517001c29712b221 /extension
parent837c0ea3adea3dbfcd5de45db7e625833fb88a89 (diff)
downloadTabFS-4c30d9f9894236ed27e6542b8d7d0a4fa677f2b0.tar.gz
TabFS-4c30d9f9894236ed27e6542b8d7d0a4fa677f2b0.zip
extension: share cached backgroundJS between .js and .js.html file
delete anim stuff for now
Diffstat (limited to 'extension')
-rw-r--r--extension/background.js43
1 files changed, 16 insertions, 27 deletions
diff --git a/extension/background.js b/extension/background.js
index 97aa98c..6729c68 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -571,6 +571,19 @@ Routes["/runtime/reload"] = {
truncate() { return {}; }
};
+(function() {
+ let __backgroundJS;
+ Object.defineProperty(window, 'backgroundJS', {
+ async get() {
+ __backgroundJS = __backgroundJS ||
+ await window.fetch(chrome.runtime.getURL('background.js'))
+ .then(r => r.text());
+ return __backgroundJS;
+ },
+ set(js) { __backgroundJS = js; }
+ });
+})();
+
// added at first to make development on Safari less painful: Safari
// normally requires you to recompile the whole Xcode project to
// deploy any update to background.js.
@@ -582,9 +595,6 @@ Routes["/runtime/background.js"] = {
// reading right now! it needs to be a global because we want
// its value (the changed JS text) to survive even as this whole
// module gets re-evaluated.
- window.backgroundJS = window.backgroundJS ||
- await window.fetch(chrome.runtime.getURL('background.js'))
- .then(r => r.text());
return window.backgroundJS;
},
async ({}, buf) => { window.backgroundJS = buf; }
@@ -600,13 +610,11 @@ Routes["/runtime/background.js"] = {
};
Routes["/runtime/background.js.html"] = routeWithContents(async () => {
- const js = await window.fetch(chrome.runtime.getURL('background.js'))
- .then(r => r.text());
-
const classes = [
[/Routes\["[^\]]+"\] = /, 'route']
];
+ const js = await window.backgroundJS;
const classedJs =
js.split('\n')
.map((line, i) => {
@@ -627,7 +635,7 @@ Routes["/runtime/background.js.html"] = routeWithContents(async () => {
<head>
<style>
body { overflow-x: hidden; }
- .route { background-color: rgb(255, 196, 196); }
+ .route { color: blue; background-color: rgb(255, 196, 196); }
.line { position: absolute; height: 15px; width: 100%; }
.line { transition: height 0.5s cubic-bezier(0.64, 0.08, 0.24, 1), transform 0.5s cubic-bezier(0.64, 0.08, 0.24, 1); }
</style>
@@ -659,26 +667,6 @@ Routes["/runtime/background.js.html"] = routeWithContents(async () => {
}
}
render();
-
- for (let line of lines) {
- function treatNeighborLines(line, expand) {
- let neighborLine = line;
- while (neighborLine && !neighborLine.classList.contains('route')) {
- neighborLine.dataset.expand = expand;
- neighborLine = neighborLine.nextElementSibling;
- }
- neighborLine = line;
- while (neighborLine && !neighborLine.classList.contains('route')) {
- neighborLine.dataset.expand = expand;
- neighborLine = neighborLine.previousElementSibling;
- }
- render();
- }
- line.onmousedown = () => {
- treatNeighborLines(line, true);
- document.body.onmouseup = () => { treatNeighborLines(line, false); };
- };
- }
</script>
</body>
</html>
@@ -896,3 +884,4 @@ if (typeof process === 'object') {
} else {
tryConnect();
}
+