Skip to content

Instantly share code, notes, and snippets.

@maplpro
Created September 30, 2010 15:04
Show Gist options
  • Save maplpro/604716 to your computer and use it in GitHub Desktop.
Save maplpro/604716 to your computer and use it in GitHub Desktop.
JavaScript templates
infoportal.ui.show_search_result = function ( search_result ) {
t = $.template( $( '#result_template' ).html() )
for ( var r in search_result ) {
$( '#result_table' ).append( t, search_result[ r ] );
if ( r % 2 === 0 ) {
$( '#result tr.resultItem:last' ).addClass( 'odd' );
}
}
$( '#result' ).fadeIn( 1000 );
$( '#result_table' ).fadeIn( 1000 );
};
<div id="result" style="display:none">
<table id="result_table" style="display:none">
<tr>
<th>
</th>
<th class="result_table_hdr">
Accessed
</th>
<th class="result_table_hdr">
Modified
</th>
<th class="result_table_hdr">
Sub-Sites
</th>
<th class="result_table_hdr">
Views
</th>
<th class="result_table_hdr">
Users
</th>
<th class="result_table_hdr">
Size
</th>
<tr>
</table>
</div>
<table id="result_template" style="display:none">
<tr class="resultItem">
<td class="result_data">
<table>
<tr>
<td >
<img class="searchResIcon" src="static/images/site.png">
</td>
<td>
<div class="sa_sub_hdr topSizeHeaderName">
<h2><b>${title}</b><br><a href="${url}">${url}</a></h2>
</div>
</td>
</tr>
<tr> <td/>
<td>
<div style="margin-top:5px;">
<div> <span class="fieldHeader"> Created: </span> ${created} by ${creator}</div>
<div> <span class="fieldHeader"> Aministrators: </span> ${admin1}, ${admin2}</div>
</div>
</td>
</tr>
</table>
</td>
<td class="topSizeCol result_data" >
${last_accessed}
</td>
<th class="topSizeCol result_data">
${last_modified}
</th>
<td class="topSizeCol result_data" >
${subsites}
</td>
<td class="topSizeCol result_data" >
${views}
</td>
<td class="topSizeCol result_data" >
${users}
</td>
<td class="topSizeCol topSizeColLast result_data" >
${size} MB
</td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment