forked from RikaKagurasaka/ChemByRika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetail.html
329 lines (307 loc) · 14.3 KB
/
detail.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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<!DOCTYPE html>
<html>
<head>
<script src="bootstrap/jquery.js"></script>
<link rel="stylesheet" href="bootstrap/bootstrap.min.css">
<!--<link rel="stylesheet" href="bootstrap/bootstrap-theme.min.css"> -->
<script src="bootstrap/bootstrap.min.js"></script>
<link rel="stylesheet" href="src/angular-material.min.css">
<script src="src/angular.min.js"></script>
<script src="src/angular-animate.js"></script>
<script src="src/angular-aria.min.js"></script>
<script src="src/angular-messages.js"></script>
<script src="src/angular-material.js"></script>
<link href="src/zoom/css/zoom.css" rel="stylesheet">
<script src="src/zoom/js/zoom.js"></script>
<script src="doi.js"></script>
<script src="list.js"></script>
<!--<script src="preview.json"></script>-->
<link rel="Shortcut Icon" href="favicon.ico">
<title>Chem by Rika</title>
<style>
img {
max-width: 100%;
}
.container {
width: 100%;
}
.blur {
opacity: 0;
transition: opacity 2s;
}
img {
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari 和 Chrome */
-o-transition: opacity 2s; /* Opera */
}
button.active {
background: #2aabd2;
}
</style>
<script>
angular.module('BlankApp', ['ngMaterial'])
.controller('AppCtrl', function ($scope, $mdDialog) {
$scope.status = ' ';
$scope.customFullscreen = false;
$scope.showAlert = function (ev, target) {
// Appending dialog to document.body to cover sidenav in docs app
// Modal dialogs should fully cover application
// to prevent interaction outside of dialog
$mdDialog.show(
{
contentElement: target,
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true
}
);
}
/*$scope.$on("slideEnded", function () {
show($scope.progress * 2 - 1);
})*/
}
);
</script>
</head>
<body ng-app="BlankApp" ng-cloak ng-controller="AppCtrl">
<div class="container" style="position:relative">
<p> </p>
<div class="row" style="max-height:33%;position:relative">
<div class="col-xs-4" id="lft1">
<!--
<span><a href="index.html"><button class="btn-sm btn btn-default"><span
class=" glyphicon glyphicon-backward"></span></button></a></span>
<span>
<button id="-quiz" type="button"
onclick="if(!$('button#quiz').hasClass('active')){$('button#quiz').addClass('active');}else{$('button#quiz').removeClass('active');}show(i);"
class="btn btn-default btn-sm"><span
class="glyphicon glyphicon-question-sign"></span></button>
</span>
<span>
<button id="-fav" class="btn-sm btn btn-default" onclick="favourite();"><span
class="glyphicon glyphicon-star"></span></button>
</span>
<span>
<button id="-tar" class="btn-sm btn btn-default" data-toggle="modal" data-target="#m-target"><span
class="glyphicon glyphicon-flag"></span></button>
</span>
<span>
<button id="doi" class="btn-sm btn btn-default" data-toggle="modal" data-target="#m-doi"><span
class="glyphicon glyphicon-download-alt"></span></button>
</span>-->
<!--<md-toolbar layout="column" layout-align="center center">-->
<div class="md-toolbar-tools">
<md-button class="md-icon-button" aria-label="BackToMenu"
onclick="window.location='index.html'"><span
class=" glyphicon glyphicon-backward"></span></md-button>
<md-button id="quiz"
onclick="if(!$('button#quiz').hasClass('active')){$('button#quiz').addClass('active');}else{$('button#quiz').removeClass('active');}show(i);"
class="md-icon-button"><span
class="glyphicon glyphicon-question-sign"></span></md-button>
<md-button id="fav" class="md-icon-button" onclick="favourite();"><span
class="glyphicon glyphicon-star"></span></md-button>
<md-button id="tar" class="md-icon-button" ng-click="showAlert($event,'#m-target')"><span
class="glyphicon glyphicon-flag"></span></md-button>
<md-button id="doi" class="md-icon-button" ng-click="showAlert($event,'#m-doi')"><span
class="glyphicon glyphicon-download-alt"></span></md-button>
</div>
<!--</md-toolbar>-->
</div>
<div class="col-xs-4" id="age"></div>
<div class="col-xs-4" id="rgt1">
<!-- <div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="0"
aria-valuemin="0" aria-valuemax="0" style="width: 0;">
NaN
</div>
</div>-->
<md-slider-container>
<md-slider class="md-primary" flex md-discrete min="1" max="{{max}}" ng-model="progress" aria-label="progress"
onmouseup="show(parseInt($('.md-thumb-text').text()) * 2 - 1);" id="progress-slider">
</md-slider>
<md-input-container>
<input readonly flex ng-model="progressLabel" aria-label="progress" aria-controls="progress-slider">
</md-input-container>
</md-slider-container>
</div>
</div>
<div class="row" style="">
<div class="col-xs-1" id="lft2"></div>
<div class="col-xs-3" id="sub" ></div>
<div class="col-xs-4" id="arr">
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 112 24" style="enable-background:new 0 0 112 24;" xml:space="preserve">
<style type="text/css">
.st0 {
fill: none;
stroke: #000000;
stroke-miterlimit: 10;
}
</style>
<line class="st0" x1="7.8" y1="11.2" x2="103.8" y2="11.2" ></line>
<line class="st0" x1="99" y1="5" x2="104.1" y2="11.2" ></line>
<line class="st0" x1="98.5" y1="16.7" x2="104.2" y2="11.1" ></line>
</svg>
</div>
<div class="col-xs-3" id="pro"></div>
<div class="col-xs-1" id="rgt2"></div>
</div>
<div class="row" style="">
<div class="col-xs-4" id="lft3" layout="row" layout-align="center center">
<md-button id="btn_previous" class="md-fab md-hue-2"
onClick="i=i-2;show(i);if(i===1){$(this).hide();}else{$(this).show();}$('.md-primary').show();">
<span class="glyphicon glyphicon-chevron-left"></span></md-button>
</div>
<div class="col-xs-4" id="rea"></div>
<div class="col-xs-4" id="rgt3" layout="row" layout-align="center center">
<md-button id="btn_next" class="md-fab md-primary"
onClick="i=i+2;show(i);if(i+2>=max){$(this).hide();}else{$(this).show();}$('.md-hue-2').show();">
<span class="glyphicon glyphicon-chevron-right"></span></md-button>
</div>
</div>
</div>
<div style="display: none;">
<div class="md-dialog-container" tabindex="-1" id="m-target">
<md-dialog layout-padding>
<h4 class="modal-title text-center">Target Molecular</h4>
<div>
<img id="img-target" class="center-block"
style="position:relative;max-width:80vw;max-height:80vh;height:auto;width:auto;"/>
</div>
</md-dialog>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
<div style="display: none;">
<div class="md-dialog-container" id="m-doi">
<md-dialog layout-padding>
<h4 class="modal-title text-center">DOI</h4>
<div class="text-center">
<a href='#'>
<i id="text-doi"></i>
</a>
</div>
</md-dialog>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
<script>
function getUrlParam(name) //获取网址参数
{
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]);
return null; //返回参数值
}
var key = getUrlParam('para');
$('title').text(key + " - Chemistry by Design");
var de = detail[key];
var max = de[0];
var reactions = de[1];
var keys = [];
for (var mkey in list) {
keys.push(mkey);
}
//for(var i=1;i<max+1;i++){
var i = 1;
function show(i) { //显示反应
$('#btn_previous').show();
$('#btn_next').show();
if(i<=1)$('#btn_previous').hide();
if(i+2>=max)$('#btn_next').hide();
$.ajax({
url: './images/' + key + '.json', dataType: 'json', dataFilter: function (data) {
data = $.parseJSON(data);
$('#sub').html('<img class="center-block" data-action="zoom" onclick="mclick($(this));" style="max-height:30vh;" src="data:image/png;base64,' + data[i + '.png'] + '"/>');
$('#age').html('<img class="center-block" data-action="zoom" onclick="mclick($(this));" style="max-height:30vh;" src="data:image/png;base64,' + data[(i + 1) + '.png'] + '"/>');
$('#pro').html('<img class="center-block" onclick="mclick($(this));" style="max-height:30vh;" src="data:image/png;base64,' + data[(i + 2) + '.png'] + '"/>');
if (reactions.indexOf(i + 1) > -1) {
$('#rea').html('<img class="center-block" style="max-height:20vh;" onclick="mclick($(this));" src="data:image/png;base64,' + data[(i + 1) + 'b.png'] + '"/>');
} else {
$('#rea').html('');
}
//$('#arr_svg').css('margin-top',$('#container').children().eq(1).height()/2);
$('.progress-bar').html(((i + 1) / 2) + '/' + ((max - 1) / 2));
$('.progress-bar').css('width', (((i + 1) / 2)) / ((max - 1) / 2) * 100 + '%');
$('.progress-bar').attr('aria-valuemax', max);
$('.progress-bar').attr('aria-valuenow', i);
var $scope = angular.element($('[ng-controller="AppCtrl"]')).scope();
$('md-slider').attr('max', i);
$scope.progress = (i + 1) / 2;
$scope.max = (max - 1) / 2;
$scope.progressLabel = $scope.progress.toString() + '/' + $scope.max.toString();
$scope.$apply();
$('.container').children('.row').eq(1).find('img').on('load', function () {
$('#arr_svg').css('top', $('#sub').children().height() / 2 - $('#arr_svg').height() / 2);
});
if ($('button#quiz').hasClass('active')) {
//$('#age').children().addClass('blur');
$('#pro').children().addClass('blur');
$('#rea').children().addClass('blur');
} else {
//$('#age').children().addClass('n-blur');
$('#pro').children().addClass('n-blur');
$('#rea').children().addClass('n-blur');
//$('#age').children().attr('data-action','zoom');
$('#pro').children().attr('data-action', 'zoom');
$('#rea').children().attr('data-action', 'zoom');
}
}
});
}
if (screen.height > 432) {
$('#lft1').find('.btn-sm').removeClass('btn-sm');
$('#btn_previous').addClass('btn-lg');
$('#btn_next').addClass('btn-lg');
}//调节工具栏大小
if (!localStorage.fav) {
localStorage.fav = [];
}
if (localStorage.fav.indexOf(key) > -1) {
$('#fav').addClass('btn-info');
}
$('#img-target').attr('src', 'preview/' + key + '.png');
$(document).ready(function () {//第一个反应初始化
show(i);
$('#btn_previous').hide();
if (max == 3) {
$('#btn_next').hide();
}
});
//以下处理历史反应
if (localStorage.his == undefined) {
localStorage.his = '';
}
while (localStorage.his.match('|').length >= 20) {
localStorage.his = localStorage.his.slice(localStorage.his.indexOf('|') + 1)
}
localStorage.his = localStorage.his.replace(RegExp(key.replace('(', '\\(').replace(')', '\\)') + ',\\d*\\|'), '');
localStorage.his += (key + ',' + Date.parse(new Date()) + '|');
console.log(localStorage.his);
//以上处理历史反应
function favourite() {//收藏反应
if (localStorage.fav.indexOf(key) < 0) {
localStorage.fav += (key + ',');
$('#fav').addClass('btn-info');
} else {
localStorage.fav = localStorage.fav.replace(key + ',', '');
$('#fav').removeClass('btn-info');
}
}
function mclick(img) { //处理quiz点击事件
if (img.hasClass('blur')) {
img.removeClass('blur');
} else {
img.attr('data-action', 'zoom');
}
}
//以下处理doi
if (dois[key] != '') {
$('#text-doi').text(dois[key]);
$('#text-doi').parent().attr('href', 'http://sci-hub.bz/' + dois[key])
} else {
$('#text-doi').text('None');
$('#doi').attr('disabled', '');
}
//以上处理doi
</script>
</body>
</html>