forked from biswaz/rescuekerala
-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move script and style to external file
- Loading branch information
1 parent
280d348
commit b795c6b
Showing
3 changed files
with
122 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const iDist = 1 | ||
const iLoc = 2 | ||
const iRequestee = 3 | ||
const iContact = 4 | ||
const iDate = 5 | ||
const iGps = 6 | ||
const iSummary = 7 | ||
|
||
$("input.search").keyup(search); | ||
$(".show-details").click(showDetails); | ||
|
||
function showDetails(evt) { | ||
var tds = $(evt.target).parent().siblings() | ||
var dist = tds.eq(iDist).text().toLowerCase() | ||
var loc = tds.eq(iLoc).text().toLowerCase() | ||
var requestee = tds.eq(iRequestee).text().toLowerCase() | ||
var phone = tds.eq(iContact).html() | ||
var date = tds.eq(iDate).text() | ||
var gps = tds.eq(iGps).html() | ||
var summary = tds.eq(iSummary).html() | ||
|
||
$("#req-dist").text(dist) | ||
$("#req-loc").text(loc) | ||
$("#req-requestee").text(requestee) | ||
$("#req-contact").html(phone) | ||
$("#req-date").text(date) | ||
$("#req-gps").html(gps) | ||
$("#req-summary").html(summary) | ||
|
||
$("#req-details").modal("show") | ||
} | ||
|
||
function search() { | ||
$("#req-table").find("tr").each(function(i,el) { | ||
// skip header row | ||
if (i == 0) return | ||
el = $(el) | ||
var tds = el.find("td") | ||
var loc = tds.eq(iLoc).text().toLowerCase() | ||
var requestee = tds.eq(iRequestee).text().toLowerCase() | ||
var phone = tds.eq(iContact).text() | ||
var locKey = $("#search-loc").val().toLowerCase() | ||
var reqKey = $("#search-requestee").val().toLowerCase() | ||
var phoneKey = $("#search-phone").val() | ||
|
||
if (loc.includes(locKey) && | ||
requestee.includes(reqKey) && | ||
phone.includes(phoneKey)) | ||
{ | ||
el.show() | ||
} else { | ||
el.hide() | ||
} | ||
}) | ||
} |