var worker = new Worker("/applications/dictionary/spellchecker/js/correctionWorker.js"); var textElements = new Array(); var errorsNumber = 1; var isWorkingOnCorrection = false; var isAlreadyAdviceToPerformCorrection = true; var pos = 0; var indexOfElements = 0; var isInterruptCorrection = false; // The master Array var checkedElements = new Array(0); var currentElement = 0; // inizializzato a -1 perché incrementato prima di usarlo var currentEvent = -1; // The skip Array var skipArray = new Array(0); // The processed Objects Associative Array var changeWords = new Array(0); // elemento da scorrere nel dom per andare a prendere gli oggetti dell'editor var elementToIncrement = 0; var menuVisualize = false; $(document).ready(function () { loadAllForms(); }); /****************************************************************************************************************************************************************************************** * * FUNZIONE DI ANALISI DEL TESTO * Correzione del paragrafo e caricamento delle parole nei menù contestuali per la scelta utente TRAMITE ACCESSO AL DB * ******************************************************************************************************************************************************************************************/ function loadAllForms() { var langId = $('#LANGUAGE').val(); var noExc = (!langId && !sessionStorage.getItem('__sc_cort_formary_exception')) || // lingua singola CROS (langId && !sessionStorage.getItem('__sc_cort_formary_exception_' + langId)); // lingue plurime LADINS var noLocStorage = localStorage && !localStorage.getItem('__sc_cort_formary_'); var noSexStorage = sessionStorage && !sessionStorage.getItem('__sc_cort_formary_'); var loadFormary = noExc && noLocStorage && noSexStorage; if (loadFormary && false) { var existStorage = (!isChrome && localStorage != undefined) || (isChrome && sessionStorage != undefined); // to-do? passare anche valore del background? //var background = $('#BACKGROUND').val(); var params = new Object(); params.IDLANG = langId; var url = contextPath + "/applications/dictionary/spellchecker/ajax/ajaxCorrectWordsLoader.jsp?IDLANG=13"; $.getJSON(url, params, function (formary) { /*if(existStorage) { try { localStorage.setItem(' __sc_cort_formary_', JSON.stringify(formary)); sessionStorage.removeItem(' __sc_cort_formary_exception'); } catch(exc) { if(sessionStorage) { try { sessionStorage.setItem(' __sc_cort_formary_', JSON.stringify(formary)); sessionStorage.removeItem(' __sc_cort_formary_exception'); } catch(cexc){ sessionStorage.setItem(' __sc_cort_formary_exception', 'yes'); sessionStorage.setItem(' __sc_cort_formary_exception_'+ langId, 'yes'); //$('#browserMessage_2').html(cexc + '

'); console.log(exc); console.log(cexc); $('#browserMessage_2').html(' Non è stato possibile caricare il dizionario nel tuo browser. La correzione sarà più lenta.

