-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
172 lines (160 loc) · 5.24 KB
/
index.php
File metadata and controls
172 lines (160 loc) · 5.24 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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bluemix云端数据库服务使用示例———PHP投票程序 - 无知人生,记录点滴</title>
<style>
body {
margin:0; padding:0;
}
a{
text-decoration:none;
color:black;
}
div.div_id {
float:left;
clear:left;
width:60px;
height:27px;
border-bottom:solid 1px #808080;
text-align:center;
line-height:27px;
}
div.div_item {
float:left;
clear:none;
width:260px;
height:27px;
border-bottom:solid 1px #808080;
text-align:left;
line-height:27px;
}
div.div_radio {
float:left;
clear:none;
width:60px;
height:27px;
border-bottom:solid 1px #808080;
text-align:left;
line-height:27px;
display:none;
}
div.div_num {
float:left;
clear:right;
width:260px;
height:27px;
border-bottom:solid 1px #808080;
text-align:left;
line-height:27px;
display:none;
}
</style>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<SCRIPT language=javascript>
$(document).ready(function(){
//判断是否已经投过票了,如果投过票了,就不再显示投票按钮,而是显示投票结果;
if (document.cookie == "" || document.cookie == "abc="){
var ck = document.cookie;
//alert("cookie == " + ck +" null or abc=");
$("#button1").show();
$("div.div_radio").show();
}else{
//alert("cookie == " + ck +" not null or abc= \\\\\ else");
$("div.div_num").show();
}
});
//通过AJAX调用后台保存投票信息
function execVote(){
var id = $('input[name="radio1"]:checked').val();
if (id == "" || id == undefined){
alert("请选择投票项!");
return;
}
$("#button1").hide();
$.ajax({
type: "POST",
url: "vote.php",
dataType:"html",
data: {"id":id},
success: function(data){
$("#div_num_" + id).text(parseInt($("#div_num_" + id).text()) + 1);
$("div.div_radio").hide();
$("div.div_num").show();
document.cookie = "abc=123";
console.log(data);
},
error: function(data){
console.log(data);
alert( "投票失败: " + data.responseText );
}
});
}
//通过AJAX调用后台翻译程序
function doExecTrans(){
//alert("cliecked!");
var txt = $("#InputText").val();
//alert("input!"+txt);
if (txt == ""){
alert("请输入要翻译的文本!");
return;
}
//$("#ProgressDiv").show();
$.ajax({
type: "GET",
url: "trans.php",
dataType:"json",
data: {"txt":txt},
success: function(data){
//$("#ProgressDiv").hide();
console.log(data);
//alert("data: "+data);
if (data.error){
alert(data.error);
}else{
$("#OutputText").text(data.text);
//alert("data: "+data);
}
},
error: function(data){
console.log(data);
alert( "Error Msg: " + data );
//$("#ProgressDiv").hide();
}
});
}
</SCRIPT>
</head>
<body>
<div>
<a href="http://blog.csdn.net/testcs_dn" target="_blank" title="无知人生,记录点滴 不积硅步,无以至千里;不积小流,无以成江海……">
<img src="" border=0 />
</a>
</div>
<div style="width:640px; height:0px; border-bottom:solid 1px #808080;text-align:center;">
<a href="http://blog.csdn.net/testcs_dn/article/details/49965993"><h3>Watson Translator</h3></a>
</div>
<div id="Wrapper" style="padding: 0px; margin: 0px; min-height:300px; text-align: center; background-color: rgb(255, 255, 255);">
<form>
<div style="width:640px; height:100px; border-bottom:solid 1px #808080;text-align:center; float:left; clear:both; margin-top:15px;">
<textarea class="textarea" id="InputText" style="height:40px;">输入</textarea>
<input type="button" id="button1" name="button1" value="翻译" onclick="doExecTrans()" />
<textarea class="textarea" id="OutputText" data-height="140px" style="height:40px;"></textarea>
</div>
</form>
</div>
<div style="margin:auto; text-align:center; line-height:28px;">云服务器:
<a href="https://console.ng.bluemix.net/home/" target="_blank" title="IBM Bluemix 数字创新平台" style="">
IBM Bluemix 数字创新平台
</a><br />
服务提供:
<a href="https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/language-translation/api/v2/#introduction" target="_blank" title="IBM Watson Developer Cloud" style="">
IBM Watson Language Translator
</a>
</div>
<div style="margin:auto; text-align:center; line-height:28px;">
<a href="http://blog.csdn.net/testcs_dn" target="_blank" title="无知人生,记录点滴 不积硅步,无以至千里;不积小流,无以成江海……" style="">
Powered by:amfang<br />无知人生,记录点滴 不积硅步,无以至千里;不积小流,无以成江海……
</a>
</div>
</body>
</html>