Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProjectClient_Y1S1_tramshedTech_team15
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Arianne Bayliss
ProjectClient_Y1S1_tramshedTech_team15
Commits
00746bd1
Commit
00746bd1
authored
2 years ago
by
Liam Driscoll
Browse files
Options
Downloads
Patches
Plain Diff
Adding (unimplemented) buttons to HTML/JS.
parent
3d6972c8
No related branches found
No related tags found
1 merge request
!34
Resolve "As a moderator, I want to be able to add new locations/spaces/features."
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
static/JS/Manage_Coworking_Spaces.js
+115
-1
115 additions, 1 deletion
static/JS/Manage_Coworking_Spaces.js
static/Manage_Coworking_Spaces.html
+6
-4
6 additions, 4 deletions
static/Manage_Coworking_Spaces.html
with
121 additions
and
5 deletions
static/JS/Manage_Coworking_Spaces.js
+
115
−
1
View file @
00746bd1
// Replaces the onSubmit attribute for the addRecord form.
// Replaces the onSubmit attribute for the addRecord form.
function
onSubmitLoad
()
{
function
onSubmitLoad
()
{
document
.
getElementById
(
'
searchButton
'
).
addEventListener
(
'
click
'
,
searchRecord
);
document
.
getElementById
(
'
addButton
'
).
addEventListener
(
'
click
'
,
addRecord
);
document
.
getElementById
(
'
addButton
'
).
addEventListener
(
'
click
'
,
addRecord
);
document
.
getElementById
(
'
editButton
'
).
addEventListener
(
'
click
'
,
editRecord
);
document
.
getElementById
(
'
deleteButton
'
).
addEventListener
(
'
click
'
,
deleteRecord
);
}
}
function
headerLoad
()
{
function
headerLoad
()
{
...
@@ -31,12 +34,50 @@ function pageLoad() {
...
@@ -31,12 +34,50 @@ function pageLoad() {
headerLoad
();
headerLoad
();
}
}
// Adds a record to the CSV file.
// Searches for a record in the database.
function
searchRecord
(
e
)
{
// Removes the standard form processing.
e
.
preventDefault
();
e
.
stopPropagation
();
// Assigning form element values to variables.
var
recordName
=
document
.
getElementById
(
"
recordName
"
).
value
;
var
recordAddress
=
document
.
getElementById
(
"
recordAddress
"
).
value
;
var
recordMainPhotos
=
document
.
getElementById
(
"
recordMainPhotos
"
).
value
;
var
recordAdditionalPhotos
=
document
.
getElementById
(
"
recordAdditionalPhotos
"
).
value
;
var
recordDescription
=
document
.
getElementById
(
"
recordDescription
"
).
value
;
var
recordWebsite
=
document
.
getElementById
(
"
recordWebsite
"
).
value
;
var
recordEmail
=
document
.
getElementById
(
"
recordEmail
"
).
value
;
var
recordPhoneNumber
=
document
.
getElementById
(
"
recordPhoneNumber
"
).
value
;
var
recordOpeningHours
=
document
.
getElementById
(
"
recordOpeningHours
"
).
value
;
var
recordCheckinInstructions
=
document
.
getElementById
(
"
recordCheckinInstructions
"
).
value
;
// Creating a form data-type to transfer multiple parameters to the server.
var
params
=
'
recordName=
'
+
recordName
+
'
&recordAddress=
'
+
recordAddress
+
'
&recordMainPhotos=
'
+
recordMainPhotos
+
'
&recordAdditionalPhotos=
'
+
recordAdditionalPhotos
+
'
&recordDescription=
'
+
recordDescription
+
'
&recordWebsite=
'
+
recordWebsite
+
'
&recordEmail=
'
+
recordEmail
+
'
&recordPhoneNumber=
'
+
recordPhoneNumber
+
'
&recordOpeningHours=
'
+
recordOpeningHours
+
'
&recordCheckinInstructions=
'
+
recordCheckinInstructions
;
var
xhttp
=
new
XMLHttpRequest
();
xhttp
.
open
(
"
POST
"
,
'
/SearchRecord
'
,
true
);
xhttp
.
setRequestHeader
(
"
Content-type
"
,
"
application/x-www-form-urlencoded
"
);
xhttp
.
onreadystatechange
=
function
()
{
if
(
xhttp
.
readyState
===
4
&&
xhttp
.
status
===
200
)
{
console
.
log
(
xhttp
.
responseText
);
document
.
getElementById
(
"
DEBUGserverMessage
"
).
innerHTML
=
xhttp
.
responseText
;
}
else
{
console
.
error
(
`Status Text:
${
xhttp
.
statusText
}
.`
);
console
.
error
(
`Ready State:
${
xhttp
.
readyState
}
.`
);
}
};
xhttp
.
send
(
params
);
}
// Adds a record to the database.
function
addRecord
(
e
)
{
function
addRecord
(
e
)
{
// Removes the standard form processing.
// Removes the standard form processing.
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
stopPropagation
();
// Assigning form element values to variables.
var
recordName
=
document
.
getElementById
(
"
recordName
"
).
value
;
var
recordName
=
document
.
getElementById
(
"
recordName
"
).
value
;
var
recordAddress
=
document
.
getElementById
(
"
recordAddress
"
).
value
;
var
recordAddress
=
document
.
getElementById
(
"
recordAddress
"
).
value
;
var
recordMainPhotos
=
document
.
getElementById
(
"
recordMainPhotos
"
).
value
;
var
recordMainPhotos
=
document
.
getElementById
(
"
recordMainPhotos
"
).
value
;
...
@@ -48,6 +89,7 @@ function addRecord(e) {
...
@@ -48,6 +89,7 @@ function addRecord(e) {
var
recordOpeningHours
=
document
.
getElementById
(
"
recordOpeningHours
"
).
value
;
var
recordOpeningHours
=
document
.
getElementById
(
"
recordOpeningHours
"
).
value
;
var
recordCheckinInstructions
=
document
.
getElementById
(
"
recordCheckinInstructions
"
).
value
;
var
recordCheckinInstructions
=
document
.
getElementById
(
"
recordCheckinInstructions
"
).
value
;
// Creating a form data-type to transfer multiple parameters to the server.
var
params
=
'
recordName=
'
+
recordName
+
'
&recordAddress=
'
+
recordAddress
+
'
&recordMainPhotos=
'
+
recordMainPhotos
+
'
&recordAdditionalPhotos=
'
+
recordAdditionalPhotos
+
'
&recordDescription=
'
+
recordDescription
+
'
&recordWebsite=
'
+
recordWebsite
+
'
&recordEmail=
'
+
recordEmail
+
'
&recordPhoneNumber=
'
+
recordPhoneNumber
+
'
&recordOpeningHours=
'
+
recordOpeningHours
+
'
&recordCheckinInstructions=
'
+
recordCheckinInstructions
;
var
params
=
'
recordName=
'
+
recordName
+
'
&recordAddress=
'
+
recordAddress
+
'
&recordMainPhotos=
'
+
recordMainPhotos
+
'
&recordAdditionalPhotos=
'
+
recordAdditionalPhotos
+
'
&recordDescription=
'
+
recordDescription
+
'
&recordWebsite=
'
+
recordWebsite
+
'
&recordEmail=
'
+
recordEmail
+
'
&recordPhoneNumber=
'
+
recordPhoneNumber
+
'
&recordOpeningHours=
'
+
recordOpeningHours
+
'
&recordCheckinInstructions=
'
+
recordCheckinInstructions
;
var
xhttp
=
new
XMLHttpRequest
();
var
xhttp
=
new
XMLHttpRequest
();
...
@@ -64,3 +106,75 @@ function addRecord(e) {
...
@@ -64,3 +106,75 @@ function addRecord(e) {
};
};
xhttp
.
send
(
params
);
xhttp
.
send
(
params
);
}
}
// Edits a record in the database.
function
editRecord
(
e
)
{
// Removes the standard form processing.
e
.
preventDefault
();
e
.
stopPropagation
();
// Assigning form element values to variables.
var
recordName
=
document
.
getElementById
(
"
recordName
"
).
value
;
var
recordAddress
=
document
.
getElementById
(
"
recordAddress
"
).
value
;
var
recordMainPhotos
=
document
.
getElementById
(
"
recordMainPhotos
"
).
value
;
var
recordAdditionalPhotos
=
document
.
getElementById
(
"
recordAdditionalPhotos
"
).
value
;
var
recordDescription
=
document
.
getElementById
(
"
recordDescription
"
).
value
;
var
recordWebsite
=
document
.
getElementById
(
"
recordWebsite
"
).
value
;
var
recordEmail
=
document
.
getElementById
(
"
recordEmail
"
).
value
;
var
recordPhoneNumber
=
document
.
getElementById
(
"
recordPhoneNumber
"
).
value
;
var
recordOpeningHours
=
document
.
getElementById
(
"
recordOpeningHours
"
).
value
;
var
recordCheckinInstructions
=
document
.
getElementById
(
"
recordCheckinInstructions
"
).
value
;
// Creating a form data-type to transfer multiple parameters to the server.
var
params
=
'
recordName=
'
+
recordName
+
'
&recordAddress=
'
+
recordAddress
+
'
&recordMainPhotos=
'
+
recordMainPhotos
+
'
&recordAdditionalPhotos=
'
+
recordAdditionalPhotos
+
'
&recordDescription=
'
+
recordDescription
+
'
&recordWebsite=
'
+
recordWebsite
+
'
&recordEmail=
'
+
recordEmail
+
'
&recordPhoneNumber=
'
+
recordPhoneNumber
+
'
&recordOpeningHours=
'
+
recordOpeningHours
+
'
&recordCheckinInstructions=
'
+
recordCheckinInstructions
;
var
xhttp
=
new
XMLHttpRequest
();
xhttp
.
open
(
"
POST
"
,
'
/EditRecord
'
,
true
);
xhttp
.
setRequestHeader
(
"
Content-type
"
,
"
application/x-www-form-urlencoded
"
);
xhttp
.
onreadystatechange
=
function
()
{
if
(
xhttp
.
readyState
===
4
&&
xhttp
.
status
===
200
)
{
console
.
log
(
xhttp
.
responseText
);
document
.
getElementById
(
"
DEBUGserverMessage
"
).
innerHTML
=
xhttp
.
responseText
;
}
else
{
console
.
error
(
`Status Text:
${
xhttp
.
statusText
}
.`
);
console
.
error
(
`Ready State:
${
xhttp
.
readyState
}
.`
);
}
};
xhttp
.
send
(
params
);
}
// Deletes a record in the database.
function
deleteRecord
(
e
)
{
// Removes the standard form processing.
e
.
preventDefault
();
e
.
stopPropagation
();
// Assigning form element values to variables.
var
recordName
=
document
.
getElementById
(
"
recordName
"
).
value
;
var
recordAddress
=
document
.
getElementById
(
"
recordAddress
"
).
value
;
var
recordMainPhotos
=
document
.
getElementById
(
"
recordMainPhotos
"
).
value
;
var
recordAdditionalPhotos
=
document
.
getElementById
(
"
recordAdditionalPhotos
"
).
value
;
var
recordDescription
=
document
.
getElementById
(
"
recordDescription
"
).
value
;
var
recordWebsite
=
document
.
getElementById
(
"
recordWebsite
"
).
value
;
var
recordEmail
=
document
.
getElementById
(
"
recordEmail
"
).
value
;
var
recordPhoneNumber
=
document
.
getElementById
(
"
recordPhoneNumber
"
).
value
;
var
recordOpeningHours
=
document
.
getElementById
(
"
recordOpeningHours
"
).
value
;
var
recordCheckinInstructions
=
document
.
getElementById
(
"
recordCheckinInstructions
"
).
value
;
// Creating a form data-type to transfer multiple parameters to the server.
var
params
=
'
recordName=
'
+
recordName
+
'
&recordAddress=
'
+
recordAddress
+
'
&recordMainPhotos=
'
+
recordMainPhotos
+
'
&recordAdditionalPhotos=
'
+
recordAdditionalPhotos
+
'
&recordDescription=
'
+
recordDescription
+
'
&recordWebsite=
'
+
recordWebsite
+
'
&recordEmail=
'
+
recordEmail
+
'
&recordPhoneNumber=
'
+
recordPhoneNumber
+
'
&recordOpeningHours=
'
+
recordOpeningHours
+
'
&recordCheckinInstructions=
'
+
recordCheckinInstructions
;
var
xhttp
=
new
XMLHttpRequest
();
xhttp
.
open
(
"
POST
"
,
'
/DeleteRecord
'
,
true
);
xhttp
.
setRequestHeader
(
"
Content-type
"
,
"
application/x-www-form-urlencoded
"
);
xhttp
.
onreadystatechange
=
function
()
{
if
(
xhttp
.
readyState
===
4
&&
xhttp
.
status
===
200
)
{
console
.
log
(
xhttp
.
responseText
);
document
.
getElementById
(
"
DEBUGserverMessage
"
).
innerHTML
=
xhttp
.
responseText
;
}
else
{
console
.
error
(
`Status Text:
${
xhttp
.
statusText
}
.`
);
console
.
error
(
`Ready State:
${
xhttp
.
readyState
}
.`
);
}
};
xhttp
.
send
(
params
);
}
This diff is collapsed.
Click to expand it.
static/Manage_Coworking_Spaces.html
+
6
−
4
View file @
00746bd1
...
@@ -22,13 +22,12 @@
...
@@ -22,13 +22,12 @@
<li><a
href=
"Manage_Coworking_Spaces.html"
>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
<img
id=
"navImg"
class=
"navImg"
<img
id=
"navImg"
class=
"navImg"
src=
"Media/Tramshed-Logo-Main-White.png"
></img></a></li>
src=
"Media/Tramshed-Logo-Main-White.png"
></img></a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
Left
</a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
Home
</a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
Home
</a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
L
eft
</a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
L
ocations
</a></li>
</ul>
</ul>
<ul
class=
"Right"
>
<ul
class=
"Right"
>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
Hom
e
</a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
Manag
e
</a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
Right
</a></li>
<li><a
href=
"Manage_Coworking_Spaces.html"
>
Login
</a></li>
<li><div
class=
"navHamburger"
>
<li><div
class=
"navHamburger"
>
<span></span>
<span></span>
<span></span>
<span></span>
...
@@ -62,7 +61,10 @@
...
@@ -62,7 +61,10 @@
name=
"record_CI"
type=
"text"
></label>
name=
"record_CI"
type=
"text"
></label>
<br><br>
<br><br>
<button
id=
"searchButton"
type=
"submit"
>
Search
</button>
<button
id=
"addButton"
type=
"submit"
>
Add
</button>
<button
id=
"addButton"
type=
"submit"
>
Add
</button>
<button
id=
"editButton"
type=
"submit"
>
Edit
</button>
<button
id=
"deleteButton"
type=
"submit"
>
Delete
</button>
</form>
</form>
<br>
<br>
<span
id=
"DEBUGserverMessage"
>
</span>
<span
id=
"DEBUGserverMessage"
>
</span>
...
...
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