Jump to content

Special character editor


tomjerry

Recommended Posts

<!DOCTYPE html>
<html>
<head>
    <style>
        .popup {
            position: absolute;
            left: 100px;
            top: 100px;
            border: 1px solid #000;
            background-color: #f0f0f0;
        }

        .popup .symbol {
            display: inline-block;
            padding: 5px;
            margin: 10px;
            border: 1px solid #000;
        }
    </style>
    <script>
        var symbolPopup = null;
        function CreateSymbolPopup () {
            if (symbolPopup) {
                return;
            }

            symbolPopup = document.createElement ('div');
            symbolPopup.className = "popup";

            var symbols = [8719, 8721, 8730];
            for (var i = 0; i < symbols.length; i++) {
                var symbolButton = document.createElement ('span');
                symbolButton.innerHTML = '' + symbols[i] + ';';
                symbolButton.onclick = AddSymbol;
                symbolButton.className = "symbol";
                symbolPopup.appendChild (symbolButton);
            }
            document.body.appendChild (symbolPopup);
        }

        function ShowSymbols () {
            CreateSymbolPopup ();
            symbolPopup.style.display = "";
        }
        function HideSymbols () {
            if (symbolPopup) {
                symbolPopup.style.display = "none";
            }
        }

        function AddSymbol () {
            var editor = document.getElementById ('editor');
            editor.value += this.innerHTML;
            HideSymbols ();
        }
    </script>
</head>
<body>
    <button onclick="ShowSymbols ()">Symbols</button>
    <textarea id="editor"></textarea>
</body>
</html>

The above is my code. By clicking the symbol button,the editor is opening. It is fine. But i also want to do like again by clicking the same button the editor should hide. Please tell me how to do that. No the editor is hiding by selecting the symbol from that editor.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.