-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
202 lines (182 loc) · 5.94 KB
/
index.php
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
<?php
include('language_codes.php');
include('settings.php');
// At this point, we generate the contents of the contextmenu
echo '<script>
var items = new Array;
items={
';
$result_voclists = mysql_query("select listid,listname from voclists where sessionid='".$sessionid."'") or die(mysql_error());
if (mysql_num_rows($result_voclists) > 0) {
while ($row = mysql_fetch_array($result_voclists)){
echo '"'.$row['listid'].'": {"name": "'.$row['listname'].'"},';
}
}
echo '
"sep1": "---------",
"new": {"name": "Create a new list"}
};
items.push({"test1": {"name": "testname"}});
</script>';
if(isset($_GET['from'])) {
if(isset($languageCodes[$_GET['from']])){
$from = $_GET['from'];
}
} else {
// passed language code is not correct, lets fallback
// to the default
$from = "en";
}
if(isset($_GET['to'])) {
if(isset($languageCodes[$_GET['to']])){
$to = $_GET['to'];
}
} else {
// passed language code is not correct, lets fallback
// to the default
$to = "de";
}
if(isset($_GET['q'])){
$q = $_GET['q'];
} else {
$q = "";
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Free and open online dictionary, based on Wiktionary" />
<meta name="HandheldFriendly" content="true" />
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no" />
<title>WikiDict.cc - The free and open online dictionary</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript' src='js/base.js'></script>
<script type='text/javascript' src="js/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript" src="js/jquery.ui.position.js"></script>
<script type="text/javascript" src="js/jquery.contextMenu.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.9.2.custom.css">
<link rel="stylesheet" media="handheld" href="css/style-mobile.css">
<link rel="stylesheet" media="screen and (max-width: 800px)" href="css/style-mobile.css">
<link rel="stylesheet" media="screen and (min-width: 801px)" href="css/styles.css">
<!--[if lte IE 8]><link rel="stylesheet" type="text/css" href="css/styles.css"><![endif]-->
<link rel="stylesheet" type="text/css" href="css/jquery.contextMenu.css"/>
<link id="opensearch" title="WikiDict.cc <?=$from?>-<?=$to?>" type="application/opensearchdescription+xml" rel="search" href="opensearch.php?from=<?=$from?>&to=<?=$to?>">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="copyright" href="//creativecommons.org/licenses/by-sa/3.0/">
<link rel="copyright" href="//www.gnu.org/copyleft/fdl.html">
<link rel="license" href="//creativecommons.org/licenses/by-sa/3.0/">
<link rel="license" href="//www.gnu.org/copyleft/fdl.html">
<script type="text/javascript">
$(function(){
$.contextMenu({
selector: '.contextmenu>tr>td',
callback: function(key, options) {
if (key == "new"){
voclist_add()
} else {
var trans = new Array();
trans[0] = $(this).text();
trans[1] = $(this).next('td').text();
trans[2] = $('#from').val();
trans[3] = $('#to').val();
trans = JSON.stringify(trans);
$.post("process.php", { action: "voclist_item_add", id: key, items: trans } )
.success(function(data) {
// wir färben das aktuelle row ein (vllt. auch permanent)?
alert('success');
})
.error(function(data) {
alert('error');
});
}
},
items: {
"fold1a": {
"name": "Add to voc list",
"items": items,
icon: "add"
}
}
});
$('.contextmenu').on('click', function(e){
console.log('clicked', this);
})
});
</script>
</head>
<?php
echo'<body onload="';
if (isset($_GET['p'])) {
echo 'showArticle(\''.$_GET['p'].'\');';
} else {
if(isset($_GET['from']) & isset($_GET['to']) & isset($_GET['q'])){
echo 'translate(\''.$from.'\',\''.$to.'\',\''.$q.'\');';
}
}
echo '">';
?>
<div id=container>
<header>
<div id="left">
<h1><a href="javascript:void(0);">WikiDict.cc</a></h1>
<h2>Free and open online dictionary based on <a target=new href=http://wiktionary.org>Wiktionary.org</a></h2>
</div>
<div id="right">
<form id="form" class="form-inline">
<span id="mobilfoo">
<label for="from">From:</label>
<select onchange="$('form').submit()" name="from" id="from" tabindex="2">
<?php
foreach ($languageCodes as $key => $value)
if($key == $from) {
echo "<option selected='selected' value='".$key."'>".$value." (".$key.")</option>";
} else {
echo "<option value='".$key."'>".$value." (".$key.")</option>";
}
?>
</select>
</span>
<span id="mobilfoo">
<label for="to">to:</label>
<select onchange="$('form').submit()" name="to" id="to" tabindex="2">
<?php
foreach ($languageCodes as $key => $value)
if($key == $to) {
echo "<option selected='selected' value='".$key."'>".$value." (".$key.")</option>";
} else {
echo "<option value='".$key."'>".$value." (".$key.")</option>";
}
?>
</select>
</span>
<br>
<input type="text" id="word" value="<?=$q?>">
<button>Translate</button>
<a href="javascript:addOpensearch();">OpenSearch</a>
</form>
</div>
</header>
<section>
<article>
</article>
<table id="result">
<thead>
<tr class="title"><th width=50%>Sprache 1</th><th>Sprache 2</th></tr>
</thead>
<tbody class="contextmenu">
</tbody>
</table>
</section>
<footer>
<div style="float:left;">
<a href="http://flattr.com/thing/1096017/WikiDict-cc-The-free-and-open-online-dictionary" target="_blank">
<img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a>
</div>
<a href="javascript:article('dictionaries');">Dictionaries</a>
<a href="javascript:article('vocabulary.php');">Vocabulary</a>
<a href="javascript:article('about');">About</a>
</footer>
</div>
</body>
</html>