Repository navigation
Expand file tree
/
Copy pathinfo.php
More file actions
195 lines (172 loc) · 5.67 KB
/
Copy pathinfo.php
File metadata and controls
195 lines (172 loc) · 5.67 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GIF小程序</title>
<!-- Latest compiled and minified CSS -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script type="text/javascript" src="../../../public/js/jquery.min.js"></script>
<script src="../../../public/js/template-web.js"></script>
<style>
body, html {
font-size: 10.66px;
width: 100%;
height:100%;
padding: 0;
margin: 0;
}
.zaly_container {
width: 100%;
height:100%;
display: block;
position: relative;
}
.gif_div{
text-align: center;
position: absolute;
top:30%;
left:0;
right:0;
margin:auto;
}
.save_button {
width:8rem;
height:3.38rem;
background:rgba(76,59,177,1);
border-radius:0.38rem;
font-size:1.5rem;
font-family:PingFangSC-Regular;
font-weight:400;
color:rgba(255,255,255,1);
}
.gif_div_button {
display: flex;
justify-content: center;
margin-top: 5rem;
cursor: pointer;
outline: none;
}
</style>
</head>
<body>
<div class="zaly_container" >
<input type="hidden" class="roomType" value='<?php echo $roomType;?>'>
<input type="hidden" class="toId" value='<?php echo $toId;?>'>
<input type="hidden" class="fromUserId" value='<?php echo $fromUserId;?>'>
<input type="hidden" class="gifId" value='<?php echo $gifId;?>'>
<input type="hidden" class="gifUrl" value='<?php echo $gifUrl;?>'>
<input type="hidden" class="gifWidth" value='<?php echo $width;?>'>
<input type="hidden" class="gifHeight" value='<?php echo $height;?>'>
<input type="hidden" class="isDefault" value='<?php echo $isDefault;?>'>
</div>
<script id="tpl-gif" type="text/html">
<div class="gif_div" id="gifDiv">
<img id="gifInfo" src='{{gifUrl}}' class='gif' gifId='{{gifId}}'>
{{if isDefault == "0" }}
<div class="gif_div_button">
<button class="save_gif save_button " gifId='{{gifId}}'>收藏</button>
</div>
{{ else }}
<div class="gif_div_button">
<button class="save_button" gifId='{{gifId}}' disabled>已收藏</button>
</div>
{{/if}}
</div>
</script>
<script type="text/javascript">
UserClientLangZH = "1";
UserClientLangEN = "0";
function getLanguage() {
var nl = navigator.language;
if ("zh-cn" == nl || "zh-CN" == nl) {
return UserClientLangZH;
}
return UserClientLangEN;
}
roomType = $(".roomType").val();
fromUserId = $(".fromUserId").val();
toId = $(".toId").val();
gifId = $(".gifId").val();
gifUrl = $(".gifUrl").val();
gifWidth = $(".gifWidth").val();
gifHeight = $(".gifHeight").val();
isDefault = $(".isDefault").val();
var imgObject = {};
var saveGifType = "save_gif";
var languageNum = getLanguage();
var html = template("tpl-gif", {
gifId:gifId,
gifUrl:gifUrl,
isDefault:isDefault
});
$(".zaly_container").append(html);
var src = $("#gifInfo").attr("src");
autoImgSize(src, 200, 200);
function autoImgSize(src, h, w)
{
var image = new Image();
image.src = src;
image.onload = function (ev) {
var imageNaturalWidth = image.naturalWidth;
var imageNaturalHeight = image.naturalHeight;
if (imageNaturalWidth < w && imageNaturalHeight<h) {
imgObject.width = imageNaturalWidth == 0 ? w : imageNaturalWidth;
imgObject.height = imageNaturalHeight == 0 ? h : imageNaturalHeight;
} else {
if (w / h <= imageNaturalWidth/ imageNaturalHeight) {
imgObject.width = w;
imgObject.height = w* (imageNaturalHeight / imageNaturalWidth);
} else {
imgObject.width = h * (imageNaturalWidth / imageNaturalHeight);
imgObject.height = h;
}
}
$("#gifInfo")[0].style.width = imgObject.width+"px";
$("#gifInfo")[0].style.height = imgObject.height+"px";
}
}
function isMobile() {
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
return true;
}
return false;
}
$(".save_gif").on("click", function () {
var gifId = $(this).attr("gifId");
var reqData = {
gifId : gifId,
type:saveGifType,
}
sendPostToServer(reqData);
return false;
});
function sendPostToServer(reqData)
{
$.ajax({
method: "POST",
url:"./index.php?action=miniProgram.gif.index&type="+saveGifType+"&lang="+languageNum,
data: reqData,
success:function (data) {
data = JSON.parse(data);
if(data.errorCode == 'error.alert') {
zalyjsAlert(data.errorInfo);
return false;
}
$(".save_gif").html("已收藏");
}
});
}
function updateServerGif(fileId)
{
var reqData = {
gifId : fileId,
type:addGifType,
width:imgObject.width,
height:imgObject.height
}
sendPostToServer(reqData, addGifType);
}
</script>
</body>
</html>