From c6c461b0881765533a9775c6d2726f5f1dcd7c31 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Sun, 11 Oct 2020 19:04:23 +0200 Subject: [PATCH 1/8] initial version of web viewer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • converter class • fetch internals document • setup filter input --- index.html | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..20818a8 --- /dev/null +++ b/index.html @@ -0,0 +1,56 @@ + + +Apple Internals + + + + +

Apple Internals

+

Collected knowledge about the internals of Apple’s platforms.

+

Sorted by keyword, abbreviation, or codename.

+

Feel free to contribute on GitHub.

+ +
+ From 270096c6202bfdf9f4126c032d1d57f065dffee8 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Sun, 18 Oct 2020 21:05:28 +0200 Subject: [PATCH 2/8] parse out structural elements from the text row, term, definition --- index.html | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 20818a8..ed3b167 100644 --- a/index.html +++ b/index.html @@ -10,16 +10,36 @@ class Converter { this.filter = ""; } generate() { - // FIXME: placeholder - // break down to row, term, definition, statement, word const dl = document.createElement("dl"); - const dd = document.createElement("dd"); - const pre = document.createElement("pre"); - pre.textContent = this.text; - dd.append(pre); - dl.append(dd); + dl.setAttribute("class", "row"); + for (const rowText of this.text.split("\n")) + if (rowText.length && rowText.toLowerCase().includes(this.filter.toLowerCase())) + dl.append.apply(dl, this.generateRow(rowText)); return dl; } + generateRow(text) { + let result = new Array(); + const parts = text.split("\t"); + result.push(this.generateTerm(parts[0])); + result.push(this.generateDefinition(parts.slice(1).join("; "))); + return result; + } + generateTerm(text) { + const dt = document.createElement("dt"); + dt.setAttribute("class", "col-sm-2"); + dt.append(this.highlight(text)); + return dt; + } + generateDefinition(text) { + const dd = document.createElement("dd"); + dd.setAttribute("class", "col-sm-10"); + dd.append(this.highlight(text)); + return dd; + } + highlight(text) { + // TODO: highlight search text using + return text; + } } document.addEventListener("DOMContentLoaded", event => { From c8ad794b5edb9a99eee9492e82cb2a7991c1c787 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Sun, 18 Oct 2020 21:05:53 +0200 Subject: [PATCH 3/8] refactor and hook up filter control filter content after at least three characters have been typed --- index.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index ed3b167..c203972 100644 --- a/index.html +++ b/index.html @@ -49,14 +49,19 @@ document.addEventListener("DOMContentLoaded", event => { return response.text(); }).then(function(text) { const converter = new Converter(text); - const content = document.getElementById("content"); - content.append(converter.generate()); + const update = filter => { + converter.filter = filter; + const content = document.getElementById("content"); + while (content.firstChild) content.firstChild.remove(); + content.append(converter.generate()); + }; // update content when typing a filter word document.getElementById("filter").addEventListener("input", event => { - // TODO: re-run converter to filter table rows and highlight typed text + update(event.target.value.length >= 3 ? event.target.value : ""); }); // place cursor in filter control document.getElementById("filter").focus(); + update(""); }); }); From 1f1ad17d02e2c7749749dc4aae46ecf311624014 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Mon, 19 Oct 2020 19:07:56 +0200 Subject: [PATCH 4/8] highlight filter term in content use tag and style accordingly --- index.html | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index c203972..aecc167 100644 --- a/index.html +++ b/index.html @@ -27,18 +27,28 @@ class Converter { generateTerm(text) { const dt = document.createElement("dt"); dt.setAttribute("class", "col-sm-2"); - dt.append(this.highlight(text)); + dt.append.apply(dt, this.highlight(text)); return dt; } generateDefinition(text) { const dd = document.createElement("dd"); dd.setAttribute("class", "col-sm-10"); - dd.append(this.highlight(text)); + dd.append.apply(dd, this.highlight(text)); return dd; } highlight(text) { - // TODO: highlight search text using - return text; + if (!this.filter.length) return Array(text); + let result = new Array(); + let index = 0; + while (index = text.toLowerCase().indexOf(this.filter.toLowerCase()), index >= 0) { + result.push(text.substr(0, index)); + const mark = document.createElement("mark"); + mark.append(text.substr(index, this.filter.length)); + result.push(mark); + text = text.substr(index + this.filter.length); + } + result.push(text); + return result; } } @@ -70,6 +80,12 @@ document.addEventListener("DOMContentLoaded", event => { body { font-size: 90%; } + mark { + position: relative; + z-index: -1; + padding: .2em; + margin: -.2em; + }

Apple Internals

From 1241dfc40070fd2e549667592b633ca4611743ef Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Sun, 18 Oct 2020 23:16:40 +0200 Subject: [PATCH 5/8] select filter text on return --- index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.html b/index.html index aecc167..81c2708 100644 --- a/index.html +++ b/index.html @@ -69,6 +69,10 @@ document.addEventListener("DOMContentLoaded", event => { document.getElementById("filter").addEventListener("input", event => { update(event.target.value.length >= 3 ? event.target.value : ""); }); + // select filter text on return + document.getElementById("filter").addEventListener("change", event => { + event.target.select(); + }); // place cursor in filter control document.getElementById("filter").focus(); update(""); From c4904eea378e5a51f85f90ef63ea103552917a82 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Sun, 18 Oct 2020 23:17:09 +0200 Subject: [PATCH 6/8] button to clear filter --- index.html | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 81c2708..9bc5c84 100644 --- a/index.html +++ b/index.html @@ -73,9 +73,14 @@ document.addEventListener("DOMContentLoaded", event => { document.getElementById("filter").addEventListener("change", event => { event.target.select(); }); - // place cursor in filter control - document.getElementById("filter").focus(); - update(""); + // clear filter button + document.getElementById("clear").addEventListener("click", event => { + document.getElementById("filter").value = ""; + document.getElementById("filter").focus(); + update(""); + }); + // initialize filter control + document.getElementById("clear").click(); }); }); @@ -96,6 +101,13 @@ document.addEventListener("DOMContentLoaded", event => {

Collected knowledge about the internals of Apple’s platforms.

Sorted by keyword, abbreviation, or codename.

Feel free to contribute on GitHub.

- +
+ +
+ + + +
+
From 5b3c254539b3c851bf6cff7c38819c4a2359cbf8 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Mon, 19 Oct 2020 13:20:54 +0200 Subject: [PATCH 7/8] document the internals website --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64a727c..2598707 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ Apple Internals =============== This repository provides tools and information to help understand and analyze the internals -of Apple’s operating system platforms. Specifically, a [Nix +of Apple’s operating system platforms. Information is collected in a text file and +[presented on a website](https://mroi.github.io/apple-internals). A [Nix flake](https://github.com/tweag/rfcs/blob/flakes/rfcs/0049-flakes.md) allows to build the following externally hosted tools: From 7d128a1eb41ed0a9a0146eef879404e818cbc2e6 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Mon, 19 Oct 2020 19:08:37 +0200 Subject: [PATCH 8/8] MIT license --- LICENSE.txt | 21 +++++++++++++++++++++ README.md | 4 ++++ index.html | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..563dd14 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Michael Roitzsch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 2598707..a60c56f 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,7 @@ Unpacks asset catalogs to individual files. [**snapUtil**](https://github.com/ahl/apfs) Manages APFS snapshots. + +___ +This work is licensed under the [MIT license](https://mit-license.org) so you can freely use +and share as long as you retain the copyright notice and license text. diff --git a/index.html b/index.html index 9bc5c84..7f11cc3 100644 --- a/index.html +++ b/index.html @@ -100,7 +100,7 @@ document.addEventListener("DOMContentLoaded", event => {

Apple Internals

Collected knowledge about the internals of Apple’s platforms.

Sorted by keyword, abbreviation, or codename.

-

Feel free to contribute on GitHub.

+

Feel free to contribute on GitHub or share under MIT license.