Skip to content
This repository has been archived by the owner on Aug 6, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from mickle00/master
Browse files Browse the repository at this point in the history
Search Record Details by Field API Name
  • Loading branch information
capeterson committed Jul 15, 2013
2 parents 8d716bd + 59f24c8 commit 56b01e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</div>
</div>
<div id="tab-record">
Field Search: <input id="search"/>
<ul>
<li>
Currently viewing record: <span id="currentRecordId">UNDEFINED</span>
Expand Down
32 changes: 30 additions & 2 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var gatherRecordInfo = function(){
for(var i = 0; i < record.fields.length; i++){
var field = record.fields[i];
console.log("Field: ",field);
$('#fieldTable > tbody:last').append("<tr><td>"+field.name+"</td><td>"+field.label+"</td><td class=\"record-data\">"+escapeHtml(record.values[field.name])+"</td></tr>");
$('#fieldTable > tbody:last').append("<tr id='" + field.name.toLowerCase() + "'><td>"+field.name+"</td><td>"+field.label+"</td><td class=\"record-data\">"+escapeHtml(record.values[field.name])+"</td></tr>");
}
}

Expand All @@ -61,6 +61,7 @@ var invalidateSession = function(){
}

$(document).ready(function() {
document.getElementById('search').addEventListener('keyup', filterFields);
$(function() {
$( "#tabs" ).tabs();
$( "#tabs" ).bind(
Expand Down Expand Up @@ -143,4 +144,31 @@ var populateCRUD = function(recordId){
console.log('populating data for describe');
console.log(describe);
$('#CRUD > tbody:last').after('<tr><td>'+describe.createable+'</td><td>'+describe.queryable+'</td><td>'+describe.updateable+'</td><td>'+describe.deletable+'</td></tr>');
}
}

var filterFields = function(){
var searchText = $('#search').val().toLowerCase();
if (searchText === '') {
showAll();
} else {
hideFields(searchText);
showFields(searchText);
}
}

var showAll = function(){
$('tr').each(function(){
$(this).show();
});
}

var hideFields = function(searchText){
$('tr:not([id*="' + searchText + '"])').each(function(){
$(this).hide();
});
}
var showFields = function(searchText){
$('tr[id*="' + searchText + '"]').each(function(){
$(this).show();
});
}

0 comments on commit 56b01e8

Please sign in to comment.