forked from RikaKagurasaka/ChemByRika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
351 lines (323 loc) · 14.4 KB
/
index.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!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>
<script src="src/waitForKeyElements.js"></script>
<!-- Angular Material Library -->
<!-- Your application bootstrap -->
<script src="src/timeago.js"></script>
<!--<script src="preview.json"></script>-->
<script src="info.js"></script>
<link rel="Shortcut Icon" href="favicon.ico">
<style>
md-list-item.active {
background: #2aabd2;
}
.btn-info {
background: #2aabd2;
}
</style>
<title>Chem by Rika</title>
</head>
<body ng-app="BlankApp" ng-cloak layout="column" ng-controller="AppCtrl">
<md-toolbar whiteframe="14" style="/*position:fixed;*/z-index: 999" class="">
<div class="md-toolbar-tools">
<md-button class="md-icon-button" aria-label="Search" onclick="search()">
<md-icon md-svg-icon="svg/ic_search_48px.svg"></md-icon>
</md-button>
<h2 flex><input type="text" class="form-control" onkeypress="EnterDown(event);" id="search"
placeholder="Search"
style="background-color: #00000000;border: #00000000;border-bottom:1px solid #ffffff ;color: #ffffffee">
</h2>
<!--<span class="input-group-btn">-->
<md-button class="md-icon-button " layout-align="right" onclick="fav();" aria-label="Favorite" id="btn-fav">
<md-icon md-svg-icon="svg/ic_star_24px.svg"></md-icon>
</md-button>
<!--<button class="btn btn-default" type="button" id="btn-fav" onclick="fav();">-->
<!--<span class="glyphicon glyphicon-star"></span>-->
<!--</button>-->
<md-button class="md-icon-button " layout-align="right" onclick="random();" aria-label="Random">
<md-icon md-svg-icon="svg/random.svg"></md-icon>
</md-button>
<!--<button class="btn btn-default" type="button" onclick="random();">-->
<!--<span class="glyphicon glyphicon-random"></span>-->
<!--</button>-->
<md-button class="md-icon-button " layout-align="right" ng-click="showAlert($event)"
aria-label="Copyright Info">
<md-icon md-svg-icon="svg/ic_copyright_48px.svg"></md-icon>
</md-button>
<!--<button class="btn btn-default" type="button" data-toggle="modal" data-target="#copyright">-->
<!--<span class="glyphicon glyphicon-copyright-mark"></span>-->
<!--</button>-->
<md-button class="md-icon-button " layout-align="right" onclick="history();" aria-label="History">
<md-icon md-svg-icon="svg/ic_history_48px.svg"></md-icon>
</md-button>
<!--<button class="btn btn-default" type="button" onclick="history();">-->
<!--<span class="glyphicon glyphicon-time"></span>-->
<!--</button>-->
<!--</span>-->
</div>
</md-toolbar>
<md-content>
<md-list class="list-group" id="list-all" style="position:relative;">
</md-list>
</md-content>
<img style="position:fixed;top:100%;left:100%;height:auto;max-height:50%;max-width:50%;z-index:999;pointer-events:none;"
class="pull-right" align="right" id="pre"/>
<div style="visibility: hidden" aria-labelledby="copyright">
<div class="md-dialog-container" id="myDialog">
<md-dialog layout-padding>
<div class="modal-header">
<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> -->
<h4 class="modal-title text-center" id="copyright-title">Copyright</h4>
</div>
<div class="modal-body">
<h2>Chem By Rika
<small> v0.4.0</small>
</h2>
<p>The synthesis routes all come from <a href="http://chemistrybydesign.oia.arizona.edu/"><em>Chemisty
By Design</em></a>.</p>
<p>Main Developer:<a href="https://github.com/RikaSugisawa">Rika</a></p>
<p>Special thanks to:<a href="https://github.com/TooYoungTooSimp">TooYoungTooSimp</a> 黑大炮</p>
<p><a href="https://github.com/RikaSugisawa/ChemByRika"><span
class="label label-primary">Github</span></a>
<a href="http://rika.tech/ChemByRika/"><span class="label label-default">Web version</span></a>
</p>
</div>
</md-dialog>
</div>
</div>
<script>
/*$.each(list,function(index,content){
$("#list-all").append('<li class="list-group-item">'+index+'</li>');
}
)*/
/*function onscroll() {
var num = Math.floor((GetPageScroll()['Y']) / $('.list-group').height() * $('.list-group').children().length + 0.5);
$('.list-group').children('.active').removeClass('active');
$('.list-group').children().eq(num).addClass('active');
if ($('.list-group').text() != '') {
$('img#pre').attr("src", 'data:image/png;base64,' + preview_json[$('.list-group').children('.active').val() + '.png']);
$('img#pre').on('load', function () {
$('img#pre').css('margin-left', -$('img#pre').width());
$('img#pre').css('margin-top', -$('img#pre').height());
});
} else {
$('img#pre').css('margin-left', 0);
$('img#pre').css('margin-top', 0);
$('.list-group').html('<div class="alert alert-warning" role="alert">There is no result.</div>');
}
}
function over(obj) {
if (screen.height > 432) {//如果是电脑就加上,不是就不加
$('.list-group').children('.active').removeClass('active');
obj.addClass('active');
}
if ($('.list-group').text() !== '') {
$('img#pre').attr("src", 'preview/' + $('.list-group').children('.active').val() + '.png');
$('img#pre').on('load', function () {
$('img#pre').css('margin-left', -$('img#pre').width());
$('img#pre').css('margin-top', -$('img#pre').height());
});
} else {
$('img#pre').css('margin-left', 0);
$('img#pre').css('margin-top', 0);
$('.list-group').html('<div class="alert alert-warning" role="alert">There is no result.</div>');
}
}*/
function search() {
$("#list-all").html('');
for (var key in list) {
if (key.toLowerCase().indexOf($('input#search').val().toLowerCase()) > -1 && (
$('#btn-fav').hasClass('btn-info') ? localStorage.fav.indexOf(key) > -1 : 1)
) {
var max = (detail[key][0] - 1) / 2;
$("#list-all").append(
'\
<md-list-item class="secondary-button-padding _md-button-wrap md-with-secondary _md md-clickable" role="listitem"\
tabindex="-1">\
<div class="md-button md-no-style">\
<button class="md-no-style md-button md-ink-ripple" type="button" ng-transclude="" aria-label="' + key + '" onclick="mclick($(this));">\
<div class="md-ripple-container" style=""></div>\
</button>\
<div style="height:100%;display: none;width:15%;background:#e009;color:#fff;font-family:Roboto,Helvetica Neue,sans-serif" class="div-sure">Click again to Sure</div>\
<div class="md-list-item-inner">\
<p>' + key.split('(')[0] + '<small>(\
' + key.split('(')[1].split(')')[0] + ')</small></p>\
\
</div>\
<div class="md-secondary-container">\
<span class="badge">' + max + ' </span>\
</div>\
</div>\
</md-list-item>'
);
}
}
}
function history() {//获取历史反应信息
$('input#search').val('');
$('#btn-fav').removeClass('btn-info');
$("#list-all").html('');
for (var key_time_int = localStorage.his.split('|').length - 1; key_time_int > 0; key_time_int--) {
var key_time = localStorage.his.split('|')[key_time_int - 1];
if (key_time == "") {
continue;
}
key = key_time.split(',')[0];
var time = new Date();
time.setTime(key_time.split(',')[1]);
datetime = time.getUTCFullYear() + '-' +
(time.getUTCMonth() + 1) + '-' +
time.getUTCDate() + 'T' +
time.getUTCHours() + ':' +
time.getUTCMinutes() + ':' +
time.getUTCSeconds() + 'Z';
var max = (detail[key][0] - 1) / 2;
$("#list-all").append('\
<md-list-item class="secondary-button-padding _md-button-wrap md-with-secondary _md md-clickable" role="listitem"\
tabindex="-1">\
<div class="md-button md-no-style">\
<button class="md-no-style md-button md-ink-ripple" type="button" ng-transclude="" aria-label="' + key + '" onclick="mclick($(this));">\
<div class="md-ripple-container" style=""></div>\
</button>\
<div style="height:100%;display: none;width:15%;background:#e009;color:#fff;font-family:Roboto,Helvetica Neue,sans-serif" class="div-sure">Click again to Sure</div>\
<div class="md-list-item-inner">\
<p>' + key.split('(')[0] + '<small>(\
' + key.split('(')[1].split(')')[0] + ')</small></p>\
\
</div>\
<div class="md-secondary-container">\
<time datetime="' + datetime + '" class="timeago"></time> \
<span class="badge">' + max + ' </span>\
</div>\
</div>\
</md-list-item>');
}
$('body').timeago('refresh');
onscroll();
}
function random() {
$("#list-all").html('');
var keys = [];
for (var key in list) {
keys.push(key);
}
var key = keys[Math.floor(Math.random() * keys.length)];
//$("#list-all").append('<button type="button" data-placement="top" data-trigger="focus" data-toggle="popover" data-content="<img style="max-width:100%;" src="./preview/'+key+'.png">" data-html=true value="'+list[key]+'" onmouseover="$(this).popover(\'show\');" onmouseout="$(this).popover(\'hide\')" onClick="window.location.href=\'detail.html?para='+key+'\'" class="list-group-item">'+key+'</li>');
var max = (detail[key][0] - 1) / 2;
$("#list-all").append('\
<md-list-item class="secondary-button-padding _md-button-wrap md-with-secondary _md md-clickable" role="listitem"\
tabindex="-1">\
<div class="md-button md-no-style">\
<button class="md-no-style md-button md-ink-ripple" type="button" ng-transclude="" aria-label="' + key + '" onclick="mclick($(this));">\
<div class="md-ripple-container" style=""></div>\
</button>\
<div class="md-list-item-inner">\
<p>' + key.split('(')[0] + '<small>(\
' + key.split('(')[1].split(')')[0] + ')</small></p>\
\
</div>\
<div class="md-secondary-container">\
<span class="badge">' + max + ' </span>\
</div>\
</div>\
</md-list-item>');
mclick($('button[aria-label="' + key + '"]'));
// onscroll();
}
//滚动条位置
/*function GetPageScroll() {
var x, y;
if (window.pageYOffset) { // all except IE
y = window.pageYOffset;
x = window.pageXOffset;
} else if (document.documentElement && document.documentElement.scrollTop) { // IE 6 Strict
y = document.documentElement.scrollTop;
x = document.documentElement.scrollLeft;
} else if (document.body) { // all other IE
y = document.body.scrollTop;
x = document.body.scrollLeft;
}
return {X: x, Y: y};
}
function getJsonLength(jsonData) { //获取json长度
var jsonLength = 0;
for (var item in jsonData) {
jsonLength++;
}
return jsonLength;
}*/
function fav() {
if ($('#btn-fav').hasClass('md-accent btn-info')) {
$('#btn-fav').removeClass('md-accent btn-info');
} else {
$('#btn-fav').addClass('md-accent btn-info');
}
search();
}
function EnterDown(e) {
var keynum
if (window.event) // IE
{
keynum = e.keyCode
}
else if (e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
if (keynum == 13) {
search();
}
}
function mclick(btn) {
$('md-list-item').removeClass('active');
if (btn.hasClass('active')) {
window.location.href = 'detail.html?para=' + btn.attr('aria-label').replace('\'', '\\\'');
} else {
$('button').removeClass('active');
btn.addClass('active');
btn.parent().parent().addClass('active');
//btn.parent().parent().css('background','#66ccff');
}
//$('img#pre').attr("src", 'preview/' + $('button.active').val() + '.png');
$('img#pre').attr("src", 'preview/' + btn.attr('aria-label') + '.png');
$('img#pre').on('load', function () {
$('img#pre').css('margin-left', -$('img#pre').width());
$('img#pre').css('margin-top', -$('img#pre').height());
});
return false;
}
$(document).ready(function () {
search();
});
angular.module('BlankApp', ['ngMaterial'])
.controller('AppCtrl', function ($scope, $mdDialog) {
$scope.status = ' ';
$scope.customFullscreen = false;
$scope.showAlert = function (ev) {
// 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: '#myDialog',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true
}
);
}
});
</script>
</body>
</html>