Skip to content

Commit f02f9c8

Browse files
authored
Update FixLanguageType.js
1 parent 7acd6c9 commit f02f9c8

1 file changed

Lines changed: 133 additions & 0 deletions

File tree

FixLanguageType.js

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,136 @@
88
* @Repository : https://github.com/BaseMax/FixLanguageTypeJs
99
*
1010
**/
11+
;(function(window,document)
12+
{
13+
"use strict";
14+
/**
15+
* @function keymap
16+
*
17+
* @goal : Keymap of en , fa
18+
*
19+
* @return array (key=en , value=fa)
20+
**/
21+
var keymap=
22+
{
23+
'q':"ض",
24+
'w':"ص",
25+
'e':"ث",
26+
'r':"ق",
27+
't':"ف",
28+
'y':"غ",
29+
'u':"ع",
30+
'i':"ه",
31+
'o':"خ",
32+
'p':"ح",
33+
'[':"ج",
34+
']':"چ",
35+
'a':"ش",
36+
's':"س",
37+
'd':"ی",
38+
'f':"ب",
39+
'g':"ل",
40+
'h':"ا",
41+
'j':"ت",
42+
'k':"ن",
43+
'l':"م",
44+
';':"ک",
45+
'\'':"گ",
46+
'z':"ظ",
47+
'x':"ط",
48+
'c':"ز",
49+
'v':"ر",
50+
'b':"ذ",
51+
'n':"د",
52+
'm':"پ",
53+
',':"و",
54+
};
55+
/**
56+
* @function replaceAll
57+
*
58+
* @goal : Replace All
59+
*
60+
* @return string
61+
**/
62+
var replaceAll = function(input,str1, str2, ignore)
63+
{
64+
return input.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g,"\\$&"),(ignore?"gi":"g")),(typeof(str2)=="string")?str2.replace(/\$/g,"$$$$"):str2);
65+
}
66+
/**
67+
* @function en_fa
68+
*
69+
* @goal : Change `en` character to `fa` character in self keymap!
70+
*
71+
* @return void
72+
**/
73+
var en_fa=function(value)
74+
{
75+
var keys=Object.keys(keymap);
76+
var values=Object.values(keymap);
77+
for(var i=0;i<keys.length;i++)
78+
value=replaceAll(value,keys[i],values[i]);
79+
return value;
80+
};
81+
/**
82+
* @function fa_en
83+
*
84+
* @goal : Change `fa` character to `en` character in self keymap!
85+
*
86+
* @return void
87+
**/
88+
var fa_en=function(value)
89+
{
90+
var keys=Object.values(keymap);
91+
var values=Object.keys(keymap);
92+
for(var i=0;i<keys.length;i++)
93+
value=replaceAll(value,keys[i],values[i]);
94+
return value;
95+
};
96+
/**
97+
* @struct fixtype
98+
*
99+
* @goal : access to public functions
100+
*
101+
* @return struct
102+
**/
103+
window.fixtype=
104+
{
105+
en_fa:en_fa,
106+
fa_en:fa_en,
107+
};
108+
/**
109+
* @struct onload
110+
*
111+
* @goal : set onclick and events after page load...
112+
*
113+
* @return void
114+
**/
115+
window.addEventListener("load",function()
116+
{
117+
var data_goscroll;
118+
data_goscroll = document.querySelectorAll("[data-scroll-go]");
119+
data_goscroll.forEach(function(item)
120+
{
121+
if(item.onclick === null)//onclick not exists
122+
{
123+
item.onclick=function()
124+
{
125+
window.goscroll.go(this);
126+
};
127+
}
128+
});
129+
//////////////////////////////////////////////////////////////////
130+
data_goscroll = document.querySelectorAll("[data-scroll-to]");
131+
data_goscroll.forEach(function(item)
132+
{
133+
if(item.onclick === null)//onclick not exists
134+
{
135+
item.onclick=function()
136+
{
137+
window.goscroll.goto(this);
138+
};
139+
}
140+
});
141+
//////////////////////////////////////////////////////////////////
142+
},false);
143+
}(window,document));

0 commit comments

Comments
 (0)