Skip to content

Commit 3905aa3

Browse files
committed
Add Search to Quests
1 parent 23c169b commit 3905aa3

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

add_mons.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ class="form-control text-center">
384384
</button>
385385
</div>
386386

387-
<!-- Add Search Box -->
387+
<!-- Add Search Box -->
388+
<input type='hidden' id='search_type' value='mon'>
388389
<div class='mb-3' id='dvSearchBox'>
389390
<input type='text' class='form-control form-control-lg' id='search' placeholder='Search'>
390391
</div>

add_quests.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<link rel="stylesheet" type="text/css" href="css/style.css?v=<?=time();?>">
3131

3232
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
33+
<script type="text/javascript" src="search_mons.js"></script>
3334

3435
<script type="text/javascript">
3536
$(document).ready(function() {
@@ -51,6 +52,7 @@
5152
}
5253
});
5354
});
55+
5456
</script>
5557

5658
</head>
@@ -179,7 +181,7 @@ class="form-control text-center">
179181
<nav aria-label="breadcrumb">
180182
<ol class="breadcrumb">
181183
<li class="breadcrumb-item active" aria-current="page">
182-
Select Pokémon Quests you want to add
184+
Select Pokémon Quests you want to add (Pokemons Currently available on Map)
183185
</li>
184186
</ol>
185187
</nav>
@@ -204,6 +206,28 @@ class="form-control text-center">
204206
</ul>
205207
</div>
206208

209+
<!-- Add Search Box -->
210+
<nav aria-label="breadcrumb">
211+
<ol class="breadcrumb">
212+
<li class="breadcrumb-item active" aria-current="page">
213+
Or use search below to add another pokemon
214+
</li>
215+
</ol>
216+
</nav>
217+
218+
<input type='hidden' id='search_type' value='questmon'>
219+
<div class='mb-3' id='dvSearchBox'>
220+
<input type='text' class='form-control form-control-lg' id='search' placeholder='Search'>
221+
</div>
222+
223+
<div class='searchmons text-center' id='dvMonsList'>
224+
<ul>
225+
<!-- Add Empty Div to be used by Ajax to display results -->
226+
<div id='display'></div>
227+
228+
</ul>
229+
</div>
230+
207231
<hr>
208232

209233
<nav aria-label="breadcrumb">

search_mons.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $(document).ready(function() {
1111
$("#search").keyup(function() {
1212
//Assigning search box value to javascript variable named as "name".
1313
var name = $('#search').val();
14+
var type = $('#search_type').val();
1415
//Validating, if "name" is empty.
1516
if (name == "") {
1617
//Assigning empty value to "display" div in "search.php" file.
@@ -27,7 +28,8 @@ $(document).ready(function() {
2728
//Data, that will be sent to "add_mons.php".
2829
data: {
2930
//Assigning value of "name" into "search" variable.
30-
search: name
31+
search: name,
32+
searchtype: type
3133
},
3234
//If result found, this funtion will be called.
3335
success: function(html) {

search_mons.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
<?php
33

44
include "./functions.php";
5+
include "./db_mad.php";
56
include "./config.php";
67

7-
$mons=get_all_mons();
8+
$mons=get_all_mons();
9+
10+
if ( $_POST['searchtype'] == "questmon" ) {
11+
$quests_mons=get_quest_mons();
12+
foreach($quests_mons as $key => $pokemon_id) {
13+
unset($mons[$pokemon_id]);
14+
}
15+
}
816

917
foreach($mons as $pokemon_id => $pokemon_name) {
1018
if ($pokemon_id <= $max_pokemon) {

0 commit comments

Comments
 (0)