-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmodel.html
137 lines (132 loc) · 3.77 KB
/
model.html
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
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="author" content="M A Eyler, Istanbul, 2020" />
<meta name="description" content="Reader for the Quran" />
<link rel="icon" href="image/icon.png">
<title>Kuran Meali </title>
<style>
body { max-width: 440px; }
body, h2, h3 { margin: 20px; }
h2 { margin-bottom: 16px; }
body, input, button {
font: 16px sans-serif;
}
#url { width: 300px; }
#page, #indx { width: 90px; }
button {
background-color: yellow;
}
</style>
</head>
<body>
<h2 id=title></h2>
Bu yazılım ile Kuran-ı Kerim metni yüklenir.
<hr />
<p><label>
URL <br>
<input type=text id=url placeholder='https://...'>
<button id=urlB>Oku</button>
</p>
<p><label>
İndeks <br>
<input type=number id=indx placeholder='1-6236' value=5621>
<button id=indxB>Ayet</button>
<button id=rootB hidden>Kökler</button>
</p>
<p><label>
Sayfa <br>
<input type=number id=page placeholder='1-604'>
<button id=pageB>Sayfa</button>
</p>
<hr />
<p id=sayfa></p>
<textarea id=out rows=20 cols=60 hidden></textarea>
<script src="code/buckwalter.js"></script>
<script src="code/common.js"></script>
<script src="code/model.js"></script>
<script src="code/utilities.js"></script>
<script>
"use strict";
function report(t) {
sayfa.textContent = t; console.log(t)
}
function doText(u = url.value, callback) {
kur = new KuranText(u, callback)
url.value = u
}
function doIndex(i = indx.value) {
report(kur.getVerse(i))
indx.value = i
}
function doPage(p = Number(page.value)) {
sayfa.innerHTML = kur.pageToHTML(p)
console.log(p+'. sayfa')
page.value = p
}
/**
* bundan sonrası data/simi.txt fazlalıkları silmek için -- Feb 2021
* */
function word2charCode(w) {
let c = [];
for (let i=0; i<w.length; i++) c.push(w.charCodeAt(i))
return c
}
function index2roots(i) {
let a = kur.data[i].trim().split(' ')
// console.log(a.filter(x => MD._word2Root.get(toBuckwalter(x))))
// ["تَشَآءُونَ", "يَشَآءَ", "ٱللَّهُ", "ٱللَّهَ", "كَانَ", "عَلِيمًا", "حَكِيمًا"]
let s = new Set()
for (let w of a) {
let b = MD._word2Root.get(toBuckwalter(w))
if (b) s.add(b)
}
return [...s]
}
// console.log(word2charCode(a[a.length-1])) //last word
// [1581, 1614, 1603, 1616, 1610, 1605, 1611, 1575]
function doRoot(i = indx.value) {
report(index2roots(i))
}
function accepted(cv) {
let c = count[cv]
if (!c) c = count[cv] = index2roots(cvToIndex(cv)).length
return c>1
}
// const acc = [], rej = [], count = {}
async function readSimi() {
console.log(kur)
let r = await fetch('data/simi.txt') //response
let t = await r.text() //text
let a = t.split('\n')
console.log('SimData', a.length+' lines')
for (let w of a) {
let [cv, ...rest] = w.trim().split(' ')
let b = rest.filter(accepted)
if (accepted(cv) && b.length>0)
acc.push([cv].concat(b).join(' '))
else rej.push(w)
}
console.log('Accept: '+acc.length, 'Reject: '+rej.length)
}
function display(a) {
out.value = a.join('\n')
}
/* */
var kur //assigned in doText()
// const MD = new MujamData('data/words.txt')
title.innerText = document.title
// Event e is not used in the listeners
urlB.onclick = (e) => doText()
indx.onchange = (e) => doIndex()
indxB.onclick = (e) => doIndex()
rootB.onclick = (e) => doRoot()
page.onchange = (e) => doPage()
pageB.onclick = (e) => doPage()
doText('tr.yazir.txt') //read data
// doText('quran-uthmani.txt', readSimi)
</script>
</body>
</html>