Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beeMapsoftwebinc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Softweb Inc
beeMapsoftwebinc
Commits
1745dce7
Commit
1745dce7
authored
4 years ago
by
eeonaaah
Browse files
Options
Downloads
Plain Diff
Merge branch 'javascript-comments' into 'staging'
JavaScript comments See merge request
!56
parents
ec546845
e28cdbd5
No related branches found
No related tags found
2 merge requests
!57
Staging
,
!56
JavaScript comments
Pipeline
#5225
passed
4 years ago
Stage: build
Stage: test
Stage: staging
Stage: test-staging
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
static/admin.js
+31
-12
31 additions, 12 deletions
static/admin.js
static/map.js
+28
-7
28 additions, 7 deletions
static/map.js
with
59 additions
and
19 deletions
static/admin.js
+
31
−
12
View file @
1745dce7
...
...
@@ -12,7 +12,7 @@ async function createTable() {
// Removes the old table so only up-to-date data will be shown
if
(
oldTable
)
{
div
.
removeChild
(
old
_t
able
);
div
.
removeChild
(
old
T
able
);
}
// Creates a new table
...
...
@@ -40,7 +40,11 @@ async function createTable() {
}
}
/** Creates the heading row based on suggestion keys */
/**
* Creates the heading row based on suggestion keys
* @param {*} content
* @return {*} heading row
*/
function
createHeadingRow
(
content
)
{
const
tr
=
document
.
createElement
(
'
tr
'
);
...
...
@@ -54,7 +58,11 @@ function createHeadingRow(content) {
return
tr
;
}
/** Creates the heading row based on suggestion values */
/**
* Creates the heading row based on suggestion values
* @param {*} content
* @return {*} content row
*/
function
createContentRow
(
content
)
{
const
id
=
content
[
'
id
'
];
const
tr
=
document
.
createElement
(
'
tr
'
);
...
...
@@ -96,9 +104,11 @@ function createContentRow(content) {
return
tr
;
}
/** Changes the child text node
/**
* Changes the child text node
* to an input field with the value set to the original text.
* Registers a 'focusout' event listener to change the field back to text node.
* @param {*} parent
*/
function
activateEditMode
(
parent
)
{
// If already editing, return
...
...
@@ -125,8 +135,11 @@ function activateEditMode(parent) {
input
.
focus
();
}
/** Removes the input element and sets the parent's text content
* to match the input field's valu
/**
* Removes the input element and sets the parent's text content
* to match the input field's value
* @param {*} input
* @param {*} parent
*/
function
deactivateEditMode
(
input
,
parent
)
{
const
text
=
input
.
value
;
...
...
@@ -134,8 +147,10 @@ function deactivateEditMode(input, parent) {
parent
.
textContent
=
text
;
}
/** Packages the edited entity data into an object
/**
* Packages the edited entity data into an object
* and calls to create a put request to update the data
* @param {*} tr
*/
async
function
saveContent
(
tr
)
{
const
entity
=
{};
...
...
@@ -158,16 +173,20 @@ async function saveContent(tr) {
createTable
();
}
/** Packages the entity data into an object
/**
* Packages the entity data into an object
* and calls to create a delete request
* @param {*} tr
*/
async
function
deleteContent
(
tr
)
{
const
entity
=
{};
// Iterates through every cell on the row,
// and appends the data to the entity object
// with the key parsed from the element's id attribute
// and value from the cell's text content
/*
Iterates through every cell on the row,
and appends the data to the entity object
with the key parsed from the element's id attribute
and value from the cell's text content
*/
for
(
const
node
of
tr
.
childNodes
)
{
const
idString
=
node
.
id
;
if
(
!
node
.
id
)
continue
;
...
...
This diff is collapsed.
Click to expand it.
static/map.js
+
28
−
7
View file @
1745dce7
...
...
@@ -27,6 +27,8 @@ const GreenIcon = L.Icon.extend({
/**
* Adds a green marker to mark a place for a possible suggestion.
* @param {*} map
* @param {*} latlng
*/
function
addSuggestionMarker
(
map
,
latlng
)
{
if
(
!
selectionMarker
)
{
...
...
@@ -59,6 +61,7 @@ function openSuggestionPopup() {
/**
* Creates a form that can be used to submit suggestions
* from inside the popup.
* @return {*} suggestion form
*/
function
createSuggestionForm
()
{
const
form
=
document
.
createElement
(
'
form
'
);
...
...
@@ -116,6 +119,7 @@ function createSuggestionForm() {
* Creates a link with an image
* @param {string} link page to redirect
* @param {string} image button icon
* @return {*} shareButton
*/
function
createShareButton
(
link
,
image
)
{
const
shareButton
=
document
.
createElement
(
'
a
'
);
...
...
@@ -129,6 +133,9 @@ function createShareButton(link, image) {
* Submits the suggested location to server. Updates popup content
* depending on the result. Saves a new marker if addition successful.
* @param {*} name
* @param {*} person
* @param {*} keeper
* @param {*} email
*/
async
function
submitSuggestion
(
name
,
person
,
keeper
,
email
)
{
// Get location data from the selection markers current position
...
...
@@ -155,8 +162,6 @@ async function submitSuggestion(name, person, keeper, email) {
setTimeout
(()
=>
{
addedMarker
.
closePopup
();
// Other information to frontend?
popup
.
setContent
(
updatePopupName
(
suggestion
.
name
));
},
2000
);
}
catch
(
error
)
{
...
...
@@ -168,7 +173,10 @@ async function submitSuggestion(name, person, keeper, email) {
/**
* Saves a new suggestion. This function is called after the server
* responds with a success
* @param {string} name
* @param {*} lat latitude
* @param {*} lng longitude
* @param {*} suggestion name
* @return {*} added marker
*/
function
saveSuggestion
(
lat
,
lng
,
suggestion
)
{
console
.
log
(
suggestion
);
...
...
@@ -187,14 +195,22 @@ function saveSuggestion(lat, lng, suggestion) {
return
addedMarker
;
}
/** Updates popup */
/**
* Updates popup
* @param {*} text
* @return {*} created popup
*/
function
updatePopupContent
(
text
)
{
const
p
=
document
.
createElement
(
'
p
'
);
p
.
textContent
=
text
;
return
p
;
}
/** Updates popup */
/**
* Updates popup
* @param {*} text
* @return {*} created popup
*/
function
updatePopupName
(
text
)
{
const
div
=
document
.
createElement
(
'
div
'
);
const
item
=
document
.
createElement
(
'
h2
'
);
...
...
@@ -224,7 +240,7 @@ async function initializeMarkers() {
const
lat
=
suggestion
.
lat
;
const
lng
=
suggestion
.
lng
;
const
marker
=
addMarker
(
lat
,
lng
);
const
popup
=
L
.
popup
().
setContent
(
updatePopup
Content
(
suggestion
.
name
));
const
popup
=
L
.
popup
().
setContent
(
updatePopup
Name
(
suggestion
.
name
));
marker
.
bindPopup
(
popup
);
});
}
catch
(
e
)
{
...
...
@@ -232,7 +248,12 @@ async function initializeMarkers() {
}
}
/** Adds a marker to the map */
/**
* Adds a marker to the map
* @param {*} lat
* @param {*} lng
* @return {*} marker
*/
function
addMarker
(
lat
,
lng
)
{
const
marker
=
L
.
marker
({
lat
,
lng
}).
addTo
(
map
);
return
marker
;
...
...
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