-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquran-citer.js
128 lines (106 loc) · 4.13 KB
/
quran-citer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var qrnCiter = (function (style) {
var res = {};
function closeDiv() {
var div = document.getElementById('light');
div.style.display = 'none';
document.getElementById('fade').style.display = 'none';
div.innerHTML = '';
document.body.style.overflow = 'auto';
}
function putScriptInIframes(sid, aid, eid) {
var scriptUrl = 'http://www.recitequran.com/embed.php?ColorText=1&wpx=560&Translations=VRussian&Ch=' + sid + '&SV=' + aid + '&EV=' + (eid || aid);
var frame = document.createElement('iframe');
var html = '<style>body > div{width:100% !important;border-right:10px !important;}</style><body style="margin:0px;padding:0px;"><script src="' + scriptUrl + '" ><\/script></body>';
frame.id = "qframe";
frame.src = 'data:text/html;charset=utf-8,' + encodeURI(html);
frame.width = "100%";
frame.height = "100%";
frame.padding = 0;
frame.border = 0;
frame.style = "overflow:hidden;height:100%;width:100%";
frame.setAttribute('frameborder', 0);
var div = document.getElementById("light");
div.appendChild(frame);
document.getElementById('light').style.display = 'block';
document.getElementById('fade').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function scanLinks() {
var
linkFormats = {
"kc": ["https://www.koran.center/", "#", ""],
"rq": ["http://www.recitequran.com/", ":", ""],
"rqru": ["http://www.recitequran.com/ru/", ":", ""],
"rqaz": ["http://www.recitequran.com/az/", ":", ""],
"rqs": [null, "", ""],
"tanzil": ["http://tanzil.net/#", ":", ""],
"quran": ["http://quran.com/", "?", ""],
"qi": ["http://al-quran.info/#", ":", ""],
"qf": ["http://www.quranflash.com/verse/", "/", ""],
"quraz1": ["http://quran.az/5", "/", "/t:3"],
"quraz2": ["http://quran.az/5", "/", "/t:2"],
"quraz3": ["http://quran.az/5", "/", "/t:3"],
},
x = document.getElementsByClassName("qrn"),
i = 0;
for (i = 0; i < x.length; i++) {
var y = x[i];
//y.style.backgroundColor = "yellow";
var links = y.getElementsByTagName("a"),
linkFormat = linkFormats[y.getAttribute("data-qlink") || style];
if (links.length > 0) {
var link = links[links.length - 1];
var nums = link.text.match(/\d+/g);
if (linkFormat[0]) {
link.href = linkFormat[0] + nums[0] + linkFormat[1] + nums[1] + linkFormat[2];
link.target = "_blank";
y.cite = link.href;
} else {
link.href = "javascript:void(0)";
var sid = nums[0],
aid = nums[1],
eid = nums.length > 2 ? nums[2] : nums[1];
link.onclick = putScriptInIframes.bind(this, sid, aid, eid);
// link.href = 'http://www.recitequran.com/embed.php?ColorText=1&wpx=560&Translations=VRussian&Ch=' + sid + '&SV=' + aid + '&EV=' + (eid || aid);
// link.classList.add("qrciter-popup-link");
}
}
}
}
function createDivs() {
var div1 = document.createElement('div');
div1.id = "light";
div1.className = "white_content";
document.body.appendChild(div1);
var div2 = document.createElement('div');
div2.id = "fade";
div2.className = "black_overlay";
div2.onclick = closeDiv;
document.body.appendChild(div2);
var divhtml = '<div id="light" class="white_content"><a href = "javascript:void(0)" onclick = "closeDiv()"></a></div><div id="fade" class="black_overlay" onclick = "closeDiv()"></div>';
var closeBtn = document.createElement('a');
closeBtn.innerHTML = '×';
closeBtn.className = 'qframe-close-btn';
closeBtn.setAttribute('href', '#');
closeBtn.addEventListener('click', closeDiv);
div2.appendChild(closeBtn);
}
/*function callMe(){
console.log(this);
return "hello";
}*/
res.initialise = function () {
/* $(document).ready(function() {
console.log("LA ILAHE ILLELLAH");
$('.qrciter-popup-link').magnificPopup({
type: 'inline',
src: '<div>HTML string</div>'
});
});
*/
scanLinks();
createDivs();
}
res.initialise();
return res;
}("kc"))