Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Development_of_Web_Applications
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silas Meister
Development_of_Web_Applications
Commits
53a79d50
Commit
53a79d50
authored
1 year ago
by
Silas Meister
Browse files
Options
Downloads
Patches
Plain Diff
Enable searching and display results
parent
f80ead03
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
functions.js
+19
-2
19 additions, 2 deletions
functions.js
php/Index.php
+1
-2
1 addition, 2 deletions
php/Index.php
php/NewsFetch.php
+4
-1
4 additions, 1 deletion
php/NewsFetch.php
styles.css
+2
-1
2 additions, 1 deletion
styles.css
with
26 additions
and
6 deletions
functions.js
+
19
−
2
View file @
53a79d50
...
@@ -49,10 +49,27 @@ function fetchNews(searchWord) {
...
@@ -49,10 +49,27 @@ function fetchNews(searchWord) {
}
}
function
displaySearchResults
(
json
)
{
function
displaySearchResults
(
json
)
{
let
searchResults
=
document
.
getElementById
();
const
searchResults
=
document
.
getElementById
(
'
search-results
'
);
searchResults
.
innerText
=
""
;
json
.
forEach
((
news
)
=>
{
json
.
forEach
((
news
)
=>
{
console
.
log
(
news
[
'
title
'
]);
let
child
=
createNewsChild
(
news
);
searchResults
.
appendChild
(
child
);
});
});
const
display
=
json
.
length
===
0
?
"
none
"
:
"
block
"
;;
searchResults
.
style
.
display
=
display
;
}
function
createNewsChild
(
news
)
{
let
a
=
document
.
createElement
(
'
a
'
);
let
textNode
=
document
.
createTextNode
(
news
[
'
title
'
]);
a
.
appendChild
(
textNode
);
return
a
;
}
}
function
slideImage
()
{
function
slideImage
()
{
...
...
This diff is collapsed.
Click to expand it.
php/Index.php
+
1
−
2
View file @
53a79d50
...
@@ -68,8 +68,7 @@ class Index extends Page {
...
@@ -68,8 +68,7 @@ class Index extends Page {
<input id="search-input" name="search-input" type="search" placeholder="Search" />
<input id="search-input" name="search-input" type="search" placeholder="Search" />
<input id="search-button" type="button" value="" />
<input id="search-button" type="button" value="" />
</form>
</form>
<div class="search-results">
<div id="search-results">
<p>sdfdsfsdfasfdasfasfas</p>
</div>
</div>
</li>
</li>
<li><img src="../img/share_icon.png" alt="" /></li>
<li><img src="../img/share_icon.png" alt="" /></li>
...
...
This diff is collapsed.
Click to expand it.
php/NewsFetch.php
+
4
−
1
View file @
53a79d50
...
@@ -26,9 +26,12 @@ class NewsFetch extends Page
...
@@ -26,9 +26,12 @@ class NewsFetch extends Page
{
{
$data
=
array
();
$data
=
array
();
if
(
empty
(
trim
(
$this
->
searchWord
)))
return
$data
;
$likeSearchWord
=
"%"
.
$this
->
searchWord
.
"%"
;
$likeSearchWord
=
"%"
.
$this
->
searchWord
.
"%"
;
$stmt
=
$this
->
database
->
prepare
(
"SELECT n.title FROM news n WHERE n.title LIKE
?
LIMIT 5"
);
$stmt
=
$this
->
database
->
prepare
(
"SELECT n.title FROM news n WHERE
LOWER(
n.title
)
LIKE
LOWER(?)
LIMIT 5"
);
$stmt
->
bind_param
(
"s"
,
$likeSearchWord
);
$stmt
->
bind_param
(
"s"
,
$likeSearchWord
);
$stmt
->
execute
();
$stmt
->
execute
();
$resultSet
=
$stmt
->
get_result
();
$resultSet
=
$stmt
->
get_result
();
...
...
This diff is collapsed.
Click to expand it.
styles.css
+
2
−
1
View file @
53a79d50
...
@@ -113,7 +113,8 @@ a {
...
@@ -113,7 +113,8 @@ a {
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.search-results
{
#search-results
{
display
:
none
;
position
:
absolute
;
position
:
absolute
;
background-color
:
#333333
;
background-color
:
#333333
;
opacity
:
0.9
;
opacity
:
0.9
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment