// JavaScript source code var testing = false; var baseUrl = "http://wcf.aml-cfwb.be/Service.svc"; jQuery(document).ready(function () { if (testing == true) { baseUrl = "http://localhost:8000/Service.svc"; } jQuery('.BCEClass').each( function () { jQuery(this).GenerateBCEdiv(); }) }); jQuery.fn.GenerateBCEdiv = function () { var specialuse = ""; if (this.attr('aml-use') == "efe") { specialuse = "EFE"; } var topdiv = new TopContainer(specialuse); this.append(topdiv.GlobalDiv); var bottomdiv = new BottomContainer(specialuse); this.append(bottomdiv.GlobalDiv); topdiv.BrotherContainer = bottomdiv; bottomdiv.BrotherContainer = topdiv; } function TopContainer(specialuse) { this.GlobalDiv = jQuery("
"); var thisobject = this; var searchboxdiv = jQuery(""); var searchlabeldiv = jQuery(""); searchlabeldiv.text("Mot du titre"); searchboxdiv.append(searchlabeldiv); this.SearchTextBox = jQuery(""); searchboxdiv.append(this.SearchTextBox); this.SearchTextBox.keypress(function (e) { if (e.keyCode == 13) { thisobject.LaunchSearch(); return false; } }); var searchbutton = jQuery(""); searchboxdiv.append(searchbutton); searchbutton.click(function () { thisobject.LaunchSearch(); }); this.GlobalDiv.append(searchboxdiv); if (specialuse == "EFE") { this.GlobalDiv.hide(); } } TopContainer.prototype = { constructor: TopContainer, LaunchSearch: function () { this.BrotherContainer.TreeViewLink.ClearMarkedCategories(); var resultcont = this.BrotherContainer.ResultsContainerLink; resultcont.SearchField = "bce_partit"; resultcont.SearchedText = this.SearchTextBox.val(); resultcont.DoSearch(); } } function BottomContainer(specialuse) { this.SpecialUse = specialuse; this.GlobalDiv = jQuery(""); this.TreeViewLink = new TreeView(specialuse); this.GlobalDiv.append(this.TreeViewLink.GlobalDiv); this.ResultsContainerLink = new ResultsContainer(specialuse); this.GlobalDiv.append(this.ResultsContainerLink.GlobalDiv); this.TreeViewLink.Container = this; } BottomContainer.prototype = { constructor: BottomContainer } function TreeView(specialuse) { this.SpecialUse = specialuse; this.GlobalDiv = jQuery(""); var clacontainer = new CategoryContainer("chargement...", "", this); this.GlobalDiv.append(clacontainer.GlobalDiv); var parameters = new Object(); parameters.SearchedText = "bce_cla"; if (this.SpecialUse == "EFE") { parameters.SearchedText = "efe_mcs"; } parameters.IncludedCollections = ''; jQuery.ajax({ context: this, crossDomain: true, type: "POST", url: baseUrl + "/ref/getreferencesinjson", data: JSON.stringify(parameters), dataType: "json", contentType: "application/json; charset=utf-8", success: function (json) { clacontainer.SetText("Classement"); var references = json.GetReferencesInJsonResult; var jsonparsed = jQuery.parseJSON(references); var categorycontainersarray = []; for (var i = 0; i < jsonparsed.length ; i++) { var reference = jsonparsed[i]; var categorycontainer = new CategoryContainer(reference.ReferenceTexte + ' (' + reference.ReferenceComplement + ')', reference.ReferenceID, this); if (this.SpecialUse == "EFE") { categorycontainer.MakeSearchable("efe_parmcs"); } else { categorycontainer.MakeSearchable("bce_parcla"); } categorycontainersarray[categorycontainersarray.length] = categorycontainer; if (categorycontainer.Classement.length == 1 || this.SpecialUse == "EFE") { clacontainer.ChildrenDiv.append(categorycontainer.GlobalDiv); } } clacontainer.EvaluateExpandCollapseSign(clacontainer.ChildrenDiv.children().length); if (this.SpecialUse != "EFE") { clacontainer.ToggleChildren(); } for (var i = 0; i < categorycontainersarray.length; i++) { categorycontainersarray[i].CollectChildren(categorycontainersarray); } }, error: function (xhr, ajaxOptions, thrownError) { alert("Erreur de connexion à la db : " + xhr.responseText); } }); var autcontainer = new CategoryContainer("chargement...", "", this); this.GlobalDiv.append(autcontainer.GlobalDiv); parameters.SearchedText = "bce_inaut"; if (this.SpecialUse == "EFE") { parameters.SearchedText = "efe_aut"; } jQuery.ajax({ context: this, crossDomain: true, type: "POST", url: baseUrl + "/ref/getreferencesinjson", data: JSON.stringify(parameters), dataType: "json", contentType: "application/json; charset=utf-8", success: function (json) { autcontainer.SetText("Auteurs"); var references = json.GetReferencesInJsonResult; var jsonparsed = jQuery.parseJSON(references); for (var i = 0; i < jsonparsed.length ; i++) { var reference = jsonparsed[i]; var categorycontainer = new CategoryContainer(reference.ReferenceTexte + ' (' + reference.ReferenceComplement + ')', reference.ReferenceID, this); if (this.SpecialUse == "EFE") { categorycontainer.MakeSearchable("efe_paraut"); } else { categorycontainer.EvaluateExpandCollapseSign(reference.ReferenceComplement); } autcontainer.ChildrenDiv.append(categorycontainer.GlobalDiv); } autcontainer.EvaluateExpandCollapseSign(autcontainer.ChildrenDiv.children().length); }, error: function (xhr, ajaxOptions, thrownError) { alert("Erreur de connexion à la db : " + xhr.responseText); } }); } TreeView.prototype = { constructor: TreeView, ClearMarkedCategories: function () { jQuery(".BCECategoryTextClass", this.GlobalDiv).removeClass("BCECategoryClickedTextClass"); } } function CategoryContainer(texte, classement, tv) { this.Classement = classement; this.TVContainer = tv; this.GlobalDiv = jQuery(""); this.ExpandCollapseSign = jQuery(""); this.GlobalDiv.append(this.ExpandCollapseSign); var RightContainerDiv = jQuery(""); this.TextDiv = jQuery(""); this.SetText(texte); RightContainerDiv.append(this.TextDiv); this.ChildrenDiv = jQuery(""); RightContainerDiv.append(this.ChildrenDiv); this.GlobalDiv.append(RightContainerDiv); } CategoryContainer.prototype = { constructor: CategoryContainer, SetText: function (newtext) { this.TextDiv.text(newtext); }, MakeSearchable: function (searchfield) { this.TextDiv.addClass('BCECategorySearchableTextClass'); var thisobject = this; this.TextDiv.click(function () { if (thisobject.TVContainer.Container.BrotherContainer) { thisobject.TVContainer.Container.BrotherContainer.SearchTextBox.val(''); } thisobject.TVContainer.ClearMarkedCategories(); thisobject.TextDiv.addClass('BCECategoryClickedTextClass'); var resultcont = thisobject.TVContainer.Container.ResultsContainerLink; resultcont.SearchField = searchfield; resultcont.SearchedText = thisobject.Classement; resultcont.DoSearch(); }); }, ToggleChildren: function () { this.ChildrenDiv.toggleClass("BCECategoryHiddenClass"); if (this.ExpandCollapseSign.text() == "+") { if (this.ChildrenDiv.children().length == 0) { this.ChildrenDiv.text("chargement..."); var parameters = new Object(); parameters.SearchedText = "bce_auteurs"; parameters.IncludedCollections = this.Classement; jQuery.ajax({ context: this, crossDomain: true, type: "POST", url: baseUrl + "/ref/getreferencesinjson", data: JSON.stringify(parameters), dataType: "json", contentType: "application/json; charset=utf-8", success: function (json) { this.ChildrenDiv.empty(); var references = json.GetReferencesInJsonResult; var jsonparsed = jQuery.parseJSON(references); for (var i = 0; i < jsonparsed.length ; i++) { var reference = jsonparsed[i]; var categorycontainer = new CategoryContainer(reference.ReferenceTexte + ' (' + reference.ReferenceComplement + ')', reference.ReferenceID, this.TVContainer); categorycontainer.MakeSearchable("bce_paraut"); this.ChildrenDiv.append(categorycontainer.GlobalDiv); } }, error: function (xhr, ajaxOptions, thrownError) { alert("Erreur de connexion à la db : " + xhr.responseText); } }); } this.ExpandCollapseSign.text('-'); } else { this.ExpandCollapseSign.text('+'); } }, CollectChildren: function (categorycontainersarray) { for (var i = 0; i < categorycontainersarray.length; i++) { if (categorycontainersarray[i].Classement.indexOf(this.Classement) == 0 && categorycontainersarray[i].Classement.length == this.Classement.length + 1) { this.ChildrenDiv.append(categorycontainersarray[i].GlobalDiv); } } this.EvaluateExpandCollapseSign(this.ChildrenDiv.children().length); }, EvaluateExpandCollapseSign: function (childrencount) { if (childrencount > 0) { this.ExpandCollapseSign.text('+'); var thisobject = this; this.ExpandCollapseSign.click(function () { thisobject.ToggleChildren(); }); } } } function ResultsContainer(specialuse) { this.SpecialUse = specialuse; this.SearchField = ""; this.SearchedText = ""; this.GlobalDiv = jQuery(""); this.ResultsCountDiv = jQuery(""); this.GlobalDiv.append(this.ResultsCountDiv); this.ResultsContainerDiv = jQuery(""); this.GlobalDiv.append(this.ResultsContainerDiv); } ResultsContainer.prototype = { constructor: ResultsContainer, DoSearch: function () { this.ResultsContainerDiv.empty(); this.ResultsCountDiv.text("recherche en cours..."); var parameters = new Object(); parameters.SearchedText = this.SearchField; parameters.IncludedCollections = this.SearchedText; jQuery.ajax({ context: this, crossDomain: true, type: "POST", url: baseUrl + "/ref/getreferencesinjson", data: JSON.stringify(parameters), dataType: "json", contentType: "application/json; charset=utf-8", success: function (json) { var references = json.GetReferencesInJsonResult; var jsonparsed = jQuery.parseJSON(references); this.ResultsCountDiv.text(jsonparsed.length + ' résultat(s)'); for (var i = 0; i < jsonparsed.length ; i++) { var reference = jsonparsed[i]; var divresultglobal = jQuery(""); var divresult = jQuery(""); divresult.text(reference.ReferenceTexte); if (this.SpecialUse == "EFE") { divresult.html("" + reference.ReferenceTexte + "