Skip to content

Commit 5eb3e97

Browse files
committed
* common.js: add function to put placeholders of elements to their titles
* tweak description of BHAV to diagram * tweak index page styles
1 parent d15cfab commit 5eb3e97

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ https://cosmatevs.github.io/bhav-to-diagram.html
33

44
A web tool for The Sims 2 modders that converts [SimPe](https://modthesims.info/showthread.php?t=630456) [BHAV](https://modthesims.info/wiki.php?title=BHAV) code to [Mermaid](https://mermaid.live/edit) diagrams. It's intended to make BHAV functions easier to understand, especially the big ones.
55

6-
Hover over interface elements (e.g. buttons, text areas) to see explanations of what they do.
6+
Hover over interface elements (e.g. buttons, icons, text areas) to see explanations of what they do.
77

88
![BHAV to Mermaid diagram tool appearance](readme-images/bhav-to-diagram.png)

assets/common.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
function debounce(callback, wait) {
2-
let timeoutId = null;
3-
return (...args) => {
4-
window.clearTimeout(timeoutId);
5-
timeoutId = window.setTimeout(
6-
() => callback(...args), wait
7-
);
8-
};
2+
let timeoutId = null;
3+
return (...args) => {
4+
window.clearTimeout(timeoutId);
5+
timeoutId = window.setTimeout(
6+
() => callback(...args), wait
7+
);
8+
};
99
}
1010

1111
function removeFromArray(array, object) {
12-
array.splice(array.indexOf(object), 1);
12+
array.splice(array.indexOf(object), 1);
1313
}
1414

1515
function distinctFilter(value, index, array) {
16-
return array.indexOf(value) === index;
16+
return array.indexOf(value) === index;
17+
}
18+
19+
function putPlaceholdersInTitles() {
20+
document.querySelectorAll('*[placeholder]').forEach(element => {
21+
element.setAttribute('title', element.getAttribute('placeholder'));
22+
})
1723
}

bhav-to-diagram.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>The Sims 2 BHAV to Mermaid diagram</title>
88
<link rel="icon" type="image/x-icon" href="assets/favicon.svg">
99
<link rel="stylesheet" href="assets/style.css?v=4" />
10-
<script src="assets/common.js?v=2"></script>
10+
<script src="assets/common.js?v=3"></script>
1111
<script src="assets/svg-pan-zoom-container.js?v=0.6.1"></script> <!-- https://github.com/luncheon/svg-pan-zoom-container -->
1212
<style>
1313
:root {
@@ -128,8 +128,7 @@
128128

129129
<body>
130130
<section id="textareas">
131-
<textarea id="input-code" spellcheck="false" placeholder="Here goes your BHAV code"
132-
title="Here goes your BHAV code"></textarea>
131+
<textarea id="input-code" spellcheck="false" placeholder="Here goes your BHAV code"></textarea>
133132
<section id="settings">
134133
<button id="tutorial-button" title="Replace the code in the BHAV textbox with a tutorial code">
135134
Show tutorial
@@ -166,7 +165,7 @@
166165
</a>
167166
</div>
168167
</section>
169-
<textarea id="output-code" readonly title="The BHAV code translated into Mermaid diagram code"></textarea>
168+
<textarea id="output-code" readonly placeholder="The BHAV code translated into Mermaid diagram code"></textarea>
170169
</section>
171170
<section id="visual-output">
172171
<div id="diagram-wrapper" data-zoom-on-wheel="zoom-amount: 0.001; min-scale: 0.9; max-scale: 20;" data-pan-on-drag>
@@ -202,6 +201,7 @@
202201
tutorialButton.addEventListener('click', () => showTutorial());
203202
diagramResetViewButton.addEventListener('click', () => resetView());
204203

204+
putPlaceholdersInTitles();
205205
setTheme();
206206

207207
function handleInput(input) {

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<style>
1111
body {
1212
--body-padding: 1.5rem;
13+
min-height: max-content;
1314
max-width: 30rem;
1415
margin: auto;
1516
box-shadow: 0 0 1rem #0004;
@@ -21,6 +22,8 @@
2122

2223
dt {
2324
font-weight: bold;
25+
font-size: 1.25rem;
26+
margin-block-start: 1rem;
2427
}
2528

2629
dd {
@@ -44,7 +47,7 @@ <h1>The Sims 2 tools</h1>
4447
especially the big ones.
4548
</p>
4649
<p>
47-
Hover over interface elements (e.g. buttons, text areas)
50+
Hover over interface elements (e.g. buttons, icons, text areas)
4851
to see explanations of what they do.
4952
</p>
5053
</dd>

0 commit comments

Comments
 (0)