-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_proxy.html
More file actions
256 lines (239 loc) · 7.91 KB
/
test_proxy.html
File metadata and controls
256 lines (239 loc) · 7.91 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html>
<head>
<title>KanJax Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="lib/jquery-2.1.4.min.js"></script>
<script src="lib/jquery.bpopup.min.js"></script>
<script src="lib/jquery.jeditable.mini.js"></script>
<script src="kanjax/kanjax.js"></script>
<style>
body {
text-align: center;
font-size: 12pt;
font-family: Sans;
margin: 0px;
overflow: hidden;
background-color: #f0f6ff;
}
iframe {
display:block;
width: 100%;
margin: 0px;
/*margin-top: 0.5em;*/
height: 100%;
border: none;
border-top: 1px solid black;
}
.rot90 {
-ms-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.cell {
padding: 0px;
align-content: center;
text-align: center;
}
#myaddress3 {
position:relative;
text-align: left;
}
#myaddress2 {
position: absolute;
top: 0;
height: 100%;
}
#myaddress {
margin:0px;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
#myback {
background: url('dynamic_blue_left.png');
background-position:center;
background-size: 25px 25px;
background-repeat:no-repeat;
background-position: 0px 0px;
border: 1px solid gray;
height: 25px; /* make this the size of your image */
width: 25px;
vertical-align: middle; /* align the text vertically centered */
cursor: pointer;
}
#myback[disabled="true"] {
background: url('dynamic_gray_left.png');
background-size: 25px 25px;
cursor: default;
}
.cell input {
margin: auto;
margin-top: 0.2em;
margin-bottom: 0.2em;
}
.cell h2 {
margin-bottom: 0.1em;
}
#showerr {
font-style: italic;
color: red;
}
</style>
<script language="JavaScript" type="text/javascript">
function onResize() {
var el, cont, r, iframe, h;
el = document.getElementById("rot90");
r = el.getBoundingClientRect();
cont = el.parentNode;
$(cont).height(r.height);
$(cont).width(r.width);
$(el).css({top: (r.height-r.width)/2,
left: (-r.height+r.width)/2 });
el = document.getElementById('myaddress');
$(el).width($(el.parentNode.parentNode).width()-10);
iframe = document.getElementById("myiframe");
h = window.innerHeight - $(iframe).offset().top-1;
$(iframe).height(h);
}
$(function() {
//KanJax.basePath = '/~maurizio/kanjax/kanjax/';
KanJax.styleFile = 'kanjax_light.css';
KanJax.setupPopup();
onResize();
$(window).on('resize', onResize);
$("#myaddress").keyup(function(event){
if(event.keyCode == 13)
myGo()
});
});
function setError(e) {
var showerr = document.getElementById("showerr");
showerr.innerText = e ? e.message : "";
}
function myAddInfo() {
var iframe = document.getElementById("myiframe");
var settings = {
kanji_info: 1,
dict: 1,
rubies: 0,
full_reading: 1
}
try {
setError();
KanJax.setupTarget(iframe.contentDocument.body);
KanJax.addInfo(iframe.contentDocument.body, settings);
} catch(e) {
setError(e);
}
}
function myRemoveInfo() {
var iframe = document.getElementById("myiframe");
try {
setError();
KanJax.removeInfo(iframe.contentDocument.body);
} catch(e) {
setError(e);
}
}
myHistory = [];
forceViaProxy = true;
function myFrameLoad() {
var iframe = document.getElementById("myiframe");
var proxypath = window.location.pathname.replace(/test_proxy\.html$/,'') + 'proxy.php';
if(forceViaProxy
&& (iframe.contentWindow.location.origin != window.location.origin
|| iframe.contentWindow.location.pathname != proxypath)) {
var outurl = window.location.origin + proxypath + '?url=';
var inurl = iframe.contentWindow.location.origin;
if(iframe.contentWindow.location.origin == window.location.origin
&& myHistory.length >= 1)
inurl = new URL(myHistory[0]).origin;
inurl += iframe.contentWindow.location.pathname + iframe.contentWindow.location.search;
var url = outurl + encodeURIComponent(inurl) + iframe.contentWindow.location.hash;
iframe.contentWindow.location = url;
return;
}
var params = iframe.contentWindow.location.search;
var url = decodeURIComponent(params.replace(/.*url=/,''));
var address = document.getElementById("myaddress");
address.value = url;
console.log(url);
myHistory.unshift(url);
if(myHistory.length > 1) {
var back = document.getElementById("myback");
back.disabled = false;
}
var autoaddinfo = document.getElementById("autoaddinfo");
if(autoaddinfo.checked)
myAddInfo({kanji_info: 1, dict: 1, rubies: 1});
}
function myGo() {
var iframe = document.getElementById("myiframe");
var address = document.getElementById("myaddress");
iframe.contentWindow.location = "proxy.php?url=" + encodeURIComponent(address.value);
}
function myBack() {
if(myHistory.length <= 1)
return;
myHistory.shift();
var iframe = document.getElementById("myiframe");
iframe.contentWindow.location = "proxy.php?url=" + encodeURIComponent(myHistory[0]);
if(myHistory.length <= 1) {
var back = document.getElementById("myback");
back.disabled = true;
}
}
</script>
</head>
<body>
<table border="0" align="center">
<colgroup>
<col span="1" style="width: 1%;">
<col span="1" style="width: 99%;">
</colgroup>
<tbody><tr><td class="cell">
<div id='rot90cont' style='position: relative'>
<div class='rot90' id='rot90'
style='font-size:70%; position: absolute; padding: 0.15em'>
<b>KanJax</b><br/>
<div style="font-size:80%; line-height: 90%">
<a href="https://github.com/maurimo/KanJax">GitHub<br/>
page</a></div>
</div></div>
</td><td class="cell" style="padding-left: 0.4em">
<table border="0" style="width:100%;">
<colgroup>
<col span="1" style="width: 0%;">
<col span="1" style="width: 100%;">
</colgroup>
<tbody><tr><td class="cell"><input disabled="true"
type="button" id="myback" value="" onclick="myBack();"/></td>
<td class="cell" id="myaddress3" style="position:relative; text-align: left;">
<div id="myaddress2" style="position: absolute; top: 0; height: 100%">
<input id="myaddress"
style="margin:0px; position: absolute; top: 50%; -ms-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
transform: translateY(-50%);" type="edit" /></div>
</td></tr></tbody></table>
<span style="font-size: 70%">
<input id="autoaddinfo" type="checkbox"/> Auto-add info on load
<input type="button" value="Add info"
onclick="myAddInfo();"/>
<input type="button" value="Remove info"
onclick="myRemoveInfo();"/>
</span>
</td></tr></tbody></table>
<div id="showerr"></div>
<!--<iframe id="myiframe" onLoad="myFrameLoad()" src="http://127.0.0.1/~maurizio/kanjax/iframe/%E6%97%A5%E6%9C%AC%20-%20Wikipedia.html"></iframe>-->
<iframe id="myiframe" onLoad="myFrameLoad()" src="proxy.php?url=https%3A%2F%2Fja.wikipedia.org%2Fwiki%2F%25E6%2597%25A5%25E6%259C%25AC"></iframe>
<!-- <iframe id="myiframe" onLoad="myFrameLoad()" src="proxy.php?url=http%3A%2F%2Fjisho.org%2Fsearch%2F%2523kanji%2520%25E8%25B2%25AB"></iframe> -->
<!-- <iframe id="myiframe" onLoad="myFrameLoad()" src="http://127.0.0.1/~maurizio/kanjax/proxy.php?url=https%3A%2F%2Fja.wikipedia.org%2Fwiki%2F%25E3%2583%25A2%25E3%2583%25BC%25E3%2583%25A9"></iframe> -->
<!-- fixme: -->
<!-- <iframe id="myiframe" onLoad="myFrameLoad()" src="http://127.0.0.1/~maurizio/kanjax/proxy.php?url=http%3A%2F%2Fwww.hiesyo.com%2Ftabemono%2F"></iframe> -->
</body>
</html>