PageRenderTime 182ms CodeModel.GetById 90ms app.highlight 5ms RepoModel.GetById 86ms app.codeStats 0ms

/kai/public/javascripts/community.js

https://bitbucket.org/bbangert/kai/
JavaScript | 45 lines | 37 code | 3 blank | 5 comment | 1 complexity | e5125b6fde9455dce9be08f326072fad MD5 | raw file
 1$(document).ready(function() {
 2    // Trigger the recent mail list thread loading
 3    var ml = $('#maillist');
 4    ml.html('Loading');
 5    var data = {mode:'json', page:1, q:'list:pylons'};
 6    var searchResults = $.getJSON('http://markmail.org/results.xqy?callback=?', data,
 7        function(data) {
 8            ml.html('');
 9            // If there's no search results, stop here
10            if (!data.search.results) {
11                return false;
12            }
13            
14            // Iterate through the search results adding them dynamically
15            // to the element
16            $.each(data.search.results.result, function(i, val) {
17                var result = $(document.createElement('div')).addClass('result');
18                var link = document.createElement('a');
19                link.href = 'http://markmail.org' + val.url.replace(/\?callback.*?\&/, '?');
20                link.target = '_blank';
21                $(link).html(val.subject);
22                result.append(link);
23                var blurb = $(document.createElement('div')).addClass('blurb');
24                
25                // Pull out just the first 50 words
26                var words = val.blurb.split(' ', limit=25);
27                blurb.html(words.join(' '));
28                result.append(blurb);
29                var meta = $(document.createElement('div')).addClass('meta');
30                meta.html(val.date + ' - ' + val.from);
31                result.append(meta);
32                ml.append(result);
33            });
34            var searchlink = document.createElement('a');
35            searchlink.href = data.search.permalink;
36            searchlink.target = '_blank';
37            $(searchlink).html('View entire mail list');
38            var numresults = $(document.createElement('p'));
39            numresults.addClass('results');
40            numresults.prepend(searchlink);            
41            ml.append(numresults);
42        }
43    );
44    
45});