Skip to content

Commit

Permalink
additional UI options
Browse files Browse the repository at this point in the history
  • Loading branch information
wexxlee committed Jun 23, 2024
1 parent 41837ec commit d5aa13d
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 3 deletions.
41 changes: 41 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ div {
margin: 5px;
}

ul {
margin-top: 0;
}

input[type="checkbox"]:disabled + label {
color: lightgrey;
}

#titlebanner {
width: 100%;
background-color: blueviolet;
Expand All @@ -45,6 +53,39 @@ div {
text-align: center;
}

#changelog {
border: 1px solid black;
padding: 5px;
min-width: 700px;
max-width: 45%;
margin: auto;
margin-bottom: 30px;
display: block;
}

#changelog-header {
display: flex;
justify-content: center;
align-items: center;
background-color: #D0D0D0;
font-weight: 800;
font-size: 20px;
color: black;
}

#changelog-contents {
font-size: 15px;
color: #333333;
}

#warn {
font-size: 12px;
font-weight: 300;
color: red;
text-align: left;
padding-left: 25px;
}

#trainName {
width: 480px;
}
Expand Down
34 changes: 33 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
<body>
<div id="titlebanner">FFXIV Hunt Conductor Helper</div>
<br />
<div id="changelog">
<div id="changelog-header">CHANGE LOG</div>
<div id="changelog-contents">
<img src="https://img.shields.io/github/v/release/wexxlee/conductor-helper" />
&nbsp;&nbsp;
<img src="https://img.shields.io/github/release-date/wexxlee/conductor-helper" />
<ul>
<li>Added option to echo mark names on the same chat line as the mark flag</li>
<li>Added option to customize the number of output lines per macro</li>
</ul>
</li>
</div>
</div>
<div id="info">
<a href="https://github.com/wexxlee/conductor-helper/blob/main/README.md">Read Me/Instructions</a>&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="https://github.com/wexxlee/conductor-helper/issues">Report Issues &amp; Request Features</a>
Expand Down Expand Up @@ -39,11 +52,30 @@
<fieldset>
<legend>Options</legend>
<div>
<input type="checkbox" id="echoMarksAndFlags" />
<label for="echoMarksAndFlags">Echo mark names with flags</label>
<br />
<div id="warn"><b>NOTE:</b> If you do not want duplicated flags,
change ChatCoordinates' "General Chat Channel" to "Say" (or something else
that doesn't show in your echo log.).</div>
<br />
<input type="checkbox" id="includeZoneName" />
<label for="includeZoneName">Add zone name headers to macro</label>
<br />
<input type="checkbox" id="includeMarkName" />
<label for="includeMarkName">Add mark names to macro</label>
<label for="includeMarkName">Add mark name headers to macro</label>
<br />
<br />
Lines per macro:
<select id="linesPerMacro">
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15" selected>15</option>
</select>
<br />
<small>(in case you want to add stuff before running it)</small>
</div>
</fieldset>
<fieldset>
Expand Down
40 changes: 38 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,42 @@
const _ECHO_PREFIX = '/e';
const _MAX_LINES_PER_MACRO = 15;
let lastClickedButton = null;

window.onload = () => {
var warnDiv = document.getElementById('warn');

document.getElementById('echoMarksAndFlags').addEventListener('change', function() {
var isChecked = this.checked;
['includeZoneName', 'includeMarkName'].forEach((id) => {
var checkbox = document.getElementById(id);
checkbox.disabled = isChecked;
if (isChecked)
checkbox.checked = false;
});
});

['includeZoneName', 'includeMarkName'].forEach((id) => {
document.getElementById(id).addEventListener('change', function() {
var isOtherChecked = document.getElementById(id === 'includeZoneName' ? 'includeMarkName' : 'includeZoneName').checked;
var echoMarksAndFlags = document.getElementById('echoMarksAndFlags');
echoMarksAndFlags.disabled = this.checked || isOtherChecked;
if (this.checked || isOtherChecked) {
echoMarksAndFlags.disabled = true;
warnDiv.style.color = 'lightgrey';
echoMarksAndFlags.checked = false;
} else {
warnDiv.style.color = 'red';
echoMarksAndFlags.disabled = false;
}
});
});
}

function generateMacro() {
clearOutput();

linesPerMacro = document.getElementById('linesPerMacro').value ?? _MAX_LINES_PER_MACRO;

const regex = {
siren: /\(Maybe:\s*(?<mark>[^)]+)\)\s*.(?<zone>[\w\'\- ]+)\s*\(\s*(?<x>[0-9\.]+)\s*,\s*(?<y>[0-9\.]+)\s*\)/,
prime: /(?<mark>[^(]+)\s+\((?<x>[0-9\.]+)\s*,\s*(?<y>[0-9\.]+)\s*\)/,
Expand All @@ -29,6 +62,7 @@ function generateMacro() {
return;
}

const echoMarksAndFlags = document.getElementById('echoMarksAndFlags').checked;
const includeZoneName = document.getElementById('includeZoneName').checked;
const includeMarkName = document.getElementById('includeMarkName').checked;

Expand Down Expand Up @@ -104,6 +138,8 @@ function generateMacro() {
zoneMarkCount++;
zoneMarkNameCache.push(markName);
zoneMarkCoordCache.push(`${_CMD_PREFIX} ${x} ${y} : ${zoneName}`);
if (echoMarksAndFlags)
zoneMarkCoordCache.push(`${_ECHO_PREFIX}${markName}  &lt;flag&gt;`);
}

// push the final zone's marks, since the loop has ended
Expand Down Expand Up @@ -142,14 +178,14 @@ function displayMacro(output) {
function getFormattedMacro(output) {
let brokenOutput = '';
for (let i = 0; i < output.length; i++) {
if (i % _MAX_LINES_PER_MACRO === 0) {
if (i % linesPerMacro === 0) {
if (i !== 0) {
brokenOutput += '</div>';
}
brokenOutput += `<div class="macroText"><button class="copyButton" onclick="copyToClipboard(this)">Copy to Clipboard</button>`;
}
brokenOutput += output[i];
if ((i + 1) % _MAX_LINES_PER_MACRO !== 0 || i !== output.length - 1)
if ((i + 1) % linesPerMacro !== 0 || i !== output.length - 1)
brokenOutput += '<br />\n';
}
brokenOutput += '</div>';
Expand Down

0 comments on commit d5aa13d

Please sign in to comment.