var $,ajaxify,ajaxrequest,buildpage,disable_links,exports,pagination;$=jQuery;exports=this;exports.setitems_url=setitems_url;disable_links=function(e){if(exports.inprogress)e.preventDefault();return 1;};pagination=function(data){var html,linkpage,rows,tmpl,_i,_len,_ref;if(data.items.length){rows=[];if(data.next_page!==data.first_page&&data.page!==data.first_page)rows.push('<span><a href="/settings/{{first_page}}"><img src="{{media_url}}/imgs/first_pager.png" alt="first" title="first" /></a></span><span>...</span>');if(data.previous_page)rows.push('<span><a href="/settings/{{previous_page}}"><img src="{{media_url}}/imgs/previous_pager.png" alt="prev" title="prev" /></a></span>');_ref=data.page_nums;for(_i=0,_len=_ref.length;_i<_len;_i++){linkpage=_ref[_i];if(linkpage===data.page)rows.push('<span class="curpage">{{page}}</span>');else rows.push('<span><a href="/settings/'+linkpage+'">'+linkpage+'</a></span>');}if(data.next_page)rows.push('<span><a href="/settings/{{next_page}}"><img src="{{media_url}}/imgs/next_pager.png" alt="next" title="next" /></a></span>');if(data.next_page!==data.page_count&&data.page!==data.page_count&&data.page_count!==0)rows.push('<span>...</span><span><a href="/settings/{{last_page}}"><img src="{{media_url}}/imgs/last_pager.png" alt="last" title="last" /></a></span>');tmpl=rows.join('\n');html=$.mustache(tmpl,data);}else html='-';return html;};ajaxify=function(e,url){e.preventDefault();$.address.value(url.replace(/\.json/,''));$.address.history($.address.baseURL()+url);ajaxrequest(url);return 1;};buildpage=function(data){var pages_html,pages_tmpl,replacement,row,rows,title_html,title_tmpl;row='<tr><td class="scanners_hash">&nbsp;</td><td class="scanners_name">{{hostname}}</td>'+'<td class="scanners_status"><img src="{{media_url}}{{statusimg}}" alt="" /></td>'+'<td class="scanners_action_settings"><a href="/settings/node/{{id}}/section/1"><img src="{{media_url}}imgs/cog.png" alt="Settings"></a></td>'+'<td class="scanners_action_edit"><a href="/settings/node/edit/{{id}}"><img src="{{media_url}}imgs/edit.png" alt="Edit"></a></td>'+'<td class="scanners_action_delete"><a href="/settings/node/delete/{{id}}"><img src="{{media_url}}imgs/action_delete.png" alt="Delete"></a></td></tr>';if(data.items){rows=[];$.each(data.items,function(i,n){var html;n.media_url=exports.media_url;html=$.mustache(row,n);return rows.push(html);});replacement=rows.join('');}else replacement='<tr><td colspan="5" class="spanrow">'+gettext('No scanning hosts found')+'</td></tr>';$('div.pages').html(pagination(data));$('tbody').empty().append(replacement);if(data.items.length){pages_tmpl=gettext('Showing items {{first_item}} to {{last_item}} of {{item_count}}.');pages_html=$.mustache(pages_tmpl,data);title_tmpl=gettext('Settings :: Nodes :: Showing page {{page}} of {{page_count}} pages.');title_html=$.mustache(title_tmpl,data);}else{pages_html=gettext('No items found');title_html=gettext('Settings :: Nodes');}$('div.toolbar p').html(pages_html);$('#title').html(title_html);$.address.title('.:. Baruwa :: '+title_html);return $('div.pages a').click(function(e){var url;url=$(this).attr('href')+'.json';return ajaxify(e,url);});};ajaxrequest=function(url){if(!$('#shield').length)$('#wrap').after(exports.loading);else $('#shield').show();return $.ajax(url,{type:'GET',cache:false,dataType:'json',success:buildpage});};$(document).ready(function(){exports.inprogress=false;$('div.pages a').click(function(e){var url;url=$(this).attr('href')+'.json';return ajaxify(e,url);});$('thead a').click(function(e){var url;url=$(this).attr('href')+'.json';return ajaxify(e,url);});$('html').ajaxStart(function(){return exports.inprogress=true;}).ajaxError(display_global_ajax_error).ajaxComplete(function(){exports.inprogress=false;$('#shield').hide();if($(window).scrollTop())return $('html,body').animate({scrollTop:$("#header-bar").offset().top},1500);}).ajaxSuccess(function(){if($('#alertmsg').length){$('#alertmsg').empty();return $('#alertmsg').remove();}});$('a').click(disable_links);$.address.externalChange(function(e){var url;if(e.path==='/'){$.address.history($.address.baseURL());return;}url=$.address.value()+'.json';return ajaxify(e,url);});return $('#statusnumitemstop, #statusnumitemsbottom').change(function(){var n;n=$(this).val();return location.href=""+exports.setitems_url+"?n="+n;});});