Mga lods pa help po pa combine ng 2 js codes kapag kasi kinokombine ko lagi hindi nanabasa yung isang code.
Script 2
Code:
// Get the text area and count elements
var textInput = document.getElementById('text-input');
var wordCountElement = document.getElementById('word-count');
var sentenceCountElement = document.getElementById('sentence-count');
// Add an event listener to the text area
textInput.addEventListener('input', function() {
// Get the text from the text area
var text = textInput.value;
// Count the words by splitting the text on any whitespace character and filtering out empty strings
var words = text.split(/\s+/).filter(function(word) {
return word !== '';
});
var wordCount = words.length;
// Count the sentences by splitting the text on periods, exclamation marks, and question marks
var sentences = text.split(/[.!?]/).filter(function(sentence) {
return sentence !== '';
});
var sentenceCount = sentences.length;
// Update the word and sentence count elements
wordCountElement.textContent = 'Word Count: ' + wordCount;
sentenceCountElement.textContent = 'Sentence Count: ' + sentenceCount;
});
// Add below your existing event listener
document.getElementById('start-ocr').addEventListener('click', function() {
var fileSelector = document.getElementById('file-selector');
if (fileSelector.files.length > 0) {
var file = fileSelector.files[0];
Tesseract.createWorker().then(worker => {
worker.recognize(file).then(function(result) {
// Get the recognized text from the result
var text = result.data.text;
// Set the recognized text as input
textInput.value = text;
// Trigger the input event to update counts
textInput.dispatchEvent(new Event('input'));
// Terminate the worker
worker.terminate();
}).catch(function(error) {
// Handle any errors that might occur
console.error(error);
alert('An error occurred while performing OCR.');
});
})
}
});
Script 2
Code:
/* SWITCH */
(function($) { "use strict";
//Page cursors
document.getElementsByTagName("body")[0].addEventListener("mousemove", function(n) {
t.style.left = n.clientX + "px",
t.style.top = n.clientY + "px",
e.style.left = n.clientX + "px",
e.style.top = n.clientY + "px",
i.style.left = n.clientX + "px",
i.style.top = n.clientY + "px"
});
var t = document.getElementById("cursor"),
e = document.getElementById("cursor2"),
i = document.getElementById("cursor3");
function n(t) {
e.classList.add("hover"), i.classList.add("hover")
}
function s(t) {
e.classList.remove("hover"), i.classList.remove("hover")
}
s();
for (var r = document.querySelectorAll(".hover-target"), a = r.length - 1; a >= 0; a--) {
o(r[a])
}
function o(t) {
t.addEventListener("mouseover", n), t.addEventListener("mouseout", s)
}
//Navigation
var app = function () {
var body = undefined;
var menu = undefined;
var menuItems = undefined;
var init = function init() {
body = document.querySelector('body');
menu = document.querySelector('.menu-icon');
menuItems = document.querySelectorAll('.nav__list-item');
applyListeners();
};
var applyListeners = function applyListeners() {
menu.addEventListener('click', function () {
return toggleClass(body, 'nav-active');
});
};
var toggleClass = function toggleClass(element, stringClass) {
if (element.classList.contains(stringClass)) element.classList.remove(stringClass);else element.classList.add(stringClass);
};
init();
}();
//Switch light/dark
$("#switch").on('click', function () {
if ($("body").hasClass("light")) {
$("body").removeClass("light");
$("#switch").removeClass("switched");
}
else {
$("body").addClass("light");
$("#switch").addClass("switched");
}
});
})(jQuery);
[\CODE]