Changeset 2404


Ignore:
Timestamp:
04/01/10 15:38:01 (14 years ago)
Author:
nathalie.silva
Message:

Ticket #891 - Correção de problemas quando utiliza HTML - aceita todas as tags. Nathalie

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js

    r2376 r2404  
    120120        var ifr = document.getElementsByTagName('iframe')[0]; 
    121121        var numSpellCheckers = 0; 
    122         var tempSpellCheckers = Array(); 
    123       //  alert("NOT OK"); 
    124  
    125          //novo 
    126          //if (textareas){ 
     122        //var tempSpellCheckers = Array(); 
     123                 
    127124        if(ifr.contentWindow) 
    128125           ifr=ifr.contentWindow.document; 
    129126        else 
    130127           ifr=ifr.contentDocument; 
    131        //  alert(ifr.body.innerHTML); 
    132          var texto = ifr.body.innerHTML; 
     128        var texto = ifr.body.innerHTML; 
    133129 
    134130       //  alert("valor textarea"); 
     
    376372         
    377373         
    378         //Adicionado por Nathalie 
     374        // Obtain the HTML content from iframe (edit area) 
    379375         var ifr= currObj.objToCheck; 
    380376         if(ifr.contentWindow) 
     
    382378         else 
    383379            ifr=ifr.contentDocument; 
    384             alert(ifr.body.innerHTML); 
    385  
    386380         var texto = ifr.body.innerHTML; 
    387381         
     
    695689{ 
    696690        with(currObj); 
     691        var parentElement = currObj.spellingResultsDiv; 
     692 
     693        // Obtain all span tags which have highlight className or corrected_word className 
     694        var nodeArray = parentElement.getElementsByTagName("span"); 
     695        var totArray = nodeArray.length; 
     696        var nodeRemove = new Array(totArray); 
     697        var j = -1; 
     698        for (var i = 0 ; i < totArray ; i++) { 
     699            var node = nodeArray[i]; 
     700            if (node.className == "highlight" || node.className == "corrected_word") { 
     701                j++; 
     702                nodeRemove[j] = node.id; 
     703                 
     704                 
     705            } 
     706        } 
     707 
     708        //Remove span tags which have highlight className or corrected_word className 
     709        for (var i = 0 ; i <= j ; i++) { 
     710            var valorNo = document.getElementById(nodeRemove[i]).innerHTML; 
     711            var fake = document.createTextNode(valorNo); 
     712            var parent =  document.getElementById(nodeRemove[i]).parentNode; 
     713            parent.replaceChild(fake, document.getElementById(nodeRemove[i]));             
     714        } 
    697715        var text = currObj.spellingResultsDiv.innerHTML; 
    698         text = text.replace(/<br *\/?>/gi, "~~~"); 
    699         // Work around a cpaint/safari bug by prefixing an asterisk to the text so that the text is never completely empty 
    700         text = '*' + text; 
    701         cp.call(currObj.config['spellUrl'], 'switchText', switchText_cb, text); 
     716 
     717        text = text.replace(/&nbsp;/gi, " %u2026 "); // Replace &nbsp; with the code %u2026 
     718        text = '*' + text; 
     719        cp.call(currObj.config['spellUrl'], 'switchText', switchText_cb, text); 
     720         
    702721}; // end switchText 
    703722 
     
    717736{ 
    718737        with(currObj); 
     738         
     739        new_string = new_string.replace(/ %u2026/gi, "&nbsp;"); // Replace the code %u2026 with &nbsp; 
     740              
    719741        new_string = new_string.replace(/~~~/gi, "\n"); 
    720  
     742        
    721743        // Remove the prefixed asterisk that was added in switchText(). 
    722744        new_string = new_string.substr(1); 
     745 
     746 
    723747        currObj.objToCheck.style.display = "none"; 
    724748         var ifr= currObj.objToCheck; 
     
    727751         else 
    728752            ifr=ifr.contentDocument; 
    729             alert(ifr.body.innerHTML); 
    730753         var texto = ifr.body.innerHTML; 
     754      
    731755         ifr.body.innerHTML = new_string; 
    732756        currObj.objToCheck.disabled = false; 
     
    769793                currObj.statusSpan.innerHTML = "Working..."; 
    770794        } 
     795        
    771796         
    772797        if(spellingSuggestionsDiv) 
    773798        { 
    774                 spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv); 
     799                 
     800                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv); 
    775801                spellingSuggestionsDiv = null; 
    776802        } 
Note: See TracChangeset for help on using the changeset viewer.