Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
90d4d639
Commit
90d4d639
authored
May 25, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
list updated
parent
15bb7498
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
50 deletions
+31
-50
dataRetrieval.js
catalog/static/js/dataRetrieval.js
+28
-48
base_top.html
catalog/templates/base_top.html
+2
-1
views.py
catalog/views.py
+1
-1
No files found.
catalog/static/js/dataRetrieval.js
View file @
90d4d639
...
@@ -95,55 +95,66 @@ var makeRequest = function (value) {
...
@@ -95,55 +95,66 @@ var makeRequest = function (value) {
function
drawPolygon
(
element
)
{
function
drawPolygon
(
element
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
if
(
polygon
.
id
===
element
.
id
)
{
if
(
polygon
.
id
===
element
.
id
)
{
// remove prev polygon
// remove prev polygon
osmap
.
removePolygon
();
osmap
.
removePolygon
();
// format coords to draw
// format coords to draw
var
coords
=
osmap
.
formatCoords
(
polygon
.
geojson
.
geometry
.
coordinates
);
var
coords
=
osmap
.
formatCoords
(
polygon
.
geojson
.
geometry
.
coordinates
);
// get the biggest area
// get the biggest area
var
biggest
=
osmap
.
getBiggestPolygon
(
coords
);
var
biggest
=
osmap
.
getBiggestPolygon
(
coords
);
// draw coordsR
// draw coordsR
osmap
.
addPolygon
(
biggest
);
osmap
.
addPolygon
(
biggest
);
}
}
})
})
}
}
$
(
'#ajax-input'
).
focus
(
function
()
{
$
(
'#ajax-input'
).
focus
(
function
()
{
console
.
log
(
'in'
);
console
.
log
(
'in'
);
if
(
OPT_LIST_IS_HIDDEN
&&
$
(
this
).
val
()
!=
''
)
{
if
(
OPT_LIST_IS_HIDDEN
&&
$
(
this
).
val
())
{
$
(
'#option-list'
).
show
();
$
(
'#option-list'
).
show
();
OPT_LIST_IS_HIDDEN
=
false
;
OPT_LIST_IS_HIDDEN
=
false
;
}
}
}).
blur
(
function
()
{
}).
blur
(
function
()
{
if
(
!
OPT_LIST_IS_HIDDEN
&&
$
(
this
).
val
()
!=
''
&&
$
(
event
.
target
).
closest
(
'#option-list'
).
length
)
{
if
(
!
OPT_LIST_IS_HIDDEN
&&
$
(
this
).
val
()
&&
$
(
event
.
target
).
closest
(
'#option-list'
).
length
)
{
$
(
'#option-list'
).
hide
();
$
(
'#option-list'
).
hide
();
OPT_LIST_IS_HIDDEN
=
true
;
OPT_LIST_IS_HIDDEN
=
true
;
}
}
});
});
$
(
'#polygon-list'
).
click
(
function
()
{
$
(
'#option-list'
).
hide
();
OPT_LIST_IS_HIDDEN
=
true
;
$
(
'#ajax-input'
).
value
=
$
(
this
)
});
$
(
document
).
click
(
function
(
event
)
{
$
(
document
).
click
(
function
(
event
)
{
if
(
!
OPT_LIST_IS_HIDDEN
)
{
if
(
!
OPT_LIST_IS_HIDDEN
)
{
//if click is triggered outside '#option-list' element remove the list
//if click is triggered outside '#option-list' element remove the list
if
(
!
$
(
event
.
target
).
closest
(
'#option-list'
).
length
>
0
)
{
if
(
!
$
(
event
.
target
).
closest
(
'#option-list'
).
length
>
0
)
{
$
(
'#option-list'
).
hide
();
$
(
'#option-list'
).
hide
();
OPT_LIST_IS_HIDDEN
=
true
;
OPT_LIST_IS_HIDDEN
=
true
;
}
}
}
}
});
});
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
var
pol_element
=
document
.
getElementById
(
'polygon-list'
);
var
pol_element
=
document
.
getElementById
(
'polygon-list'
);
$
(
'#ajax-input'
).
on
(
'input'
,
function
(
e
)
{
var
typingTimer
;
var
typingInterval
=
800
;
//milliseconds
// On keyup, start the contdown
$
(
'#ajax-input'
).
on
(
'input'
,
function
()
{
var
value
=
$
(
'#ajax-input'
).
val
();
clearTimeout
(
typingTimer
);
var
value
=
$
(
this
).
val
();
if
(
value
)
{
if
(
value
===
''
)
{
typingTimer
=
setTimeout
(
makeRequest
.
bind
(
null
,
value
),
typingInterval
);
}
else
{
$
(
'#option-list'
).
hide
();
$
(
'#option-list'
).
hide
();
while
(
pol_element
.
firstChild
)
{
while
(
pol_element
.
firstChild
)
{
...
@@ -154,36 +165,5 @@ $(document).ready(function () {
...
@@ -154,36 +165,5 @@ $(document).ready(function () {
return
return
}
}
// console.log("TOKEN: ", document.getElementsByName('csrfmiddlewaretoken')[0].value);
makeRequest
(
value
);
// $.ajax({
// type: "POST",
// url: "http://localhost:8080/catalog/searchsubmit/",
// data: {
// 'csrfmiddlewaretoken': document.getElementsByName('csrfmiddlewaretoken')[0].value,
// 'value': value
// },
// dataType: 'json',
// success: function(data) {
// console.log("DATA: ", data.polygonList);
// while (pol_element.firstChild) {
// pol_element.removeChild(pol_element.firstChild);
// }
// data.polygonList.forEach(function (polygon) {
// $('#polygon-list').append('<a href="#"><li class="pol">' + polygon.city + ", " + polygon.state + '</li></a>');
// });
// if (OPT_LIST_IS_HIDDEN) {
// $('#option-list').show();
// OPT_LIST_IS_HIDDEN = false;
// }
// }
// });
});
});
});
// $('#option-list').focusout(function () {
// $(this).hide();
// });
});
\ No newline at end of file
catalog/templates/base_top.html
View file @
90d4d639
...
@@ -194,8 +194,9 @@
...
@@ -194,8 +194,9 @@
<!-- AdminLTE App -->
<!-- AdminLTE App -->
<script
src=
"{% static 'adminlte/dist/js/adminlte.min.js' %}"
></script>
<script
src=
"{% static 'adminlte/dist/js/adminlte.min.js' %}"
></script>
{% block scripts %}{% endblock %}
<script
src=
"{% static 'js/dataRetrieval.js' %}"
type=
"text/javascript"
></script>
<script
src=
"{% static 'js/dataRetrieval.js' %}"
type=
"text/javascript"
></script>
{% block scripts %}{% endblock %}
</body>
</body>
</html>
</html>
catalog/views.py
View file @
90d4d639
...
@@ -30,7 +30,7 @@ def map(request):
...
@@ -30,7 +30,7 @@ def map(request):
form
=
ASFSearchForm
(
request
.
POST
)
form
=
ASFSearchForm
(
request
.
POST
)
# Render the HTML template index.html with the data in the context variable
# Render the HTML template index.html with the data in the context variable
return
render
(
request
,
'map.html'
,{
"searchForm"
:
form
})
return
render
(
request
,
'map.html'
,
{
"searchForm"
:
form
})
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
def
productList
(
request
):
def
productList
(
request
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment