- Timestamp:
- 04/12/10 10:27:29 (14 years ago)
- Location:
- sandbox/expressoMail1_2/corretor_ortografico/spell_checker
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js
r2430 r2477 43 43 var positionEditor; 44 44 var areaEditor; 45 var abaEditor; 45 var abaEditor; 46 var blockSpellCheck = false; 46 47 cp = new cpaint(); 47 48 cp.set_transfer_mode('post'); 48 49 cp.set_response_type('text'); 49 function beginSpellCheck(position, area, aba){ 50 51 50 function beginSpellCheck(){ 51 if(!blockSpellCheck){ 52 position = "body_position_" + currentTab; 53 area = "body_" + currentTab; 54 aba = currentTab; 52 55 //var cp = new cpaint(); 53 56 // alert("Seta globals"); … … 109 112 //window.onload =new setupSpellCheckers(); 110 113 //alert("Fim"); 114 } else { 115 alert("O corretor ja esta rodando.") 116 } 111 117 } // fecha funᅵᅵo 112 118 … … 140 146 141 147 }; // end setInit 148 149 function setupSpellChecker(){ 150 151 152 currObj = this; 153 154 currObj.config = new Array(); 155 156 currObj.config['divId'] = "body_position_" + currentTab; 157 currObj.config['width'] = "99%"; 158 currObj.config['id'] = "body_" + currentTab; 159 160 spellContainer = document.createElement('DIV'); 161 spellContainer.id = currObj.config['divId']; 162 spellContainer.className = 'spell_container'; 163 spellContainer.style.width = currObj.config['width']; 164 165 oldElement = document.getElementById(currObj.config['id']); 166 167 //oldElement.parentNode.replaceChild(spellContainer, oldElement); 168 169 //generate the div to hold the spell checker controls 170 currObj.controlPanelDiv = document.createElement('DIV'); 171 currObj.controlPanelDiv.className = 'control_panel'; 172 currObj.controlPanelDiv.id = 'control_panel_' + currentTab; 173 document.getElementById(currObj.config['divId']).appendChild(currObj.controlPanelDiv); 174 175 //the span that toggles between spell checking and editing 176 currObj.actionSpan = document.createElement('SPAN'); 177 currObj.actionSpan.className = "action"; 178 currObj.actionSpan.id = "action"; 179 /*if(currObj.config['useIcons']) 180 { 181 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia \" border=\"0\" /></a>"; 182 } 183 else 184 { 185 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>"; 186 }*/ 187 currObj.controlPanelDiv.appendChild(currObj.actionSpan); 188 189 //the span that lets the user know of the status of the spell checker 190 currObj.statusSpan = document.createElement('SPAN'); 191 currObj.statusSpan.className = "status"; 192 currObj.statusSpan.id = "status"; 193 currObj.statusSpan.innerHTML = ""; 194 currObj.controlPanelDiv.style.display = "none"; 195 currObj.controlPanelDiv.appendChild(currObj.statusSpan); 196 197 //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox")); 198 //the textarea to be spell checked 199 //oldElement.value = currObj.config['value']; 200 //document.getElementById(currObj.config['divId']).appendChild(oldElement); 201 currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); 202 203 } 142 204 143 205 … … 161 223 function ajaxSpell(varName, width, height, spellUrl, divId, name, id, title, value) 162 224 { 163 164 225 226 currObj = this; 165 227 166 228 currObj.config = new Array(); //the array of configuration options … … 185 247 } 186 248 187 spellContainer = document.createElement('DIV');249 /*spellContainer = document.createElement('DIV'); 188 250 spellContainer.id = currObj.config['divId']; 189 251 spellContainer.className = 'spell_container'; … … 192 254 oldElement = document.getElementById(currObj.config['id']); 193 255 194 oldElement.parentNode.replaceChild(spellContainer, oldElement);256 //oldElement.parentNode.replaceChild(spellContainer, oldElement); 195 257 196 258 //generate the div to hold the spell checker controls … … 203 265 currObj.actionSpan.className = "action"; 204 266 currObj.actionSpan.id = "action"; 205 if(currObj.config['useIcons'])267 /*if(currObj.config['useIcons']) 206 268 { 207 269 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia \" border=\"0\" /></a>"; … … 210 272 { 211 273 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>"; 212 } 213 currObj.controlPanelDiv.appendChild(currObj.actionSpan);274 }*/ 275 /*currObj.controlPanelDiv.appendChild(currObj.actionSpan); 214 276 215 277 //the span that lets the user know of the status of the spell checker … … 219 281 currObj.statusSpan.innerHTML = ""; 220 282 currObj.controlPanelDiv.appendChild(currObj.statusSpan); 221 283 284 //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox")); 222 285 //the textarea to be spell checked 223 286 oldElement.value = currObj.config['value']; 224 document.getElementById(currObj.config['divId']).appendChild(oldElement); 225 226 287 //document.getElementById(currObj.config['divId']).appendChild(oldElement); 288 currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); 289 */ 290 291 currObj.controlPanelDiv = document.getElementById('control_panel_' + currentTab); 292 currObj.statusSpan = currObj.controlPanelDiv.childNodes[1]; 293 currObj.actionSpan = currObj.controlPanelDiv.childNodes[0] ; 294 227 295 currObj.objToCheck = document.getElementById(currObj.config['id']); //the actual object we're spell checking 228 296 currObj.spellingResultsDiv = null; // Auto-generated results div … … 276 344 function spellCheck_cb(new_data) 277 345 { 278 with(currObj); 346 347 with(currObj); 279 348 new_data = new_data.toString(); 280 349 var isThereAMisspelling = new_data.charAt(0); … … 295 364 296 365 currObj.objToCheck.style.display = "none"; 297 currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv,currObj.objToCheck); 366 //currObj.objToCheck.parentNode. 367 //currObj.objToCheck.parentNode.appendChild(currObj.spellingResultsDiv,currObj.objToCheck); 368 currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); 298 369 currObj.statusSpan.innerHTML = ""; 299 370 … … 320 391 currObj.objToCheck.disabled = false; 321 392 } 393 394 currObj.controlPanelDiv.style.display = "block"; 395 322 396 }; // end spellCheck_cb 323 397 … … 332 406 *************************************************************/ 333 407 function spellCheck() { 334 with(currObj); 335 var query; 336 337 if(currObj.spellingResultsDiv) 338 { 339 currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv); 340 currObj.spellingResultsDiv = null; 341 } 342 343 if(currObj.config['useIcons']) 344 { 345 currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />"; 346 } 347 else 348 { 349 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>"; 350 } 351 352 if(currObj.config['useIcons']) 353 { 354 currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />"; 355 } 356 else 357 { 358 currObj.statusSpan.innerHTML = "Verificando Ortografia..."; 359 } 360 361 362 // Obtain the HTML content from iframe (edit area) 363 var ifr= currObj.objToCheck; 364 if(ifr.contentWindow) 365 ifr=ifr.contentWindow.document; 366 else 367 ifr=ifr.contentDocument; 368 var texto = ifr.body.innerHTML; 369 370 371 query = texto; 372 //query = currObj.objToCheck.value; 373 374 //query = query.replace(/\r?\n/gi, "<br />"); // Commented from the original by Nathalie 375 query = query.replace(/\r?\n/gi, " "); // replace \n with " " - By Nathalie 376 377 378 cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName']); 408 409 if(!blockSpellCheck) { 410 blockSpellCheck = true; 411 412 language = document.getElementById("selectLanguage"); 413 language = language[document.getElementById("selectLanguage").selectedIndex].value; 414 415 with(currObj); 416 var query; 417 418 currObj.controlPanelDiv.style.display = "block"; 419 420 if(currObj.spellingResultsDiv) 421 { 422 currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv); 423 currObj.spellingResultsDiv = null; 424 } 425 426 /*if(currObj.config['useIcons']) 427 { 428 currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />"; 429 } 430 else 431 { 432 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>"; 433 }*/ 434 435 /*if(currObj.config['useIcons']) 436 { 437 currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />"; 438 } 439 else 440 { 441 currObj.statusSpan.innerHTML = "Verificando Ortografia..."; 442 }*/ 443 444 // Obtain the HTML content from iframe (edit area) 445 var ifr= currObj.objToCheck; 446 if(ifr.contentWindow) 447 ifr=ifr.contentWindow.document; 448 else 449 ifr=ifr.contentDocument; 450 var texto = ifr.body.innerHTML; 451 452 query = texto; 453 //query = currObj.objToCheck.value; 454 455 //query = query.replace(/\r?\n/gi, "<br />"); // Commented from the original by Nathalie 456 query = query.replace(/\r?\n/gi, " "); // replace \n with " " - By Nathalie 457 458 cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], language); 459 } 379 460 }; // end spellcheck 380 461 … … 400 481 spellingSuggestionsDiv = null; 401 482 } 402 483 484 currObj.controlPanelDiv.style.display = "block"; 485 403 486 if(currObj.config['useIcons']) 404 487 { … … 595 678 function showSuggestions(word, id) 596 679 { 597 680 language = document.getElementById("selectLanguage"); 681 language = language[document.getElementById("selectLanguage").selectedIndex].value; 682 598 683 with(currObj); 599 684 if(currObj.config['useIcons']) … … 633 718 document.body.appendChild(spellingSuggestionsDiv); 634 719 635 cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id );720 cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id, language); 636 721 }; // end showSuggestions 637 722 … … 682 767 683 768 with(currObj); 684 685 769 //By Nathalie - The Element means that this div belongs to the current tab 686 770 var parentElement = Element(currObj.spellingResultsDiv.id); 687 688 771 // Obtain all span tags which have highlight className or corrected_word className 689 772 var nodeArray = parentElement.getElementsByTagName("span"); … … 691 774 var nodeRemove = new Array(totArray); 692 775 var j = -1; 776 693 777 for (var i = 0 ; i < totArray ; i++) { 694 778 var node = nodeArray[i]; … … 708 792 parent.replaceChild(fake, document.getElementById(nodeRemove[i])); 709 793 } 710 var text = currObj.spellingResultsDiv.innerHTML; 794 795 var text = currObj.spellingResultsDiv.innerHTML; 711 796 712 797 text = text.replace(/ /gi, " %u2026 "); // Replace with the code %u2026 713 798 text = '*' + text; 799 714 800 cp.call(currObj.config['spellUrl'], 'switchText', switchText_cb, text); 715 801 … … 730 816 function switchText_cb(new_string) 731 817 { 732 818 733 819 with(currObj); 734 820 … … 775 861 776 862 with(currObj); 863 864 currObj.controlPanelDiv.style.display = "block"; 777 865 if(currObj.config['useIcons']) 778 866 { … … 812 900 function resetAction() 813 901 { 814 815 902 with(currObj); 816 if(currObj.config['useIcons'])903 /*if(currObj.config['useIcons']) 817 904 { 818 905 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" /></a>"; … … 821 908 { 822 909 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>"; 823 } 824 910 }*/ 911 912 currObj.actionSpan.innerHTML = ""; 825 913 currObj.statusSpan.innerHTML = ""; 914 currObj.controlPanelDiv.style.display = "none"; 915 blockSpellCheck = false; 826 916 }; // end resetAction 827 917 -
sandbox/expressoMail1_2/corretor_ortografico/spell_checker/spell_checker.php
r2430 r2477 75 75 76 76 //$pspell_link = pspell_new_config($pspell_config); 77 $pspell_link = pspell_new("pt_BR"); 77 78 78 79 79 require_once("cpaint/cpaint2.inc.php"); //AJAX library file … … 98 98 * 99 99 *************************************************************/ 100 function showSuggestions($word, $id )100 function showSuggestions($word, $id, $language) 101 101 { 102 102 global $editablePersonalDict; //bool to set editability of personal dictionary 103 global $pspell_link; //the global link to the pspell module 103 //global $pspell_link; //the global link to the pspell module 104 $pspell_link = pspell_new($language); 104 105 global $cp; //the CPAINT object 105 106 … … 160 161 * 161 162 *************************************************************/ 162 function spellCheck($string, $varName) 163 { 164 global $pspell_link; //the global link to the pspell module 163 function spellCheck($string, $varName, $language) 164 { 165 //global $pspell_link; //the global link to the pspell module 166 $pspell_link = pspell_new($language); 165 167 global $cp; //the CPAINT object 166 168 $retVal = ""; … … 287 289 { 288 290 global $editablePersonalDict; 289 global $pspell_link; //the global link to the pspell module 291 //global $pspell_link; //the global link to the pspell module 292 $pspell_link = pspell_new("pt_BR"); 290 293 global $cp; //the CPAINT object 291 294 $retVal = "";
Note: See TracChangeset
for help on using the changeset viewer.