forked from usablica/persian.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
persian.min.js
8 lines (8 loc) · 2.48 KB
/
persian.min.js
1
2
3
4
5
6
7
8
/**
* PersianJs v0.3.0
* https://github.com/usablica/persian.js
* MIT licensed
*
* Copyright (C) 2012 usabli.ca and other contributors
*/
!function(){function t(t){this._str=t}function r(t){if(t){for(var r=["ي","ك","","دِ","بِ","زِ","ذِ","ِشِ","ِسِ","","ى"],n=["ی","ک","","د","ب","ز","ذ","ش","س","","ی"],e=0,i=r.length;i>e;e++)t=t.replace(new RegExp(r[e],"g"),n[e]);return this._str=t,this}}function n(t){if(t){for(var r=["ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ","ظ","ط","ز","ر","ذ","د","پ","و","؟"],n=["q","w","e","r","t","y","u","i","o","p","[","]","a","s","d","f","g","h","j","k","l",";","'","z","x","c","v","b","n","m",",","?"],e=0,i=r.length;i>e;e++)t=t.replace(new RegExp(r[e],"g"),n[e]);return this._str=t,this}}function e(t){if(t){for(var r=["١","٢","٣","٤","٥","٦","٧","٨","٩","٠"],n=["۱","۲","۳","۴","۵","۶","۷","۸","۹","۰"],e=0,i=r.length;i>e;e++)t=t.replace(new RegExp(r[e],"g"),n[e]);return this._str=t,this}}function i(t){if(t){for(var r=["1","2","3","4","5","6","7","8","9","0"],n=["۱","۲","۳","۴","۵","۶","۷","۸","۹","۰"],e=0,i=r.length;i>e;e++)t=t.replace(new RegExp(r[e],"g"),n[e]);return this._str=t,this}}function s(t){if(t){for(var r="";r!=t;)r=t,t=t.replace(/(http\S+?)\%20/g,"$1_");return t=t.replace(/(http\S+)/g,function(t,r){return decodeURI(r)}),t=t.replace(/\u200c\u200c\u200c_\u200c\u200c\u200c/g,"%20"),this._str=t,this}}function u(t){if(t){for(var r=["می "," ها","ه ای ","ه ی "],n=["می","ها","های ","هی "],e=0,i=r.length;i>e;e++)t=t.replace(new RegExp(r[e],"g"),n[e]);return this._str=t,this}}var c="0.3.0",o="undefined"!=typeof module&&module.exports,f=function(r){if(!r||""===r)throw new Error("Input is null or empty.");return new t(r)};f.version=c,f.fn=t.prototype={clone:function(){return f(this)},value:function(){return this._str},toString:function(){return this._str.toString()},set:function(t){return this._str=String(t),this},arabicChar:function(){return r.call(this,this._str)},arabicNumber:function(){return e.call(this,this._str)},fixURL:function(){return s.call(this,this._str)},englishNumber:function(){return i.call(this,this._str)},switchKey:function(){return n.call(this,this._str)},fixZeroWidth:function(){return u.call(this,this._str)}},o&&(module.exports=f),"undefined"==typeof ender&&(this.persianJs=f),"function"==typeof define&&define.amd&&define("persianJs",[],function(){return f})}();