Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
hadithmv committed Dec 19, 2024
1 parent 7b0a194 commit 1213f2e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
11 changes: 4 additions & 7 deletions page-uc/textEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -1197,15 +1197,12 @@ <h4>Add or remove Prefix/Suffix for each line</h4>

<!-- -->

<!-- !!! why is this id even listener dependant?
? and what more functions are in the js that can be moved to case -->
<!-- !!! what more event listener dependent functions are in the js that can be moved to case -->

<!-- -->

<div class="dropdown-button">
<button
id="convertQuotes"
class="function-button"
title="Quote conversion options"
>
<button class="function-button" title="Quote conversion options">
Quote Conv 🎤
</button>
<div class="dropdown-content quote-converter">
Expand Down
68 changes: 35 additions & 33 deletions page-uc/textEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,41 @@ document.addEventListener("DOMContentLoaded", () => {
);
break;

/* OLD CODE
let isSmartQuotes = false;
document.getElementById("convertQuotes").addEventListener("click", () => {
if (isSmartQuotes) {
// Convert smart quotes to straight quotes
textArea.value = textArea.value
.replace(/[\u2018\u2019]/g, "'")
.replace(/[\u201C\u201D]/g, '"');
} else {
// Convert straight quotes to smart quotes for RTL
textArea.value = textArea.value
.replace(/(\W|^)"(\S)/g, "$1\u201D$2") // opening doubles
.replace(/(\u201D[^"]*)"([^"]*$|[^\u201D"]*\u201D)/g, "$1\u201C$2") // closing doubles
.replace(/([^0-9])"/g, "$1\u201C") // remaining double closing
.replace(/(\W|^)'(\S)/g, "$1\u2019$2") // opening singles
.replace(/([a-z])'([a-z])/gi, "$1\u2018$2") // contractions
.replace(/((\u2019[^']*)|[a-z])'([^0-9]|$)/gi, "$1\u2018$3") // closing singles
.replace(
/(\u2019)([0-9]{2}[^\u2018]*)(\u2019([^0-9]|$)|$|\u2018[a-z])/gi,
"\u2018$2$3"
) // abbrev. years like '93
.replace(
/(\B|^)\u2019(?=([^\u2018]*\u2018\b)*([^\u2018\u2019]*\W[\u2018\u2019]\b|[^\u2018\u2019]*$))/gi,
"$1\u2018"
) // backwards apostrophe
.replace(/'''/g, "\u2034") // triple prime
.replace(/''/g, "\u2033") // double prime
.replace(/'/g, "\u2032"); // prime
}
isSmartQuotes = !isSmartQuotes;
updateStats();
});
//
*/

// =====================================================

// Web Languages
Expand Down Expand Up @@ -1722,39 +1757,6 @@ document.addEventListener("DOMContentLoaded", () => {
});
//

let isSmartQuotes = false;
document.getElementById("convertQuotes").addEventListener("click", () => {
if (isSmartQuotes) {
// Convert smart quotes to straight quotes
textArea.value = textArea.value
.replace(/[\u2018\u2019]/g, "'")
.replace(/[\u201C\u201D]/g, '"');
} else {
// Convert straight quotes to smart quotes for RTL
textArea.value = textArea.value
.replace(/(\W|^)"(\S)/g, "$1\u201D$2") // opening doubles
.replace(/(\u201D[^"]*)"([^"]*$|[^\u201D"]*\u201D)/g, "$1\u201C$2") // closing doubles
.replace(/([^0-9])"/g, "$1\u201C") // remaining double closing
.replace(/(\W|^)'(\S)/g, "$1\u2019$2") // opening singles
.replace(/([a-z])'([a-z])/gi, "$1\u2018$2") // contractions
.replace(/((\u2019[^']*)|[a-z])'([^0-9]|$)/gi, "$1\u2018$3") // closing singles
.replace(
/(\u2019)([0-9]{2}[^\u2018]*)(\u2019([^0-9]|$)|$|\u2018[a-z])/gi,
"\u2018$2$3"
) // abbrev. years like '93
.replace(
/(\B|^)\u2019(?=([^\u2018]*\u2018\b)*([^\u2018\u2019]*\W[\u2018\u2019]\b|[^\u2018\u2019]*$))/gi,
"$1\u2018"
) // backwards apostrophe
.replace(/'''/g, "\u2034") // triple prime
.replace(/''/g, "\u2033") // double prime
.replace(/'/g, "\u2032"); // prime
}
isSmartQuotes = !isSmartQuotes;
updateStats();
});
//

// TRANSLITERATION
// https://github.com/naxeem/thaana-transliterator-js/blob/main/thaana-transliterator.js

Expand Down

0 comments on commit 1213f2e

Please sign in to comment.