Opened 14 years ago

Closed 14 years ago

#381 closed defect (fixed)

Two Bug Fixes

Reported by: loren35 at gottahavejesus dot com Owned by: gogo
Priority: high Milestone:
Component: Plugin_SpellChecker Version: trunk
Severity: major Keywords: spell checker
Cc:

Description

Here are two bugs and fixes for the spell checker:
spell-check-logic.php Line 139 is

}

The surrounding text of Line 139 is: (Line 139 is the 5th line down.)

     {
       // This one isnt used for anything at the moment!
       $return = 'failed to open!';
     }
}
$infolines .= '"Language Used":"'.$lang.'",';
$infolines .= '"Mispelled words":"'.$counter.'",';
$infolines .= '"Total words suggested":"'.$suggest_count.'",';
$infolines .= '"Total Lines Checked":"'.$returnlines.'"';

Line 139 should read:

} else { $returnlines=0; }

Without defining $returnlines as 0 it is left undefinded causing an error (when using the highest error checking).

The other bug is in spell-check-ui.js
Finishspellchecking() should look like this: (note: I copied to the end of the javascript file so there may be extra '}'s and '};'s at the end of the function)

function finishedSpellChecking() {
  // initialization of global variables
  currentElement = null;
  wrongWords = null;
  allWords = {};
  fixedWords = [];
  suggested_words = frame.contentWindow.suggested_words;

  document.getElementById("status").innerHTML = "HTMLArea Spell Checker (<a href='readme-tech.html' target='_blank' title='Technical information'>info</a>)";
  var doc = frame.contentWindow.document;
        var spans = doc.getElementsByTagName("span");
        var sps = [];
  var id = 0;
        for (var i = 0; i < spans.length; ++i) {
                var el = spans[i];
                if (/HA-spellcheck-error/.test(el.className)) {
                        sps.push(el);
      el.__msh_wordClicked = wordClicked;
      el.onclick = function(ev) {
        ev || (ev = window.event);
        ev && HTMLArea._stopEvent(ev);
        return this.__msh_wordClicked(false);
      };
      el.onmouseover = wordMouseOver;
      el.onmouseout = wordMouseOut;
      el.__msh_id = id++;
      var txt = (el.__msh_origWord = el.firstChild.data);
      el.__msh_fixed = false;
      if (typeof allWords[txt] == "undefined") {
        allWords[txt] = [el];
      } else {
        allWords[txt].push(el);
      }
                } else if (/HA-spellcheck-fixed/.test(el.className)) {
      fixedWords.push(el);
    }
        }
  var dicts = doc.getElementById("HA-spellcheck-dictionaries");
  if (dicts) {
    dicts.parentNode.removeChild(dicts);
    dicts = dicts.innerHTML.split(/,/);
    var select = document.getElementById("v_dictionaries");
    for (var i = select.length; --i >= 0;) {
      select.remove(i);
    }
    var activeDictionary = document.getElementById("f_dictionary").value;
    for (var i = 0; i < dicts.length; ++i) {
      var txt = dicts[i];
      var option = document.createElement("option");
      if(txt == activeDictionary) {
        option.selected = true;
      }
      option.value = txt;
      option.appendChild(document.createTextNode(txt));
      select.appendChild(option);
    }
  }
  wrongWords = sps;
  if (sps.length == 0) {
    if (!modified) {
      alert(_lc("No mispelled words found with the selected dictionary."));
      // window.close();
    } else {
      alert(_lc("No mispelled words found with the selected dictionary."));
    }
    return false;
  }
  (currentElement = sps[0]).__msh_wordClicked(true);
  var as = doc.getElementsByTagName("a");
  for (var i = as.length; --i >= 0;) {
    var a = as[i];
    a.onclick = function() {
      if (confirm(_lc("Please confirm that you want to open this link") + ":\n" +
            this.href + "\n" + _lc("I will open it in a new page."))) {
        window.open(this.href);
      }
      return false;
    };
  }
};

I have moved

  var dicts = doc.getElementById("HA-spellcheck-dictionaries");
  if (dicts) {
    dicts.parentNode.removeChild(dicts);
    dicts = dicts.innerHTML.split(/,/);
    var select = document.getElementById("v_dictionaries");
    for (var i = select.length; --i >= 0;) {
      select.remove(i);
    }
    var activeDictionary = document.getElementById("f_dictionary").value;
    for (var i = 0; i < dicts.length; ++i) {
      var txt = dicts[i];
      var option = document.createElement("option");
      if(txt == activeDictionary) {
        option.selected = true;
      }
      option.value = txt;
      option.appendChild(document.createTextNode(txt));
      select.appendChild(option);
    }
  }

up futher because otherwise when no words are found wrong if the dictionary is run multiple times it will leave some extra divs with the dictionary name in it when it posts the text back to the editor.

If this doesn't make since or you have any questions about it feel free to email me. (My email is the the username area.)

Change History (1)

comment:1 Changed 14 years ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

Applied in changeset:273

Note: See TracTickets for help on using tickets.