--- a/alcatel/static/js/recherche.js Mon Jul 22 14:56:35 2013 +0200
+++ b/alcatel/static/js/recherche.js Wed Aug 14 16:36:41 2013 +0200
@@ -1,11 +1,18 @@
-var curentjson = "";
- var typeTri = "treemap";
- var currentfromdate = "07/01/2007";
- var currenttodate = "12/01/2012";
- var currentcategories = [];
+var currentjsonStreamgraph = "";
+var currentjsonTreemap = "";
+var currentText = "";
+var typeTri = "treemap";
+var currentfromdate = "";
+var currenttodate = "";
+var currentcategories = [];
+var firsttimefiltre = true;
+var firsttimerequest = true;
+var currentqueryidtreemap= "";
+var currentqueryidstreamgraph= "";
+var currentuser = "";
- function launchpage(json)
+ /*function launchpage(json)
{
curentjson = json;
if (typeTri == "treemap")
@@ -107,146 +114,264 @@
$(content).appendTo("#right");
}
}
+ */
+ /*function setAffichage(typeTri)
+ {
+ alert(typeTri);
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'typeTri')
+ .attr('value', typeTri)
+ .appendTo('#setAffichage');
+
+ $("#setAffichage").submit();
+ }*/
- $(function(){
+ function setCategories(json)
+ {
+
+ $("#pickeddatebegin").val(json.query.from_date);
+ $("#pickeddateend").val(json.query.to_date);
+ $("#recherche_id").val(json.query.text);
+
+ $('input[name=categories1]').attr('checked', false);
+ $('input[name=categories2]').attr('checked', false);
+ $('input[name=categories3]').attr('checked', false);
+ $('input[name=categories4]').attr('checked', false);
+
+ if(json.query.typeTri == "treemap")
+ {
+ $('#treemapaff').click();
+ }
+
+ if(json.query.typeTri == "liste")
+ {
+ $('#listehref').click();
+ }
-
- $('#recherche_button').click(function() {
+ for (j = 0; j < json.query.categories.length; j++)
+ {
+ if(json.query.categories[j] == "International")
+ {
+ $('input[name=categories1]').attr('checked', true);
+ }
+ else if(json.query.categories[j] == "France")
+ {
+ $('input[name=categories2]').attr('checked', true);
+ }
+ else if(json.query.categories[j] == "Economie")
+ {
+ $('input[name=categories3]').attr('checked', true);
+ }
+ else if(json.query.categories[j] == "Culture")
+ {
+ $('input[name=categories4]').attr('checked', true);
+ }
+ }
+ }
+
+ function updatedossierdoc(json)
+ {
+ //alert('updatedossierdoc'+json.dossierDocs);
+ content="";
+ for (i = 0; i < json.dossierDocs.length ; i++)
+ {
+ content += "<li class=\"clearfix\"> <a href=\"/documentary_files/"
+ content += json.user;
+ content += "/";
+ content += json.dossierDocs[i].id;
+ content += "\"><img src=\"";
+ content += json.dossierDocs[i].url;
+ content += "\" alt=\"\" width=\"50px\" height=\"29px\"/><span class=\"documentaire-texte\"><h3>";
+ content += json.dossierDocs[i].title;
+ content += "</h3><p>";
+ content += json.dossierDocs[i].description;
+ content += "</p></span></a></li>";
+ }
+ //alert(content);
+ $("#mesdossiers").empty();
+ $(content).appendTo("#mesdossiers");
+ }
+
+ function getDossierDocs(user)
+ {
+
+ if(user != "")
+ {
+ window.location.href = "http://localhost:8000/documentary_files/"+user;
+ }
+ else
+ {
+ alert('Vous devez vous connecter.');
+ }
+
+ }
+
+ function launchsearch()
+ {
- $('#from_date').val(currentfromdate);
- $('#to_date').val(currenttodate);
-
- //$['categories'] = array('inter', 'france', 'eco');
-
-
- $.each(currentcategories, function() {
- if(this != undefined)
+ currentfromdate = $("#pickeddatebegin").val();
+ currenttodate = $("#pickeddateend").val();
+ currentText = $("#recherche_id").val();
+ currentcategories =[];
+
+ $("input:checked").each(function() {
+ currentcategories.push($(this).val());
+ });
+
+ $("input:checkbox:not(:checked)").each(function() {
+ currentcategories.push('');
+ });
+
+ if ($("#ajaxtreemap input[name=from_date]").val() != undefined)
+ {
+ $("#ajaxtreemap input[name=from_date]").val(currentfromdate);
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'from_date')
+ .attr('value', currentfromdate)
+ .appendTo('#ajaxtreemap');
+ }
+
+ if ($("#ajaxtreemap input[name=to_date]").val() != undefined)
+ {
+ $("#ajaxtreemap input[name=to_date]").val(currenttodate);
+ }
+ else
{
$('<input />').attr('type', 'hidden')
- .attr('name', 'categories')
- .attr('value', this)
- .appendTo('#ajax1');
- }
-
- });
- /*var i=0;
- $("input[name='categories']").each( function() {
- if(currentcategories[i] != undefined)
- {
- alert(currentcategories[i]);
-
- $(this).attr('value', currentcategories[i]);
+ .attr('name', 'to_date')
+ .attr('value', currenttodate)
+ .appendTo('#ajaxtreemap');
}
- /*else
- {
- return false;
- }*/
- /*i++;
-
- });
-*/
-
- $('#ajax1').submit();
- });
-
- // Formulaire POST AJAX
- $("#ajax1").submit( function()
- {
- var urlSubmit = $(this).attr('action');
- /*var params = [
- {
- name: "adress",
- value: window.location.pathname
- },
- {
- name: "time",
- value: new Date().getTime()
- }
- ];
-
- $.each(currentcategories, function(i,param)
- {
-
-
- $('<input />').attr('type', 'hidden')
- .attr('name', param.name)
- .attr('value', param.value)
- .appendTo('#ajax1');
- });*/
-
-
- $.ajax(
- {
- type: "POST",
- url: urlSubmit,
- data : $(this).serializeArray(),
- success: function(data) {
- var json = jQuery.parseJSON(data);
- var k =1;
- alert(currentfromdate);
- if (typeTri == "treemap")
+ var i=1;
+ $.each(currentcategories, function()
+ {
+ if(this != undefined)
+ {
+ if (firsttimerequest == false)
{
- content = "<div class=\"actus\">";
- for (i = 0; i < json.clusters.length & i<4; i++)
- {
- content += "<a id=\""+json.clusters[i].id+"\" href=\"http://localhost:8000/documents_cluster/"+json.query.query_id+"/"+json.clusters[i].id+"/0/10\"><div class=\"actu\"><img src=\"/static/img/home-visuel-"+k+".jpg\" alt=\"\" /><div class=\"inner-actu\">";
- content += "<h2> ";
- content += json.clusters[i].title;
- content += "</h2></div></div></a>";
- k++;
- }
- content +="</div>";
+ $("#ajaxtreemap input[name=categories"+i+"]").val(this);
+ i++;
}
else
{
- content = "<div class=\"articles\">";
- for (i = 0; i < json.clusters.length && i<4; i++)
- {
- content += "<div name=\"cluster_id\" class=\"article\" id=\""+json.clusters[i].id+"\"><div class=\"inner-article clearfix\"><h2><a title=\"Lire l\'article\" id=\""+json.clusters[i].id+"\" href=\"http://localhost:8000/documents_cluster/"+json.query.query_id+"/"+json.clusters[i].id+"/0/10\">";
- content += json.clusters[i].title;
- content += "</a></h2><p class=\"number-article\"><a href=\"#\">";
- content += json.clusters[i].documents_number;
- content +=" articles | ";
- content += json.clusters[i].annotations.length;
- content += " annotations </a><a title=\"ajouter une annotation\" class=\"add-annotation\" href=\"#\"></a></p> <div class=\"article-annotations\"><a title=\"title\" class=\"blue\" href=\"#\" style=\"width:20%;\"></a><a title=\"title\" class=\"green\" href=\"#\" style=\"width:20%;\"></a><a title=\"title\" class=\"red\" href=\"#\" style=\"width:40%;\"></a><a title=\"title\" class=\"empty\" href=\"#\" style=\"width:20%;\"></a></div><div class=\"article-content\">";
- content +="<div class=\"article-visuel-wrap\"><img class=\"article-visuel\" src=\"/static/img/visuel-article.jpg\" alt=\"\" /></div>";
- content +="<p class=\"resume\">";
- content += json.clusters[i].abstract;
- content += "</p><ul class=\"articlelinks\"><ul>";
-
- for (j = 0; j < json.clusters[i].documents.length; j++)
- {
- content += "<li><a href=\"\" id=\""+json.clusters[i].documents[j].id+"\">";
- content += json.clusters[i].documents[j].title;
- content += "</a></li>";
- }
- content +="</ul></ul>";
- content +="</div></div></div>";
- }
- content +="</div>";
+
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'categories'+i)
+ .attr('value', this)
+ .appendTo('#ajaxtreemap');
+ i++;
}
- $("#right").empty();
- $(content).appendTo("#right");
- curentjson = json;
+ }
+
+ });
+
+
+
+ if ($("#ajaxstreamgraph input[name=from_date]").val() != undefined)
+ {
+ $("#ajaxstreamgraph input[name=from_date]").val(currentfromdate);
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'from_date')
+ .attr('value', currentfromdate)
+ .appendTo('#ajaxstreamgraph');
+ }
+
+ if ($("#ajaxstreamgraph input[name=to_date]").val() != undefined)
+ {
+ $("#ajaxstreamgraph input[name=to_date]").val(currenttodate);
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'to_date')
+ .attr('value', currenttodate)
+ .appendTo('#ajaxstreamgraph');
+ }
+
+ if ($("#ajaxstreamgraph input[name=recherche]").val() != undefined)
+ {
+ $("#ajaxstreamgraph input[name=recherche]").val(currentText);
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'recherche')
+ .attr('value', currentText)
+ .appendTo('#ajaxstreamgraph');
+ }
+
+
+ var j=1;
+ $.each(currentcategories, function()
+ {
+ if(this != undefined)
+ {
+ if (firsttimerequest == false)
+ {
+ $("#ajaxstreamgraph input[name=categories"+j+"]").val(this);
+ j++;
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'categories'+j)
+ .attr('value', this)
+ .appendTo('#ajaxstreamgraph');
+ j++;
+ }
+ }
+
+ });
+
+ firsttimerequest = false;
+
+ $("#ajaxstreamgraph").submit();
+ $('#ajaxtreemap').submit();
+ }
+ $(function(){
+
+ $('#login_button').click(function() {
+
+ $('#ajaxlogin').submit();
+ });
+
+ $('#treemapaff').click(function()
+ {
+ $.ajax(
+ {
+ type: "POST",
+ url: "/",
+ data : "typeTri=treemap&requestType=setAffichage",
+ success: function(data) {
+
}
});
- return false;
- });
+
+ });
- // Formulaire POST AJAX
- $("#ajax2").submit( function()
+ $('#listehref').click(function()
+ {
+ $.ajax(
+ {
+ type: "POST",
+ url: "/",
+ data : "typeTri=liste&requestType=setAffichage",
+ success: function(data) {
+
+ }
+ });
+ });
+
+ $("#ajaxlogin").submit( function()
{
- alert('ajax2');
var urlSubmit = $(this).attr('action');
- currentcategories = [];
- /*var data = { 'categories' : []};*/
- $("input:checked").each(function() {
- /*data['categories'].push($(this).val());*/
- currentcategories.push($(this).val());
- });
- currentfromdate = $("#pickeddatebegin").val();
- currenttodate = $("#pickeddateend").val();
$.ajax(
{
@@ -255,59 +380,321 @@
data : $(this).serializeArray(),
success: function(data) {
var json = jQuery.parseJSON(data);
- var k =1;
- if (typeTri == "treemap")
- {
- content = "<div class=\"actus\">";
- for (i = 0; i < json.clusters.length & i<4; i++)
- {
- content += "<a id=\""+json.clusters[i].id+"\" href=\"http://localhost:8000/documents_cluster/"+json.query.query_id+"/"+json.clusters[i].id+"/0/10\"><div class=\"actu\"><img src=\"/static/img/home-visuel-"+k+".jpg\" alt=\"\" /><div class=\"inner-actu\">";
- content += "<h2> ";
- content += json.clusters[i].title;
- content += "</h2></div></div></a>";
- k++;
- }
- content +="</div>";
- }
- else
- {
- content = "<div class=\"articles\">";
- for (i = 0; i < json.clusters.length && i<4; i++)
- {
- content += "<div name=\"cluster_id\" class=\"article\" id=\""+json.clusters[i].id+"\"><div class=\"inner-article clearfix\"><h2><a title=\"Lire l\'article\" id=\""+json.clusters[i].id+"\" href=\"http://localhost:8000/documents_cluster/"+json.query.query_id+"/"+json.clusters[i].id+"/0/10\">";
- content += json.clusters[i].title;
- content += "</a></h2><p class=\"number-article\"><a href=\"#\">";
- content += json.clusters[i].documents_number;
- content +=" articles | ";
- content += json.clusters[i].annotations.length;
- content += " annotations </a><a title=\"ajouter une annotation\" class=\"add-annotation\" href=\"#\"></a></p> <div class=\"article-annotations\"><a title=\"title\" class=\"blue\" href=\"#\" style=\"width:20%;\"></a><a title=\"title\" class=\"green\" href=\"#\" style=\"width:20%;\"></a><a title=\"title\" class=\"red\" href=\"#\" style=\"width:40%;\"></a><a title=\"title\" class=\"empty\" href=\"#\" style=\"width:20%;\"></a></div><div class=\"article-content\">";
- content +="<div class=\"article-visuel-wrap\"><img class=\"article-visuel\" src=\"/static/img/visuel-article.jpg\" alt=\"\" /></div>";
- content +="<p class=\"resume\">";
- content += json.clusters[i].abstract;
- content += "</p><ul class=\"articlelinks\"><ul>";
-
- for (j = 0; j < json.clusters[i].documents.length; j++)
- {
- content += "<li><a href=\"\" id=\""+json.clusters[i].documents[j].id+"\">";
- content += json.clusters[i].documents[j].title;
- content += "</a></li>";
- }
- content +="</ul></ul>";
- content +="</div></div></div>";
- }
- content +="</div>";
- }
- $("#right").empty();
- $(content).appendTo("#right");
+
+ showResults(json);
curentjson = json;
}
});
return false;
+
+ });
+
+
+
+ $('#recherche_button').click(function() {
+ launchsearch();
+
+ });
+
+ // Formulaire POST AJAX
+ $("#ajaxtreemap").submit( function()
+ {
+ var urlSubmit = $(this).attr('action');
+ $.ajax(
+ {
+ type: "POST",
+ url: urlSubmit,
+ data : $(this).serializeArray(),
+ success: function(data) {
+ currentjsonTreemap = data;
+ var json = jQuery.parseJSON(data);
+ currentqueryidtreemap = json.query.query_id;
+ showResults(json);
+ }
+ });
+ return false;
+ });
+
+ // Formulaire POST AJAX
+ $("#ajaxstreamgraph").submit( function()
+ {
+
+ var urlSubmit = $(this).attr('action');
+
+ $.ajax(
+ {
+ type: "POST",
+ url: urlSubmit,
+ data : $(this).serializeArray(),
+ success: function(data) {
+ currentjsonStreamgraph = data;
+ var json = jQuery.parseJSON(data);
+ loadStreamgraph(json);
+ //currentqueryidstreamgraph = json.query.query_id;
+
+ }
+ });
+ return false;
+ });
+
+ // Formulaire POST AJAX
+ $("#ajaxfiltretreemap").submit(function()
+ {
+ var urlSubmit = $(this).attr('action');
+
+ if (($(this).attr('action')).indexOf("next") !== -1)
+ {
+ var myurl = ($(this).attr('action')).split('/');
+
+
+
+ if ($("#ajaxfiltretreemap input[name=docId]").val() != undefined)
+ {
+ $("#ajaxfiltretreemap input[name=docId]").val(myurl[4]);
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'docId')
+ .attr('value', myurl[4])
+ .appendTo('#ajaxfiltretreemap');
+ }
+ }
+
+
+
+ if ($("#ajaxfiltretreemap input[name=recherche]").val() != undefined)
+ {
+ $("#ajaxfiltretreemap input[name=recherche]").val($("#recherche_id").val());
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'recherche')
+ .attr('value', $("#recherche_id").val())
+ .appendTo('#ajaxfiltretreemap');
+ }
+
+
+ $('#ajaxfiltrestreamgraph').submit();
+
+ $.ajax(
+ {
+ type: "POST",
+ url: urlSubmit,
+ data : $(this).serializeArray(),
+ success: function(data) {
+ currentjsonTreemap = data;
+ var json = jQuery.parseJSON(data);
+ showResults(json);
+ //curentjson = json;
+ document.getElementById('titleleft').innerHTML = "";
+ }
+ });
+ return false;
});
- $('.checkbox_category').click(function(){
- /*var theValue = $(this).val();*/
- $('#ajax2').submit();
+ // Formulaire POST AJAX
+ $("#ajaxfiltrestreamgraph").submit( function()
+ {
+
+ if (($(this).attr('action')).indexOf("next") !== -1)
+ {
+ var myurl = ($(this).attr('action')).split('/');
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'docId')
+ .attr('value', myurl[4])
+ .appendTo('#ajaxfiltrestreamgraph');
+ }
+
+ currentfromdate = $("#pickeddatebegin").val();
+ currenttodate = $("#pickeddateend").val();
+
+ if ($("#ajaxfiltrestreamgraph input[name=from_date]").val() != undefined)
+ {
+ $("#ajaxfiltrestreamgraph input[name=from_date]").val(currentfromdate);
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'from_date')
+ .attr('value', currentfromdate)
+ .appendTo('#ajaxfiltrestreamgraph');
+ }
+
+ if ($("#ajaxfiltrestreamgraph input[name=to_date]").val() != undefined)
+ {
+ $("#ajaxfiltrestreamgraph input[name=to_date]").val(currenttodate);
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'to_date')
+ .attr('value', currenttodate)
+ .appendTo('#ajaxfiltrestreamgraph');
+ }
+
+ currentcategories =[];
+
+ $("input:checked").each(function() {
+ currentcategories.push($(this).val());
+ });
+
+ $("input:checkbox:not(:checked)").each(function() {
+ currentcategories.push('');
+ });
+ var i=1;
+ $.each(currentcategories, function()
+ {
+ if(this != undefined)
+ {
+ if (firsttimefiltre == false)
+ {
+ $("#ajaxfiltrestreamgraph input[name=categories"+i+"]").val(this);
+ i++;
+ }
+ else
+ {
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'categories'+i+'')
+ .attr('value', this)
+ .appendTo('#ajaxfiltrestreamgraph');
+ i++;
+ }
+ }
+
+ });
+
+ firsttimefiltre = false;
+ var urlSubmit = $(this).attr('action');
+
+ $.ajax(
+ {
+ type: "POST",
+ url: urlSubmit,
+ data : $(this).serializeArray(),
+ success: function(data) {
+ currentjsonStreamgraph = data;
+ var json = jQuery.parseJSON(data);
+ loadStreamgraph(json);
+ }
+ });
+ return false;
+ });
+
+ $('.checkbox_category').click(function()
+ {
+ // $("#categories1").removeAttr('checked');
+ //$('input[name=categories1]').removeAttr('checked');
+ $('#ajaxfiltretreemap').submit();
});
+
+
+ // Formulaire POST AJAX
+ $("#ajaxdocumentaryfile").submit(function()
+ {
+ currentuser = $("#user_connected").text();
+
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'user')
+ .attr('value', currentuser)
+ .appendTo('#ajaxdocumentaryfile');
+
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'jsontreemap')
+ .attr('value', currentjsonTreemap)
+ .appendTo('#ajaxdocumentaryfile');
+
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'jsonstreamgraph')
+ .attr('value', currentjsonStreamgraph)
+ .appendTo('#ajaxdocumentaryfile');
+
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'query_id')
+ .attr('value', currentqueryidtreemap)
+ .appendTo('#ajaxdocumentaryfile');
+
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'visibility')
+ .attr('value', 'private')
+ .appendTo('#ajaxdocumentaryfile');
+
+ var urlSubmit = $(this).attr('action');
+ $.ajax(
+ {
+ type: "POST",
+ url: urlSubmit,
+ data : $(this).serializeArray(),
+ success: function(data) {
+ $('#ajaxupdatedossierdoc').submit();
+ }
+ });
+ return false;
+ });
+
+ // Formulaire POST AJAX
+ $("#ajaxupdatedossierdoc").submit(function()
+ {
+ currentuser = $("#user_connected").text();
+ $('<input />').attr('type', 'hidden')
+ .attr('name', 'user')
+ .attr('value', currentuser)
+ .appendTo('#ajaxupdatedossierdoc');
+
+ var urlSubmit = $(this).attr('action');
+ $.ajax(
+ {
+ type: "POST",
+ url: urlSubmit,
+ data : $(this).serializeArray(),
+ success: function(data)
+ {
+ //alert(data);
+ var json = jQuery.parseJSON(data);
+ updatedossierdoc(json);
+ }
+ });
+ return false;
+ });
+
+
+ $( "#dialog-form" ).dialog({
+ autoOpen: false,
+ height: 250,
+ width: 350,
+ modal: false,
+ buttons: {
+ "Créer dossier": function() {
+ $('#ajaxdocumentaryfile').submit();
+ $( this ).dialog( "close" );
+ },
+ "Annuler": function() {
+
+ $( this ).dialog( "close" );
+ }
+ },
+ close: function() {
+ allFields.val( "" ).removeClass( "ui-state-error" );
+ }
+ });
+ $( "#create-dossierDoc" ).click(function() {
+
+ currentuser = $("#user_connected").text();
+
+ if(currentuser != "")
+ {
+ $( "#dialog-form" ).dialog( "open" );
+ }
+ else
+ {
+ alert('Vous devez vous connecter.');
+ }
+
+
+
+});
+
+
});//jQuery
\ No newline at end of file