'); } } } }*/ _init(); }); } else _init(); } /****************************************************************************************************************************************************************************************** * * FUNZIONE DI COSTRUZIONE DELL'EDITOR * ******************************************************************************************************************************************************************************************/ function _init() { buildTextArea(); $('#areaText').wysiwyg({ autoGrow: true, /* maxHeight: 1000, initialContent: "", */ maxLength: 23000, controls: { bold: {visible: true}, italic: {visible: true}, underline: {visible: true}, strikeThrough: {visible: true}, justifyLeft: {visible: true}, justifyCenter: {visible: true}, justifyRight: {visible: true}, justifyFull: {visible: true}, indent: {visible: true}, outdent: {visible: true}, subscript: {visible: true}, superscript: {visible: true}, undo: {visible: true}, redo: {visible: true}, cut: {visible: true}, copy: {visible: true}, paste: {visible: true}, html: {visible: true}, increaseFontSize: {visible: true}, decreaseFontSize: {visible: true}, insertOrderedList: {visible: true}, insertUnorderedList: {visible: true}, insertHorizontalRule: {visible: true}, // hidden buttons code: {visible: false}, insertImage: {visible: false}, removeFormat: {visible: false} }, events: { click: function (event) { if ($(event.target).is('a')) { window.open($(event.target).attr('href')); } else if ($($(event.target).parents()[0]).is('a')) { if (event.button == '0') window.open($(event.target).closest('a').attr('href')); else if (event.button == '2') $(event.target).trigger('rightClick'); } if (isWorkingOnCorrection) { event.preventDefault(); alert("Correzione ancora in corso"); } if (!isWorkingOnCorrection && !isAlreadyAdviceToPerformCorrection) { event.preventDefault(); isAlreadyAdviceToPerformCorrection = true; } // ripulitura del testo di invito alla scrittura var $textArea = $('#areaText'); var content = $textArea.wysiwyg("getContent"); if ("

" == content || " " == content) $textArea.wysiwyg("clear"); // Se c'è un contextMenù attivo lo nasconde in modo da simulare il click fuori focus per disattivare il menù. $('#openXMLContainer').hide(); $(".cntxtMn").hide(); }, keydown: function (event) { var $textArea = $('#areaText'); var document = $textArea.data("wysiwyg").editorDoc; var sel = document.getSelection();// var range = sel.getRangeAt(0); var textnode = range.startContainer;//document.getElementsByTagName("span").item(0); var node = range.startContainer.parentNode;//document.getElementsByTagName("span").item(0); //var bodyNode = document.getElementsByTagName("body")[0]; if (node.tagName == "SPAN" && $(node).attr('class') == "hlErr") { //alert('gente, son dentro diehene'); var len = textnode.textContent.trim().length; var caret = range.startOffset; if (len == caret && event.keyCode == '32') { range.setStartAfter(node); range.setEndAfter(node); //event.preventDefault(); } } }, // aggiunto per verificare la lunghezza di un testo eventualmente incollato keyup: function (event) { var $textArea = $('#areaText'); var text = $textArea.wysiwyg("getText"); if (23000 > 0 && text.length >= 23000 ) { text = text.substring(0, 23000); $('#wysiwyg_areaText').contents().find('body').text(text); alert('lunghezza massima superata: 23000'); } }, mousedown: function (event) { //buildMenu($(event.target)); } , mouseover: function (event) { if ($(event.target).is('a')) { $(event.target).css('cursor', 'pointer'); } else if ($($(event.target).parents()[0]).is('a')) { $(event.target).closest('a').css('cursor', 'pointer'); } else { buildMenu($(event.target)); } } } }); // eliminazione contextMenu var bodyHtml = $('#wysiwyg_areaText').contents().find('body'); // distruggo i context menù associati agli span bodyHtml.destroyContextMenu(); // distruggo il context menù del sistema operativo bodyHtml.bind('contextmenu', function () { return false; }); // funzione per scrollare insieme alla pagina un elemento, che nel nostro caso è un div $(".scrollableEl").jScroll(); //gestione hover sui buttons $('.buttonHtml').hover(function () { $(this).toggleClass('buttonHtml-hover'); }); if (isOpera) $('#browserMessage_1').html('Per una migliore esperienza d\'uso, potrebbe essere necessario disabilitare il \"Controllo ortografico\" del browser.
(strumenti/preferenze/avanzate/controllo ortografico)

'); } function buildMenu($node) { if ($node.is("span")) { var spanId = $node.attr('id').replace('word_', ''); var invalidWord = $node.text(); var isForced = $node.attr('data-type-isForced'); var isCorrect = $node.attr('data-type-isCorrect'); var iframeContents = $("#areaText").prev().find("iframe").contents(); var errorLevel = $node.attr('data-type-errorLevel'); var contextErrorLevel = $node.attr('data-type-contexterrorLevel'); var segmentsErrorLevel = $node.attr('data-type-segmentserrorLevel'); var suggestions = $node.attr('data-type-suggestionsLoaded'); var isStartSentencedWord = $node.attr('data-type-isstartsentenceword'); if ($('#crtMn_' + spanId).length == 0) createContextMenuForErrors(spanId, suggestions, invalidWord, isForced, errorLevel, contextErrorLevel, segmentsErrorLevel, false, isCorrect, isStartSentencedWord, iframeContents); } } function buildTextArea() { setTimeout(function () { $('iframe').contents().find('body').css('padding', '3px 5px'); }, 0); var $textArea = $('