• I love your feature via quicktags.js for looking up a word in a seperate window, but why stop there?

    Adding a couple of quick lines in the .js and you’re able to look up a word via the Thesaurus as well, not just the dictionary. Not only that, but you’re heading to virtually the same site to get the info and so the syntax is the same, so why not?

    Maybe a quick hack, if nothing else…..

    In quicktags.js, underneath:

    function edSpell(myField) {
    var word = "";
    if (document.selection) {
    myField.focus();
    var sel = document.selection.createRange();
    if (sel.text.length > 0) {
    word = sel.text;
    }
    }
    else if (myField.selectionStart || myField.selectionStart == "0") {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    if (startPos != endPos) {
    word = myField.value.substring(startPos, endPos);
    }
    }
    if (word == "") {
    word = prompt("Enter a word to look up:", "");
    }
    if (word != "") {
    window.open("http://dictionary.reference.com/search?q=" + escape(word));
    }
    }

    add:

    function edThesa (myField) {
    var worrd = "";
    if (document.selection) {
    myField.focus();
    var sel = document.selection.createRange();
    if (sel.text.length > 0) {
    worrd = sel.text;
    }
    }
    else if (myField.selectionStart || myField.selectionStart == "0") {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    if (startPos != endPos) {
    worrd = myField.value.substring(startPos, endPos);
    }
    }
    if (worrd == "") {
    word = prompt("Enter a word to look up:", "");
    }
    if (worrd != "") {
    window.open("http://thesaurus.reference.com/search?q=" + escape(worrd));
    }
    }

    and then toss a line in here:

    function edToolbar() {
    document.write("<div id="ed_toolbar">");
    for (i = 0; i < edButtons.length; i++) {
    edShowButton(edButtons[i], i);
    }
    document.write("<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="Dictionary lookup" value="Dict." />");

    document.write("<input type="button" id="ed_thesa" class="ed_button" onclick="edThesa(edCanvas);" title="Thesaurus lookup" value="Thes." />");

    document.write("<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="Close all open tags" value="Close Tags" />");
    // edShowLinks(); // disabled by default
    document.write("</div>");
    }

    and that’s it….?

  • The topic ‘Quicktag suggestion – adding lookup via thesaurus’ is closed to new replies.