UNPKG

kdj_singlish

Version:

KDJ Singlish is an app which created to help people to type in sinhala without making any mistakes. This will save your time and fix all the issues you are getting when you type. Just use it and let me know the issues.

442 lines (394 loc) 12.4 kB
const { remote } = require('electron'); $(document).ready(function () { notification.innerHTML = `KDJ Singlish is Now Ready for 32 Bit & 64 Bit Operating Systems`; notification.opened = true; }); document.getElementById('close').addEventListener('click', closeWindow); document.getElementById('minimize').addEventListener('click', minimizeWindow); document.getElementById('maximize').addEventListener('click', maximizeWindow); function closeWindow() { var window = remote.getCurrentWindow(); window.close(); } function minimizeWindow() { var window = remote.getCurrentWindow(); window.minimize(); } function maximizeWindow() { var window = remote.getCurrentWindow(); if (!window.isMaximized()) { window.maximize(); } else { window.unmaximize(); } } $(function () { $('#btnCopyUni').click(function () { let notification = document.querySelector('#notification'); $('#unicode_textarea').focus(); $('#unicode_textarea').select(); document.execCommand('copy'); notification.innerHTML = `Unicode Text has copied to the clipboard`; notification.opened = true; }); }); $(function () { $('#btnCopyFont').click(function () { $('#fmabaya_textarea').focus(); $('#fmabaya_textarea').select(); document.execCommand('copy'); notification.innerHTML = `Font Text has copied to the clipboard`; notification.opened = true; }); }); // WORD SUGESSIONS ACTIVATED function start() { var basepath = app.getPath('documents'); const suggestionsFile = basepath + '\\KDJ_Singlish\\suggestions.txt'; var $radios = $('input:radio[name=optradio]'); if ($radios.is(':checked') === false) { $radios.filter('[value=offline]').prop('checked', true); $.get(suggestionsFile, function (data) { var suggests = data.split(','); console.log(suggests); new Suggest.LocalMulti('input_textarea', 'suggest', suggests, { dispAllKey: false, dispMax: 6, interval: 500, classMouseOver: false, highlight: true }); return false; }); } $("input[name='optradio']").click(function () { if ($('#radio1').is(':checked')) { console.log('Online Suggessions Library Activated'); $.get(suggestionsFile, function (data) { var suggests = data.split(','); console.log(suggests); new Suggest.LocalMulti('input_textarea', 'suggest', suggests, { dispAllKey: false, dispMax: 6, interval: 500, highlight: true }); return false; }); } else { console.log('Online Suggessions Library Activated'); $.get('https://api.kdjguru.com/kdj_singlish_suggests.txt', function (data) { var suggests = data.split(','); console.log(suggests); new Suggest.LocalMulti('input_textarea', 'suggest', suggests, { dispAllKey: false, dispMax: 6, interval: 500 }); }); } }); // $('#radio1').change(function () { // if ($('#radio1').is(':checked')) { // alert("checked"); // console.log('Offline Suggessions Library Activated') // $.get('../sinhalaSuggessions.txt', function (data) { // var suggests = data.split(','); // console.log(suggests); // new Suggest.LocalMulti("input_textarea", "suggest", suggests, { // dispAllKey: false, // dispMax: 5, // interval: 500 // }); // }); // } // else if (s) { // alert('unchecked') // } // }); // $('#radio2').change(function () { // console.log('Online Suggessions Library Activated') // $.get('https://api.kdjguru.com/kdj_singlish_suggests.txt', function (data) { // var suggests = data.split(','); // console.log(suggests); // new Suggest.LocalMulti("input_textarea", "suggest", suggests, { // dispAllKey: false, // dispMax: 5, // interval: 500 // }); // }); // }); } window.addEventListener ? window.addEventListener('load', start, false) : window.attachEvent('onload', start); // $('#unicode_textarea').focus(function () { // var theVal = $(this).val(); // $(this).val(theVal); // }); var inputBox = document.getElementById('typeArea'); var unicodeScroll = document.getElementById('unicode_textarea'); var fontScroll = document.getElementById('fmabaya_textarea'); function hideUnicode() { // Get the checkbox var checkBox = document.getElementById('hideUnicode'); var unicodeArea = document.getElementById('unicodeArea'); if (checkBox.checked == true) { console.log('hello'); unicodeArea.classList.remove('hideArea'); } else { console.log('bello'); unicodeArea.classList.add('hideArea'); } } function hideFont() { // Get the checkbox var checkBox = document.getElementById('hideFont'); var fontArea = document.getElementById('fontArea'); if (checkBox.checked == true) { console.log('hello'); fontArea.classList.remove('hideArea'); } else { console.log('bello'); fontArea.classList.add('hideArea'); } } $('#input_textarea').on('keyup', function () { //console.log("ok"); $('#tick')[0].pause(); $('#tick')[0].currentTime = 0; $('#tick')[0].play(); $('#tick')[0].volume = 0.3; }); function muteTickSound() { if ($('#muteTickSound').prop('checked')) { console.log('current state: checked'); // AUDIO PLAYS $('#input_textarea').on('keyup', function () { //console.log("ok"); $('#tick')[0].pause(); $('#tick')[0].currentTime = 0; $('#tick')[0].play(); $('#tick')[0].volume = 0.3; }); } else { console.log('current state: unchecked'); $('#input_textarea').on('keyup', function () { //console.log("ok"); $('#tick')[0].volume = 0; }); } } // Adds and removes body class depending on screen width. function screenClass() { if ($(window).innerWidth() < 790) { $('#typeArea').addClass('col-sm-12').removeClass('col'); $('#unicodeArea').addClass('col-sm-12').removeClass('col'); $('#fontArea').addClass('col-sm-12').removeClass('col'); } else { $('#typeArea').addClass('col').removeClass('col-sm-12'); $('#unicodeArea').addClass('col').removeClass('col-sm-12'); $('#fontArea').addClass('col').removeClass('col-sm-12'); } } // Fire. screenClass(); // And recheck when window gets resized. $(window).bind('resize', function () { screenClass(); }); function resizeText(multiplier) { var typeArea = document.getElementById('input_textarea'); var unicodeArea = document.getElementById('unicode_textarea'); var fontArea = document.getElementById('fmabaya_textarea'); var currentSize = typeArea.style.fontSize || 1; typeArea.style.fontSize = parseFloat(currentSize) + multiplier * 0.1 + 'em'; unicodeArea.style.fontSize = parseFloat(currentSize) + multiplier * 0.1 + 'em'; fontArea.style.fontSize = parseFloat(currentSize) + multiplier * 0.1 + 'em'; } // WRITE IN TEXT DOCUMENT // WORD SUGGESTIONS AUTO ADD function duplicateCheck() { var output = document.getElementById('Output'); output.innerHTML = ''; var textArea = document.getElementById('input_textarea'); var inputSerials = textArea.value.trim().split(" "); var outputSerials = new Object(); for (var i = 0; i < inputSerials.length; i++) { var serial = inputSerials[i]; //build an object whose properties are serials //if the serial exists, incremint a counter if (outputSerials[serial]) { outputSerials[serial]++; } else { outputSerials[serial] = 1; } } // For testing // output.innerHTML = // 'Serials: <br />'; // for (var i in outputSerials) { // output.innerHTML += i + " "; // } for (var i in outputSerials) { //check to see if we have any duplicates if (outputSerials[i] > 2) { output.innerHTML += "," + i; } } } $('#input_textarea').on('change', function () { var output = document.getElementById('Output'); var test = Output.innerHTML; var suggession = test; if (Output.innerHTML.length > 2) { var basepath = app.getPath('documents'); const suggestionsFile = basepath + '\\KDJ_Singlish\\suggestions.txt'; fs.readFile(suggestionsFile, 'utf8', function (err, contents) { var output = document.getElementById('Output'); var suggetionsList = contents; Output.innerHTML = contents; console.log(contents); // Bug Fix: Check 3 words together with diferent variations if (suggetionsList.indexOf(test) != -1) { console.log('It\'s in the list'); Output.innerHTML = ""; return false; } else { var basepath = app.getPath('documents'); const suggestionsFile = basepath + '\\KDJ_Singlish\\suggestions.txt'; fs.appendFile(suggestionsFile, suggession, function (err) { if (err) { return console.log(err); } alert('Your suggestion added to the database. Add more to fast up your process.'); console.log("Saved"); Output.innerHTML = ""; }); console.log('It\'s not in the list'); } }); } }); $(function () { $('#clearSuggest').click(function () { var suggestedWord = document.getElementById('suggestedWord'); suggestedWord.value = ""; }) }); var basepath = app.getPath("documents"); const tempSaveFile = basepath + '\\KDJ_Singlish\\tempSave.txt'; const folderPath = basepath + '\\KDJ_Singlish'; $('#input_textarea').change(function () { var textArea = document.getElementById('input_textarea'); var tempText = textArea.value; setTimeout( fs.appendFile(tempSaveFile, tempText, function (err) { if (err) { return console.log(err); } console.log("Saved Temporary Text"); }), 2000); }); document.addEventListener("DOMContentLoaded", function (event) { // - Code to execute when all DOM content is loaded. // - including fonts, images, etc. // Path.join(require('os').homedir(), 'Desktop/whatever'); // const suggestionsFile = new URL('file:///C:/KDJ_Singlish/suggestions.txt'); var basepath = app.getPath("documents"); const suggestionsFile = basepath + '\\KDJ_Singlish\\suggestions.txt'; // console.log(suggestionsFile) const tempSaveFile = basepath + '\\KDJ_Singlish\\tempSave.txt'; const folderPath = basepath + '\\KDJ_Singlish'; const contentSug = fs.readFileSync('sinhalaSuggessions.txt', 'utf8'); console.log(contentSug); try { if (!fs.existsSync(folderPath)) { fs.mkdirSync(folderPath) } else { console.log('KDJ_Singlish folder is already in place...') } } catch (err) { console.error(err) alert('err') } // console.log(app.getPath('userData') + "\\s"); try { if (fs.existsSync(suggestionsFile)) { //file exists console.log('Suggession Fille is already in place...') } else { fs.writeFile(tempSaveFile, '', function (err) { if (err) { return console.log(err); } else{ fs.writeFile(suggestionsFile, contentSug, function (err) { if (err) { return console.log(err); } console.log("Saved Temporary Text"); }); } console.log("Saved Temporary Text"); }); } } catch (err) { console.error(err) } }); // GET LIST OF SUGGESSIONS WITH AJAX // $("#btnAddSuggest").click(function () { // $.ajax({ // url: "../sources/sinhalaSuggessions.txt", // success: function (result) { // $("#list").html(result); // console.log('hello'); // } // }); // }); // WRITE TEXT FILE USIGN AJAX // $("#btnAddSuggest").click(function () { // $.ajax({ // url: "../sources/sinhalaSuggessions.txt", // success: function (result) { // console.log('hello'); // } // }); // }); $(function () { $('#btnAddSuggest').click(function () { var suggestedWord = document.getElementById('suggestedWord'); var test = suggestedWord.value; var suggession = "," + test; if (suggestedWord.value.length > 0) { var basepath = app.getPath('documents'); const suggestionsFile = basepath + '\\KDJ_Singlish\\suggestions.txt'; fs.readFile(suggestionsFile, 'utf8', function (err, contents) { var output = document.getElementById('Output'); var suggetionsList = contents; Output.innerHTML = contents; console.log(contents); if (suggetionsList.indexOf(test) > -1) { console.log('It\'s in the list'); alert('Sorry, That word has aready added to the list.'); Output.innerHTML = ""; return false; } else { fs.appendFile(suggestionsFile, suggession, function (err) { if (err) { return console.log(err); } alert('Your suggestion added to the database. Add more to fast up your process.'); console.log("Saved"); Output.innerHTML = ""; }); console.log('It\'s not in the list'); } }); } else { alert('Type your word or phrase first. Then try again.'); } }); });