Farsi labels for Farsi Ordered Lists!

The javascript code below, can convert English numbered Farsi ordered lists to the correctly labeled ones!

<script type="text/javascript">
 //<![CDATA[
 $(document).ready(function() {
  $("ol").each(function() {
    var i = 1;
    $(this).css("list-style-type","none")
         .children("li").each(function() {
          var label = "";
          var order = i++;
          while(order >= 1)
          {
            label = String.fromCharCode(order % 10 + 0x6F0) + label;
            order /= 10;
          }
          if(label == "")
            label = String.fromCharCode(0 + 0x6F0);
          label += ".";
          var li = $(this);
          li.css("padding-right", "0px").css("margin-right", "10px");
          li.html("<span style="display:block; float:right; margin-left:10px;">" + label + "&nbsp</span>" + li.html());
         });
  });
 });
 //]]>
 </script>

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>