|
1 function articles(json) |
|
2 { |
|
3 $("#pickeddatebegincluster").val(json.query.from_date); |
|
4 $("#pickeddateendcluster").val(json.query.to_date); |
|
5 $("#recherche").val(json.query.text); |
|
6 for (j = 0; j < json.query.categories.length; j++) |
|
7 { |
|
8 if(json.query.categories[j] == "International") |
|
9 { |
|
10 alert('Inter'); |
|
11 $('input[id=categorie1]').attr('checked', true); |
|
12 } |
|
13 else if(json.query.categories[j] == "France") |
|
14 { |
|
15 alert('France'); |
|
16 $('input[id=categorie2]').attr('checked', true); |
|
17 } |
|
18 else if(json.query.categories[j] == "Economie") |
|
19 { |
|
20 alert('Economie'); |
|
21 $('input[id=categorie3]').attr('checked', true); |
|
22 } |
|
23 else |
|
24 { |
|
25 alert('Culture'); |
|
26 $('input[id=categorie4]').attr('checked', true); |
|
27 } |
|
28 } |
|
29 |
|
30 |
|
31 content = "<div class=\"articles\">"; |
|
32 for (i = 0; i < json.documents.length; i++) |
|
33 { |
|
34 content += "<div class=\"article\"><div class=\"inner-article clearfix\"><h2><a id=\""+json.documents[i].id+"\" title=\"Lire l\'article\" href=\""+json.documents[i].url_document+"\">"; |
|
35 content += json.documents[i].title; |
|
36 content += " »</a></h2><p class=\"author\"><a href=\"#\">"; |
|
37 content += json.documents[i].date; |
|
38 content += " </a><br/> by <a href=\"#\">"; |
|
39 content += json.documents[i].author[0].name; |
|
40 content += "</a></p><div class=\"article-content\"><div class=\"article-visuel-wrap\"><img class=\"article-visuel\" src=\"/static/img/visuel-article.jpg\" alt=\"\" /></div><p class=\"resume\">"; |
|
41 content += json.documents[i].abstract; |
|
42 content += " </p></div></div></div>"; |
|
43 } |
|
44 content +="</div>"; |
|
45 $("#right").empty(); |
|
46 $(content).appendTo("#right"); |
|
47 } |
|
48 |
|
49 $(function(){ |
|
50 |
|
51 // Formulaire POST AJAX |
|
52 $("#ajax3").submit( function() |
|
53 { |
|
54 var urlSubmit = $(this).attr('action'); |
|
55 currentcategories = []; |
|
56 /*var data = { 'categories' : []};*/ |
|
57 $("input:checked").each(function() { |
|
58 /*data['categories'].push($(this).val());*/ |
|
59 currentcategories.push($(this).val()); |
|
60 }); |
|
61 currentfromdate= $("#pickeddatebegin").val(); |
|
62 currenttodate= $("#pickeddateend").val(); |
|
63 |
|
64 $.ajax( |
|
65 { |
|
66 type: "POST", |
|
67 url: urlSubmit, |
|
68 data : $(this).serializeArray(), |
|
69 success: function(data) { |
|
70 |
|
71 var json = jQuery.parseJSON(data); |
|
72 |
|
73 content = "<div class=\"articles\">"; |
|
74 for (i = 0; i < json.documents.length; i++) |
|
75 { |
|
76 content += "<div class=\"article\"><div class=\"inner-article clearfix\"><h2><a id=\""+json.documents[i].id+"\" title=\"Lire l\'article\" href=\""+json.documents[i].url_document+"\">"; |
|
77 content += json.documents[i].title; |
|
78 content += " »</a></h2><p class=\"author\"><a href=\"#\">"; |
|
79 content += json.documents[i].date; |
|
80 content += " </a><br/> by <a href=\"#\">"; |
|
81 content += json.documents[i].author[0].name; |
|
82 content += "</a></p><div class=\"article-content\"><div class=\"article-visuel-wrap\"><img class=\"article-visuel\" src=\"/static/img/visuel-article.jpg\" alt=\"\" /></div><p class=\"resume\">"; |
|
83 content += json.documents[i].abstract; |
|
84 content += " </p></div></div></div>"; |
|
85 } |
|
86 content +="</div>"; |
|
87 $("#right").empty(); |
|
88 $(content).appendTo("#right"); |
|
89 } |
|
90 }); |
|
91 return false; |
|
92 }); |
|
93 |
|
94 $('.checkbox_category').click(function(){ |
|
95 /*var theValue = $(this).val();*/ |
|
96 $('#ajax3').submit(); |
|
97 }); |
|
98 |
|
99 });//jQuery |