-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwishlist.html
585 lines (217 loc) · 8.98 KB
/
wishlist.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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>books2go</title>
<link rel="stylesheet" href="css/jquery.mobile-1.4.3.min.css" />
<link rel="stylesheet" href="css/styles.css" />
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.mobile-1.4.3.min.js"></script>
<script src="js/main.js"></script>
<script>
</script>
<script id="panel-init">
$(function() {
$( "body>[data-role='panel']" ).panel();
});
</script>
</head>
<body >
<div id="wishListPage" data-role="page" >
<div data-role="header" data-position="fixed" data-theme="a" id="header"> <div data-role="navbar" id="head-buttons" data-iconpos="top"> </div> </div><!-- header -->
<div data-role="content" id="content">
<p class='logop'><img class='logo' src="images/logo3.png" alt="" /></p>
<div id="crumbdiv" style="display:none">
<ul id="crumb" data-role="listview" data-filter="false" data-inset="false" data-theme="a" >
<li><a class='ui-btn ui-btn-icon-left ui-icon-carat-l' href='javascript:ResetView()' data-ajax='false'>Back to wish list</a></li>
</ul>
</div>
<div id="search">
<div id="type-isbn">
<div class="title">Wish list</div>
<p>Add a book to your wish list and get notified by e-mail as soon as it is available! By default, you will be alerted when the textbook you want is posted by another student from your school.</p>
<form id="isbn-form">
<input type="text" placeholder="<enter isbn>" id="txt-isbn" maxlength="18" data-clear-btn="true" />
<button type="submit" style="background-color: #BCED91">Add</button>
</form>
</div>
<div id="results">
</div>
</div>
<div style="clear:both;height:20px"></div>
<div id="wl">
<div class="title">Your wish list</div>
<div id="wishlist"></div>
<div style="clear:both;height:20px"></div>
</div>
<div id="err"></div>
</div>
<div data-role="popup" id="pop" data-overlay-theme="a" data-theme="a" data-dismissible="true" style="max-width:400px;font-size:12px">
<p id="err"></p>
</div>
<div data-role="panel" id="mypanel" data-theme="a" style='padding:0;margin:0;'>
<img src="images/logo3.png" width="100%" />
<div style="height:30px"></div>
<ul data-role="listview" id="menu">
<li><a href="javascript:GoHome()" data-rel="close" data-ajax="false">Home</a></li>
<li><a href="search.html" data-rel="close" data-ajax="false">Search</a></li>
<li id="uprofile" style="display:none" data-role="collapsible" data-iconpos="right" data-inset="false">
<h2>Profile</h2>
<ul data-role="listview" data-theme="a">
<li><a href="mybooks.html" data-rel="close" data-ajax="false"> - My books</a></li>
<li><a href="postbook.html" data-rel="close" data-ajax="false"> - Post a textbook</a></li>
<li><a href="inbox.html" data-rel="close" data-ajax="false"> - Inbox</a></li>
<li><a href="wishlist.html" data-rel="close" data-ajax="false"> - Wish list</a></li>
<li><a href="editprofile.html" data-rel="close" data-ajax="false"> - Edit profile</a></li>
<li><a href="editschools.html" data-rel="close" data-ajax="false"> - Edit schools</a></li>
<li><a href="changepassword.html" data-rel="close" data-ajax="false"> - Change password</a></li>
</ul>
</li>
<li style="display:none" id="logout"><a href="logout.html" data-rel="user" data-ajax="false">Log out</a></li>
<li style="display:none" id="login"><a href="login.html" data-rel="user" data-ajax="false">Log In</a></li>
</ul>
</div><!-- /panel -->
<script>
$(document).on('pagebeforecreate', '#wishListPage', function(){ LoadHeader();});
$(document).on("pagebeforeshow","#wishListPage",function(){ // When entering pagetwo
if(window.localStorage.getItem("user_id")){
if(window.localStorage.getItem("user_id") > 0){
$("#uprofile").show();
$("#logout").show();
$("#login").hide();
GetInboxCount();
DisplayWishList();
}
}else{
localStorage.clear();
window.location = "index.html";
}
});
function DisplayWishList(){
var UID = window.localStorage.getItem("user_id");
if(UID){
$.ajax({
type: "POST",
url: "http://www.books2go.ca/mobiservice/get_wishlist.php",
data: {'UID' : UID},
dataType: "json",
success: function(data) {
$("#wishlist").html(data.result);
SetWidth();
ResetView();
},
error: function(xhr, desc, err) {
showErrorMessage(xhr + " Details: " + desc + "\nError:" + err, $("#err"), 0);
}
});
}
}
function AddToWishList(id){
var title = $("#btitle" + id).html();
var price = $("#bprice" + id).html();
var edition = $("#bedition" + id).html();
var author = $("#bauthor" + id).html();
var isbn = $("#bisbn" + id).html();
var ean = $("#bean" + id).html();
var smallpic = $("#smallpic" + id).html();
var medpic = $("#medpic" + id).html();
var UID = window.localStorage.getItem("user_id");
var email = window.localStorage.getItem("email");
if(id){
$.ajax({
type: "POST",
url: "http://www.books2go.ca/mobiservice/add_bookwishlist.php",
async: false,
data: {'isbn' : isbn, 'ean' : ean, 'price' : price, 'UID' : UID, 'title' : title, 'edition' : edition, 'author' : author, 'email' : email,'smallpic' : smallpic, 'medpic' : medpic},
dataType: "json",
success: function(data) {
if(data.error == ''){
showErrorMessage("Book has been added to your wish list !", $("#err"), 0);
DisplayWishList();
$("#results").html('');
$("#txt-isbn").val('');
}else{
showErrorMessage(data.error, $("#err"), 0);
}
},
error: function(xhr, desc, err) {
showErrorMessage(xhr + " Details: " + desc + "\nError:" + err, $("#err"), 0);
}
});
}
}
function RemoveFromWishList(id){
var UID = window.localStorage.getItem("user_id");
$.ajax({
type: "POST",
url: "http://www.books2go.ca/mobiservice/edit_bookwishlist.php",
async: false,
data: {'i' : id, 'UID' : UID},
dataType: "json",
success: function(data) {
showErrorMessage("Book was removed from your wish list", $("#err"), 0);
setTimeout(function() {
DisplayWishList();
}, 2000);
},
error: function(xhr, desc, err) {
showErrorMessage(xhr + " Details: " + desc + "\nError:" + err, $("#err"), 0);
}
});
}
function PostISBN(page){
getisbn = $("#txt-isbn").val();
author = "";
title = "";
var UID = window.localStorage.getItem("user_id");
$.ajax({
type: "POST",
url: "http://www.books2go.ca/mobiservice/get_newbook.php?search=new&wl=1",
async: false,
data: {'getisbn' : getisbn, 'author' : author, 'title' : title, 'UID' : UID, 'page' : page},
dataType: "json",
success: function(data) {
if(data.error == ''){
$("#wl").hide();
$("#crumbdiv").show();
$("#type-isbn").hide();
$("#results").show();
$("#results").html('');
$("#results").html(data.result);
SetWidth();
}else if (data.result == ''){
showErrorMessage("No books were found", $("#err"), 0);
}else{
showErrorMessage("Please enter an ISBN", $("#err"), 0);
}
},
error: function(xhr, desc, err) { showErrorMessage(xhr + " Details: " + desc + "\nError:" + err, $("#err"), 0);
}
});
}
function SetWidth(){
var tw = $("#wishListPage").width();
var w = $("#wishListPage").width() - 190;
$(".info").css("width", w);
}
$('#isbn-form').submit(function (e) {
e.preventDefault();
PostISBN(1);
});
function ResetView(){
$("#search").show()
$("#crumbdiv").hide();
$("#wl").show();
$("#type-isbn").show();
$("#results").hide();
}
</script>
</div><!-- /page -->
</body>
</html>