JSFiddle - React, Tailwind, and code Playground

by Amir Sharifian

HTML

<div class="myGrid">
    <b style="top: 50px;">123456789-10-11-12</b>
    <br />
    <span style="margin: 20px 0 10px 5px">05-10-1390</span>
    <a href="http://blog.jsfiddle.net/" style="left: 20px">our blog</a>
</div>

JavaScript

var numConversion = {'0':'&#1776;', '1':'&#1777;', '2':'&#1778;', '3':'&#1779;', '4':'&#1780;', '5':'&#1781;', '6':'&#1782;', '7':'&#1783;', '8':'&#1784;', '9':'&#1785;'};

$(document).ready(function() {
    var grid = $(".myGrid");

    var gridContent = grid.contents();
    convertText(gridContent);

    function convertText(contents) {
        contents.each(function() {
            if (this.nodeType == 3) {
                this.nodeValue =
                $("<div/>").html(convert(this.nodeValue)).text();
            } else if (this.nodeType == 1) {
                convertText($(this).contents());
            }
        });
    }

    $(".myGrid").html(grid.html());

    function convert(txt) {
        var resultTxt = '';
        var textChar = '';
        for (var i = 0; i < txt.length; i++) {
            textChar = txt.charAt(i);
            if (numConversion.hasOwnProperty(textChar )) {
                resultTxt += numConversion[textChar ];
            } else {
                resultTxt += textChar;
            }
        }

        return resultTxt;
    }
});