-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathView.html
201 lines (196 loc) · 6.88 KB
/
View.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>View Holidays</title>
<meta name="description" content="">
<meta http-equiv="Content-Security-Policy" content="object-src 'none';
default-src *;
style-src 'self' https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css View.css 'unsafe-inline';
script-src 'self' https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js 'unsafe-inline' 'unsafe-eval';
img-src * data: 'unsafe-inline';
connect-src * 'unsafe-inline';
child-src *;
"/>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="View.css">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<header>
<nav>
<ul>
<li><a href="Homepage.html">Home</a></li>
<li><a href="Favourites.html">Favourites</a></li>
<li><a href="View.html">View All Holidays</a></li>
<li> <a href="HolidayForm.html">Find your Holiday</a></li>
</ul>
</nav>
</header>
<aside id="favourite">Drag and Drop the Names into this box to save them<button id="clear">Remove All</button>
<ul id="resorts"></ul>
</aside>
<br><br>
<section class="row">
<section class="column">
<div class="container">
<img src="Belmond-Napasai/jonny-clow-35081.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="Thailand.html">Belmond Napasai</a></div>
</div>
</div>
</section>
</section>
<section class="row">
<section class="column">
<div class="container">
<img src="Chalet-Hotel/chris-biron-99839.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="France.html">Chalet Hotel Spaniniere</a></div>
</div>
</div>
</section>
<section class="column">
<div class="container">
<img src="Grandhotel-Pupp/daniil-avilov-244393.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="Czech.html">Grandhotel Pupp</a></div>
</div>
</div>
</section>
</section>
<section class="row">
<section class="column">
<div class="container">
<img src="JW-Marriott/isabella-juskova-260419.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="CostaRica.html">JW Marriott Guanacaste</a></div>
</div>
</div>
</section>
<section class="column">
<div class="container">
<img src="La-Plantation/ghost-presenter-423659.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="Mauritius.html">La Plantation d'Albion</a></div>
</div>
</div>
</section>
</section>
<section class="row">
<section class="column">
<div class="container">
<img src="Les-Boucaniers/mathieu-de-gouville-218862.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="Carribean.html">Les Boucaniers</a></div>
</div>
</div>
</section>
<section class="column">
<div class="container">
<img src="Salinas-Do-Maragogi/agustin-diaz-185846.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="Brazil.html">Salinas Do Maragogi</a></div>
</div>
</div>
</section>
</section>
<section class="row">
<section class="column">
<div class="container">
<img src="Savoy/stephane-juban-275330.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="Seychelles.html">Savoy Reosort & Spa</a></div>
</div>
</div>
</section>
<section class="column">
<div class="container">
<img src="Walt-Disney/thomas-kelley-91838.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><a href="America.html">Walt Disney Florida</a></div>
</div>
</div>
</section>
</section>
<footer class="copyright"><!--Another footer is used to group information about the author and my social media link at the bottom of the page-->
©2017 - <strong>Created by <a href="http://critichub.herokuapp.com">Cyril Kofi Asomani</a></strong>
</footer>
<script>
$(document).ready(function(){
/*I had to move the code into script tags since I was having issues when On this page The elements with one of the three classes below makes those elements draggable*/
$(".container, .text, .image").draggable({helper:"clone",
revert:true,
drag:function(){
$(this).addClass("active");
},
stop:function(){
$(this).removeClass("active");
},
hoverClass:"hover",
activeClass:"active",
tolerance:"touch"
});
/*Once the holiday name is dropped into our favourite list not only is it given a button it is added to the local storage.*/
$("#favourite").droppable({
drop:function(event,ui){
try{
var addLocation = ui.draggable.text();
var file = JSON.parse(localStorage.getItem("Favourites"));
console.log(file);
if(file == null || file == undefined){
file = [];
}
for(i in file){
if(file[i] == addLocation){
alert("Already a Favourite");
return;
}
}
file.push(addLocation);
localStorage.setItem("Favourites",JSON.stringify(file));
}catch(e){
var QUOTA_EXCEEDED_ERR = e.name;
if(e == QUOTA_EXCEEDED_ERR){
console.log("Unable to save to file");
}else{
console.log("Unable to save to file");
console.log(file);
console.log(e);
}}
$("#resorts").append("<li>"
+ui.draggable.text()
+'<button class="delete">X</button>'
+"</li>" );
$("button").button();
/*The event listener below will remove the resort name from the list aswell as the local storage*/
$("#favourite ul li button.delete").on("click",function(){
var user = $(this).closest("li").text();
if(file == null || file != null){
file = [];
}
for (var i = 0; i < file.length; i++) {
if(file[i] == user){
file.splice(i,1);
break;
}
}
localStorage.setItem("Favourites", file);
$(this).closest("li").remove();
});
}
});
$("#clear").button();
/*After making my clear button a jquery widget an eventlistener is attached to the button which will clear my unordered list aswell as remove all favourites from the local storage*/
$("#clear").on("click",function(){
localStorage.removeItem("Favourites");
$("#resorts").empty();
});
});
</script>
</body>
</html>