Skip to content

Commit

Permalink
Update ttveditor.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rmens committed Oct 27, 2024
1 parent e82c1f9 commit 5473990
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions assets/js/ttveditor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function(){
// Character limit settings from localized script data
var softLimitText = parseInt(ttveditorData.soft_limit_text, 10);
var hardLimitText = parseInt(ttveditorData.hard_limit_text, 10);
var softLimitText = parseInt(teksttveditor_options.soft_limit_text, 10);
var hardLimitText = parseInt(teksttveditor_options.hard_limit_text, 10);

var softLimitTitle = parseInt(ttveditorData.soft_limit_title, 10);
var hardLimitTitle = parseInt(ttveditorData.hard_limit_title, 10);
var softLimitTitle = parseInt(teksttveditor_options.soft_limit_title, 10);
var hardLimitTitle = parseInt(teksttveditor_options.hard_limit_title, 10);

function wpautop(text, br = true) {
if (text.trim() === '') return '';
Expand Down Expand Up @@ -88,7 +88,7 @@
"body": wpautop(pageContent),
"title": titleValue,
"duration": 5000,
"image": ttveditorData.image_url
"image": teksttveditor_options.image_url
};

var jsonString = JSON.stringify(data);
Expand Down Expand Up @@ -129,12 +129,12 @@
var pageNum = index + 1;
var length = pageText.trim().length;

// Soft limit warning in gray
if (length >= softLimitText && length < hardLimitText) {
// Soft limit warning in gray
warnings.push('<li style="color: gray;">Pagina ' + pageNum + ' nadert de limiet van ' + hardLimitText + ' tekens (' + length + ' tekens).</li>');
}
// Hard limit warning in red
if (length >= hardLimitText) {
// Hard limit warning in red
warnings.push('<li style="color: red;">Pagina ' + pageNum + ' heeft de limiet van ' + hardLimitText + ' tekens overschreden! (' + length + ' tekens).</li>');
overHardLimit = true;
}
Expand Down Expand Up @@ -183,11 +183,9 @@
if (overHardLimit) {
if (textArea) {
textArea.style.backgroundColor = '#ffe6e6'; // Light red
textArea.style.backgroundColor = '#ffe6e6';
}
if (titleInput) {
titleInput.style.backgroundColor = '#ffe6e6'; // Light red
titleInput.style.backgroundColor = '#ffe6e6';
}
} else {
if (textArea) {
Expand Down Expand Up @@ -238,7 +236,7 @@
var base64Strings = generateBase64();
if (base64Strings.length > 0) {
base64Strings.forEach(function(base64String) {
var previewUrl = ttveditorData.preview_url + encodeURIComponent(base64String);
var previewUrl = teksttveditor_options.preview_url + encodeURIComponent(base64String);
window.open(previewUrl, '_blank');
});
}
Expand Down

0 comments on commit 5473990

Please sign in to comment.