PageSourceSearch

https://webdeb.be/assets/javascripts/ajax-router.js

js webdeb.be collected 2026-10-02 20:34:41 UTC 98,932 bytes, 2,946 lines download raw bytes

1/*
2 * WebDeb - Copyright (C) <2014-2019> <Université catholique de Louvain (UCL), Belgique ; Université de Namur (UNamur), Belgique>
3 *
4 * List of the contributors to the development of WebDeb: see AUTHORS file.
5 * Description and complete License: see LICENSE file.
6 *
7 * This program (WebDeb) is free software:
8 * you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program (see COPYING file).
15 * If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19/**
20 * This collection of functions are proxies for all Play ajax reverse routing.
21 * Javascript functions have the same names as the ones declared in routes file (for easy maintenance).
22 *
23 * Ajax calls (play reverse routing) must also be declared in Application.javascriptRoutes() method.
24 *
25 * @author Fabian Gilson
26 * @author Martin Rouffiange
27 */
28
29/*
30 * ACTORS
31 */
32
33/**
34 * Search for an actor based on a name and a type
35 *
36 * @param query the term (name) to look for
37 * @param actortype the actor type (int value)
38 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
39 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
40 * @return {*}
41 */
42function searchActor(query, actortype, fromIndex, toIndex) {
43  actortype = actortype === undefined ? -1 : actortype;
44  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.searchActor(query, actortype, fromIndex, toIndex).ajax({ async: true });
45}
46
47function findAffiliations(actor, viewBy, filters) {
48    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.findAffiliations(actor, viewBy, filters).ajax({ async: true });
49}
50
51/**
52 * Search for an actor based on a name among party members for election 2019
53 *
54 * @param query the term (name) to look for
55 * @return {*}
56 */
57function searchPartyMembers(query) {
58    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.searchPartyMembers(query).ajax({ async: true });
59}
60
61/**
62 * Validate current step of the given actor form
63 *
64 * @param form the actor form to validate
65 * @returns either a bad request, internal server error, or a success status code
66 */
67function actorStepValidation(form) {
68    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.validateStep().ajax({
69        type: 'POST',
70        processData: false,
71        contentType: false,
72        data: new FormData(form[0]),
73        async: true
74    });
75}
76
77/**
78 * Search for details of a given unknown actor (DB-pedia call)
79 *
80 * @param type the actor type id (0 for person, 1 for organization)
81 * @param isUrl boolean saying if we search from an url or from a name (put in value param)
82 * @param value the value to look for
83 * @param optional an optional value that will be used if given type is 0 and value is not an url
84 * @returns {*|{}}
85 */
86function searchActorDetails(type, isUrl, value, optional) {
87  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.searchActorDetails(type, isUrl, value, optional).ajax({ async: true });
88}
89
90/**
91 * Get all linked contributions with an actor by viz pane type
92 *
93 * @param actor the actor id
94 * @param type the name of the viz pane type
95 * @param pov for a specific contains in pane, -1 if none
96 * @returns {*}
97 */
98function getActorLinkedContributions(actor, type, pov) {
99  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getLinkedContributions(actor, type, pov).ajax({ async: true });
100}
101
102/**
103 * Find the list of contextualized arguments where the given author is thinker of an citation linked with
104 *
105 * @param actor an actor id
106 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
107 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
108 * @returns {*}
109 */
110function findActorArgumentsWhereThinker(actor, fromIndex, toIndex) {
111    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.findActorArgumentsWhereThinker(actor, fromIndex, toIndex).ajax({ async: true });
112}
113
114/**
115 * Find the list of citations where the given author is thinker limited by indexes
116 *
117 * @param actor an actor id
118 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
119 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
120 * @returns {*}
121 */
122function findActorCitationsWhereThinker(actor, fromIndex, toIndex) {
123    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.findActorCitationsWhereThinker(actor, fromIndex, toIndex).ajax({ async: true });
124}
125
126/**
127 * Find the list of contextualized arguments where the given author is cited of an citation linked with or directly with the argument
128 *
129 * @param actor an actor id
130 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
131 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
132 * @returns {*}
133 */
134function findActorArgumentsWhereCited(actor, fromIndex, toIndex) {
135    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.findActorArgumentsWhereCited(actor, fromIndex, toIndex).ajax({ async: true });
136}
137
138/**
139 * Find the list of citations where the given author is cited limited by indexes
140 *
141 * @param actor an actor id
142 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
143 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
144 * @returns {*}
145 */
146function findActorCitationsWhereCited(actor, fromIndex, toIndex) {
147    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.findActorCitationsWhereCited(actor, fromIndex, toIndex).ajax({ async: true });
148}
149
150/**
151 * Find the list of citations where the given author is thinker limited by indexes
152 *
153 * @param actor an actor id
154 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
155 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
156 * @returns {*}
157 */
158function findActorAffiliations(actor, fromIndex, toIndex) {
159    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.findActorCitationsWhereThinker(actor, fromIndex, toIndex).ajax({ async: true });
160}
161
162/**
163 * Find the list of citations of the given actor where he has the given actor role, displayed by contribution type
164 *
165 * @param actor an actor id
166 * @param role the actor role on the citation
167 * @param type a contribution type to display by
168 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
169 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
170 * @param filters a string that contains data for filter results
171 * @returns {*}
172 */
173function findActorCitations(actor, role, type, fromIndex, toIndex, filters) {
174    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.findActorCitations(actor, role, type, fromIndex, toIndex, filters).ajax({ async: true });
175}
176
177/**
178 * Get the modal with all citations where given actor is text's author
179 *
180 * @param actor an actor id
181 * @param text an text id
182 * @returns {*}
183 */
184function getActorTextCitations(actor, text) {
185    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getActorTextCitations(actor, text).aja
185x({ async: true });
186}
187
188/**
189 * Retrieve a raw picture file from given url and get filename back (will be used to be retrieved at actor form submit)
190 *
191 * @param url the url where we have to get the picture
192 * @returns {*|{}}
193 */
194function getPictureFile(url) {
195  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getPictureFile(url).ajax({ async: true });
196}
197
198/**
199 * Ajax call to retrieve an actor by its id
200 *
201 * @param actorId the actor ID to retrieve
202 * @return {*}
203 */
204function getActor(actorId) {
205  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getActor(actorId).ajax({ async: true });
206}
207
208/**
209 * Ajax call to retrieve all functions of a given actor (by id)
210 *
211 * @param actorId the actor id to fetch the functions for
212 * @param type a profession type
213 * @param term a string term to look for also
214 * @return {*}
215 */
216function getActorFunctions(actorId, type, term) {
217    actorId = actorId !== '' ? actorId : -1;
218    type = type == null ? -1 : type;
219  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getActorFunctions(actorId, type, term).ajax();
220}
221
222/**
223 * open modal for edit an actor
224 *
225 * @param actorId the actor id to edit
226 * @returns {*}
227 */
228function editActor(actorId) {
229    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.editFromModal(actorId).ajax({ async: true });
230}
231
232/**
233 * Handle actor form submission from modal frame
234 *
235 * @param form the actor form
236 * @returns either a bad request with the content of the form in error, or a success status code
237 */
238function saveFromModal(id, form) {
239  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.saveFromModal().ajax({
240    type: 'POST',
241    processData: false,
242    contentType: false,
243    data: new FormData(form[0]),
244    async: true
245  });
246}
247
248/**
249 * Warn user canceled the submission of an Actor from a modal form
250 *
251 * @returns an empty response with the status code
252 */
253function cancelFromModal() {
254  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.cancelFromModal().ajax({ async: true });
255}
256
257/**
258 * Cancel the transformation of an citation to a contextualized argument
259 *
260 * @returns a rendered message to warn user about the cancellation
261 */
262function cancelCitationToArgumentFromModal() {
263    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.cancelFromModal().ajax({ async: true });
264}
265
266/**
267 * Upload a picture for a given actor (in form)
268 *
269 * @param form the form query (post request) with the file and the id to post
270 * @param actorId the actor id for whom we add a new picture
271 * @returns {*|{}}
272 */
273function uploadActorPicture(form, actorId) {
274  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.uploadActorPicture(actorId).ajax({
275    type: 'POST',
276    data: new FormData(form[0]),
277    contentType: false,
278    processData: false,
279		async: true
280  });
281}
282
283/**
284 * Get modal frames to handle auto-created actors, if any
285 * @returns {*}
286 */
287function getAutoCreatedActors() {
288  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getAutoCreatedActors().ajax({ async: true });
289}
290
291/**
292 * Get modal frames to handle auto-created professors, if any
293 * @returns {*}
294 */
295function getAutoCreatedProfessions() {
296  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getAutoCreatedProfessions().ajax({ async: true });
297}
298
299/**
300 * Get modal frame to add new affiliations to existing actor (id)
301 *
302 * @param id an actor id
303 * @param isAffiliated true if the new affiliation must be affiliated
304 * @param isPerson true if the new affiliation concerns a person, false for a organization
305 * @returns {*|{}}
306 */
307function newAffiliations(id, isAffiliated, isPerson) {
308  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.newAffiliations(id, isAffiliated, isPerson).ajax({ async: true });
309}
310
311/**
312 * Post new affiliations for given actor id
313 *
314 * @param id an actor id
315 * @param isAffiliated true if the new affiliation must be affiliated
316 * @param isPerson true if the new affiliation concerns a person, false for a organization
317 * @param form the ActorAffiliationForm to submit
318 * @returns {*|{}}
319 */
320function addAffiliations(id, isAffiliated, isPerson, form) {
321  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.addAffiliations(id, isAffiliated, isPerson).ajax({
322    type: 'POST',
323    data: form.serialize(),
324		async: true
325  });
326}
327
328/**
329 * Get an actor card (properties and avatar pane)
330 *
331 * @param id an actor id
332 * @returns {*|{}}
333 */
334function getActorCard(id) {
335  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getActorCard(id).ajax({ async: true });
336}
337
338/**
339 * Get all contributions of given actor
340 *
341 * @param id an actor id
342 *
343 * @returns the partial searchResult scala template, or an error message, if an error occurred
344 */
345function getActorContributions(id) {
346	return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getActorContributions(id).ajax({ async: true });
347}
348
349/**
350 * Reset the actor type of a given actor. This operation also delete the linked person or organization from db
351 *
352 * @param id an actor id
353 * @return the edit page for this actor
354 */
355function resetActorType(id) {
356    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.resetActorType(id).ajax({ async: true });
357}
358
359/**
360 * Get the modal with all debates concerned by the given actor and socio key value
361 *
362 * @param actor an actor id
363 * @param key a socio key to see
364 * @param value the value of the socio key to see
365 * @return the modal with all debates
366 */
367function getActorPositionsForSocioValue(actor, key, value) {
368    return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.getActorPositionsForSocioValue(actor, key, value).ajax({ async: true });
369}
370
371/*
372 * TEXTS
373 */
374
375/**
376 * open modal for edit a text
377 *
378 * @param textId the text id to edit
379 * @returns {*}
380 */
381function editText(textId) {
382    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.editFromModal(textId).ajax({ async: true });
383}
384
385/**
386 * Submit text form
387 *
388 * @param textId the text id
389 * @param form the form with the text details
390 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
391 */
392function saveText(textId, form) {
393    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.saveFromModal(textId).ajax({
394        type: 'POST',
395        processData: false,
396        contentType: false,
397        data: new FormData(form[0]),
398        async: true
399    });
400}
401
402/**
403 * Find the list of contextualized arguments that are part of the given text limited by index
404 *
405 * @param text a text id
406 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
407 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
408 */
409function findTextArguments(text, fromIndex, toIndex) {
410    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.findTextArguments(text, fromIndex, toIndex).ajax({ async: true });
411}
412
413/**
414 * Find the list of citations that are part of the given text limited by index and with filters
415 *
416 * @param text a text id
417 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
418 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
419 * @param filters a string that contains data for filter results
420 */
421function findTextCitations(text, fromIndex, toIndex, filters) {
422    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.findTextCitations(text, fromIndex, toIndex, filters).ajax({ async: true });
423}
424
425/**
426 * Find a text by url
427 *
428 * @param url a url to search
429 * @return the corresponding text, if any
430 */
431function findTextByUrl(url) {
432    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.findTextByUrl(url).ajax({ async: true });
433}
434
435/**
436 * Get the text content of a html content found by the given url
437 *
438 * @param url a url for which we need is content
439 * @return the html text content of the given url
440 */
441function getHtmlContent(url) {
442    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getHtmlContent(url).ajax({ async: true });
443}
444
445/**
446 * Get modal frames to display text content, if any
447 *
448 * @param id a text id
449 * @returns {*}
450 */
451function getTextContentModal(id) {
452    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getTextContentModal(id).ajax({ async: true });
453}
454
455/**
456 * Search for a text
457 *
458 * @param query a string query
459 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
460 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
461 * @return {*}
462 */
463function searchText(query, fromIndex, toIndex) {
464  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.searchText(query, fromIndex, toIndex).ajax({ async: true });
465}
466
467/**
468 * Search for all text source name containing this term
469 *
470 * @param query the term to search for
471 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
472 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
473 * @returns {*}
474 */
475function searchTextSource(query, fromIndex, toIndex) {
476  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.searchTextSource(query, fromIndex, toIndex).ajax({ async: true });
477}
478
479/**
480 * Get the annotated version of given text (from WDTAL service or cache)
481 *
482 * @param textId a text id
483 * @returns {*|{}}
484 */
485function getAnnotatedText(textId, synchronous, highlighted) {
486  synchronous = synchronous || false;
487  highlighted = highlighted === undefined ? true : highlighted;
488  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getAnnotatedText(textId, highlighted).ajax({ async: !synchronous });
489}
490
491/**
492 * Get the annotated text or the html web content
493 *
494 * @param textId a text id
495 * @returns {*|{}}
496 */
497function getTextContentOrHtmlContent(textId, synchronous, highlighted) {
498    synchronous = synchronous || false;
499    highlighted = highlighted === undefined ? true : highlighted;
500    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getTextContentOrHtmlContent(textId, highlighted).ajax({ async: !synchronous });
501}
502
503/**
504 * Get the content of a text from a given url
505 *
506 * @param url an url to get the text and other properties from (typically a web page)
507 * @returns {*|{}}
508 */
509function getTextContent(url) {
510  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getTextContent(url).ajax({ async: true });
511}
512
513/**
514 * Get embed html code from a platform (Twitter, TikTok, ...) url
515 *
516 * @param url an url to get embed code
517 * @param platform the type of platform (Twitter, TikTok, ...)
518 * @returns *
519 */
520function getEmbed(url, platform) {
521    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getEmbed(url, platform).aja
521x({ async: true });
522}
523
524/**
525 * Get the content of a PDF from a given url
526 *
527 * @param url an url pointing to a pdf file
528 * @returns {*|{}}
529 */
530function extractPDFContent(url) {
531  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.extractPDFContent(url).ajax({ async: true });
532}
533
534/**
535 * Get text language
536 *
537 * @param text a text content
538 * @returns {*|{}}
539 */
540function getTextLanguage(text) {
541  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getTextLanguage(text).ajax({ async: true });
542}
543
544/**
545 * Get the share media modal for given contribution
546 *
547 * @param idContribution a contribution id
548 * @returns {*}
549 */
550function getShareMediaModal(id, pane, pov) {
551    pane = pane === undefined ? 0 : pane;
552    pov = pov === undefined ? 0 : pov;
553    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getShareMediaModal(id, pane, pov).ajax({ async: true });
554}
555
556/**
557 * Get the list of actors linked to given contribution with given role that redirect to given pane
558 *
559 * @param id a contribution id
560 * @param role the role of the actor
561 * @param pane the pane to redirect
562 * @returns {*}
563 */
564function getContributionActors(id, role, pane) {
565    pane = pane === undefined ? 0 : pane;
566    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getContributionActors(id, role, pane).ajax({ async: true });
567}
568
569
570/**
571 * open modal to find linked contributions by given contribution type to given contribution
572 *
573 * @param contributionId a contribution id
574 * @returns {*}
575 */
576function getFindContributionsModal(contributionId) {
577    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getFindContributionsModal(contributionId).ajax({ async: true });
578}
579
580/**
581 * open modal or get the list of linked contributions by given contribution type to given contribution
582 *
583 * @param contributionId a contribution id
584 * @param forContributionId the related contribution id
585 * @param forContributionType the contribution type
586 * @param contributionRole the role of related contribution
587 * @param pane the pane to redirect
588 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
589 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
590 * @param filters a string that contains data for filter results
591 * @returns {*}
592 */
593function findContributions(contributionId, forContributionId, forContributionType, contributionRole, pane, fromIndex, toIndex, filters) {
594    forContributionId = forContributionId != null ? forContributionId : -1;
595    contributionRole = contributionRole != null ? contributionRole : -1;
596    pane = pane != null ? pane : 0;
597    fromIndex = fromIndex != null ? fromIndex : -1;
598    toIndex = toIndex != null ? toIndex : -1;
599
600    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.findContributions(contributionId, forContributionId, forContributionType, contributionRole, pane, fromIndex, toIndex, filters).ajax({ async: true });
601}
602
603/**
604 * Get a text radiography (all texts having arguments with similarity links to this text's arguments)
605 *
606 * @param id a text id
607 * @param sortby int value representing a ERadiographyViewKey
608 * @returns {*}
609 */
610function textRadiography(id, sortby) {
611  return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.textRadiography(id, sortby).ajax({ async: true });
612}
613
614/**
615 * Get the name of a given contribution id
616 *
617 * @param id a contribution id
618 * @returns {*}
619 */
620function getContributionName(id) {
621    id = id == null ? -1 : id;
622    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getContributionName(id).ajax({ async: true });
623}
624
625/**
626 * Get the name of a given place id
627 *
628 * @param id a place id
629 * @returns {*}
630 */
631function getPlaceName(id) {
632    id = id == null ? -1 : id;
633    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getPlaceName(id).ajax({ async: true });
634}
635
636/**
637 * Get the name of a given technical type id
638 *
639 * @param value a technical value
640 * @param id a technical id
641 * @returns {*}
642 */
643function getTechnicalName(value, id) {
644    value = value || "";
645    id = id || "";
646    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getTechnicalName(id, value).ajax({ async: true });
647}
648
649/**
650 * Get the name of a given profession id
651 *
652 * @param id a profession id
653 * @returns {*}
654 */
655function getProfessionName(id) {
656    id = id == null ? -1 : id;
657    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getProfessionName(id).ajax({ async: true });
658}
659
660/**
661 * Get the description of a given affiliation
662 *
663 * @param id an affiliation id
664 * @returns {*}
665 */
666function getAffiliationDescription(id) {
667    id = id == null ? -1 : id;
668    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getAffiliationName(id).ajax({ async: true });
669}
670
671/**
672 * Get suggested contributions related to given contribution
673 *
674 * @param id a contribution id
675 * @returns {*}
676 */
677function getSuggestionsContribution(id) {
678    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getSuggestionsContribution(id).ajax({ async: true });
679}
680
681/**
682 * Find a list of Contribution ordered by number of visualization hits (actor, text and argument only)
683 *
684 * @param type a contribution type (may be -1 for actors, texts and arguments)
685 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
686 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
687 * @param orderBy the way to order the entries
688 * @returns {*}
689 */
690function getPopularEntries(type, fromIndex, toIndex, orderBy) {
691    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getPopularEntries(type, fromIndex, toIndex, orderBy).ajax({ async: true });
692}
693
694/**
695 * Get the modal with all citations in the context contribution for the given actor
696 *
697 * @param context a context contribution id
698 * @param actor an actor id
699 * @returns {*}
700 */
701function getActorCitationInContext(context, actor) {
702    startWaitingModal();
703    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.getActorCitationInContext(context, actor).ajax({ async: true });
704}
705
706/**
707 * Get the modal with all citations in the context contribution that come from given text
708 *
709 * @param context a context contribution id
710 * @param text a text id
711 * @returns {*}
712 */
713function getTextCitationInContext(context, text) {
714    startWaitingModal();
715    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.getTextCitationInContext(context, text).aja
715x({ async: true });
716}
717
718/**
719 * Get the modal with all citations in the context contribution for the given sociography key and key value
720 *
721 * @param context a context contribution id
722 * @param subContext a tag sub context id
723 * @param key a ESocioGroupKey key id
724 * @param keyValue the key value
725 * @param shade the shade needed
726 * @param isArgument true for arguments, false for positions
727 * @returns {*}
728 */
729function getSociographyCitationInContext(context, subContext, key, keyValue, shade, isArgument) {
730    subContext = subContext === undefined || !subContext ? -1 : subContext;
731    shade = shade === undefined ? -1 : shade;
732    isArgument = isArgument === undefined ? true : isArgument;
733
734    startWaitingModal();
735
736    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.getSociographyCitationInContext(context, subContext, key, keyValue, shade, isArgument).ajax({ async: true });
737}
738
739/**
740 * Get the concurrent citations list of the main actor compared to given key / value actor(s) in given context / sub context
741 *
742 * @param context a context contribution id
743 * @param subContext a sub context contribution id
744 * @param actor the main actor id
745 * @param key a ESocioGroupKey key id
746 * @param keyValue the key value
747 * @param isArgument true for arguments, false for positions
748 * @return the concurrent citations list
749 */
750function getSociographyCitationsConcurrent(context, subContext, actor, key, keyValue, isArgument) {
751    subContext = subContext === undefined || !subContext ? -1 : subContext;
752    isArgument = isArgument === undefined ? true : isArgument;
753
754    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.getSociographyCitationsConcurrent(context, subContext, actor, key, keyValue, isArgument).ajax({ async: true });
755}
756
757/**
758 * Get all linked contributions with a text by viz pane type
759 *
760 * @param text the text id
761 * @param type the name of the viz pane type
762 * @param pov for a specific contains in pane, -1 if none
763 * @returns {*}
764 */
765function getTextLinkedContributions(text, type, pov) {
766    pov = pov === undefined ? -1 : pov;
767    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getLinkedContributions(text, type, pov).ajax({ async: true });
768}
769
770/**
771 * Get all citations for given text id
772 *
773 * @param id a text id
774 * @returns {*}
775 */
776function getTextCitations(id) {
777    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getCitations(id).ajax({ async: true });
778}
779
780/**
781 * Get the first argument id for given context contribution id
782 *
783 * @param id a context contributio id
784 * @returns {*}
785 */
786function getFirstArgument(id) {
787    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getFirstArgument(id).ajax({ async: false });
788}
789
790/**
791 * Check if a given domain name is a free source or not. Free means free of rights.
792 *
793 * @param domain the domain name to check
794 * @return true if the given domain name is a free source
795 */
796function checkFreeSource(domain) {
797    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.checkFreeSource(domain).ajax({ async: false });
798}
799
800/*
801 * CONTEXT CONTRIBUTION
802 */
803
804/**
805 * Get the context contribution behind the contribution id
806 *
807 * @param id a context contribution id
808 * @returns a debate or a text
809 */
810function getContextContribution(id) {
811    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getContextContribution(id).ajax({ async: true });
812}
813
814/*
815 * ARGUMENTS
816 */
817
818/**
819 * Search for arguments with given query (in standard form and authors)
820 *
821 * @param query a query string
822 * @param type the type of argument, if any otherwise -1
823 * @param shade the shade of argument, if any otherwise -1
824 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
825 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
826 * @returns {*}
827 */
828function searchArgument(query, type, shade, fromIndex, toIndex) {
829    shade = shade === undefined ? -2 : shade;
830    type = type === undefined ? -1 : type;
831    fromIndex = fromIndex === undefined ? -1 : fromIndex;
832    toIndex = toIndex === undefined ? -1 : toIndex;
833	return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.searchArgument(query, type, shade, fromIndex, toIndex).ajax({ async: true });
834}
835
836/**
837 * Search for arguments dictionary with given query title
838 *
839 * @param query a query string
840 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
841 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
842 * @returns {*}
843 */
844function searchArgumentDictionary(query, fromIndex, toIndex) {
845    fromIndex = fromIndex === undefined ? -1 : fromIndex;
846    toIndex = toIndex === undefined ? -1 : toIndex;
847    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.searchArgumentDictionary(query, fromIndex, toIndex).ajax({ async: true });
848}
849
850/**
851 * Get modal frame to add a new link by either searching for an existing context contribution or adding new one
852 *
853 * @param contextId the context contribution where add this link
854 * @param id an argument or citation id that will be linked to the new argument
855 * @param shade the link shade that will bind both argument (or citation) (give one and future one), if any
856 * @param fromAuto true if this is called from automatic transformation process
857 * @returns {*|{}}
858 */
859function argumentSelection(contextId, id, shade, fromAuto) {
860    shade = shade === undefined ? -1 : shade;
861    fromAuto = fromAuto === undefined ? false : fromAuto;
862    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.argumentContextSelection(contextId, id, shade, fromAuto).ajax({ async: true });
863}
864
865/**
866 * Get all shades of a given argument type and timing
867 *
868 * @param type an argument type
869 * @param timing a timing
870 * @param lang language code to fetch the shade for
871 * @return the list of all shades corresponding to the given argument type and timing
872 */
873function getArgumentShades(type, timing, lang) {
874  return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.getArgumentShades(type, timing, lang).aja
874x({ async: true });
875}
876
877/**
878 * Get the justification map for a given argument
879 *
880 * @param argument an argument id
881 * @return the argument cartography pane
882 */
883function getJustificationMap(argument) {
884    return jsRoutes.be.webdeb.presentation.web.controllers.viz.VizActions.getJustificationMap(argument).ajax({ async: true });
885}
886
887/**
888 * open modal for create an argument
889 *
890 * @param contextId the context where add the argument
891 * @param subContextId a tag sub context id
892 * @param categoryId if the new argument is in a specific category
893 * @param superArgumentId if the new argument is a sub argument of a specific super argument
894 * @param shadeId the shade of the potential link
895 * @returns {*}
896 */
897function newArgument(contextId, subContextId, categoryId, superArgumentId, shadeId) {
898    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.newArgument(contextId, subContextId, categoryId, superArgumentId, shadeId).ajax({ async: true });
899}
900
901/**
902 * open modal for create an argument from a citation justification link
903 *
904 * @param citationId a citation justification link id
905 * @return the modal to complete the argument
906 */
907function newArgumentFromCitation(citationId) {
908    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.newArgumentFromCitation(citationId).ajax({ async: true });
909}
910
911/**
912 * open modal for edit an argument
913 *
914 * @param argId the argument id to edit
915 * @returns {*}
916 */
917function editArgument(argId, contextId) {
918    contextId = contextId === undefined ? -1 : contextId;
919    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.editFromModal(argId, contextId).ajax({ async: true });
920}
921
922/**
923 * Get citations linked with argument in given context
924 *
925 * @param contextId the context where add the argument
926 * @param subContextId a tag sub context id
927 * @param categoryId if the new argument is in a specific category
928 * @param argumentId the argument id
929 * @param shadeId the shade of the potential link
930 * @returns {*}
931 */
932function getArgumentCitationLinks(contextId, subContextId, categoryId, argumentId, shadeId) {
933    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.getArgumentCitationLinks(contextId, subContextId, categoryId, argumentId, shadeId).ajax({ async: true });
934}
935
936/**
937 * Submit  argument form
938 *
939 * @param argId the argument id
940 * @param contextId the context id
941 * @param form the form with the argument details
942 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
943 */
944function saveArgument(argId, contextId, form) {
945    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.saveFromModal(argId, contextId).ajax({
946        type: 'POST',
947        data: form.serialize(),
948        async: true
949    });
950}
951
952/**
953 * open modal for edit an argument dictionary
954 *
955 * @param argId the argument dictionary id to edit
956 * @returns {*}
957 */
958function editArgumentDictionary(argId) {
959    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.editDictionary(argId).ajax({ async: true });
960}
961
962/**
963 * Submit argument dictionary form
964 *
965 * @param argId the argument dictionary id
966 * @param form the form with the argument dictionary details
967 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
968 */
969function saveArgumentDictionary(argId, form) {
970    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.saveDictionary(argId).ajax({
971        type: 'POST',
972        data: form.serialize(),
973        async: true
974    });
975}
976
977/**
978 * Save links from argument viz
979 *
980 * @param fromArgument the argument where the save is performed
981 * @param type the name of the viz pane type
982 * @param linkType the linkType from carto
983 * @param links json-representation of LinkForms with all justification links of given text
984 * @returns {*}
985 */
986function saveLinks(fromArgument, type, linkType, links) {
987    linkType = (linkType == null ? -1 : linkType);
988    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.saveLinks(fromArgument, type, linkType).ajax({
989        type: 'POST',
990        contentType: "application/json; charset=utf-8",
991        data: links,
992        async: true
993    });
994}
995
996/**
997 * Save a link between two contextualized or simple arguments or between a contextualized argument and an citation
998 *
999 * @param from an (contextualized) argument id
1000 * @param to an other (contextualized) argument or an citation id
1001 * @param shade the shade id that will be used to bind both argument
1002 * @param group the group where save this link
1003 * @param context a context contribution or -1 or undefined if not needed
1004 * @returns {*}
1005 */
1006function saveLink(from, to, shade, group, context) {
1007    context = context === undefined ? -1 : context;
1008    shade = shade === undefined ? -1 : shade;
1009    return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.saveLink(from, to, context, shade, group).ajax({
1010        type: 'POST',
1011        contentType: "application/json; charset=utf-8",
1012        data: "{}",
1013        async: true
1014    });
1015}
1016
1017/**
1018 * Cancel the creation of a new argument to be linked to another one
1019 *
1020 * @returns {*|{}}
1021 */
1022function abortLinkCreation() {
1023  return jsRoutes.be.webdeb.presentation.web.controllers.entry.argument.ArgumentActions.abortLinkCreation().ajax({ async: true });
1024}
1025
1026/*
1027 * CITATIONS
1028 */
1029
1030/**
1031 * Validate current step of the given citation form
1032 *
1033 * @param form the citation form to validate
1034 * @returns either a bad request, internal server error, or a success status code
1035 */
1036function citationStepValidation(form) {
1037    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.validateStep().ajax({
1038        type: 'POST',
1039        data: form.serialize(),
1040        async: true
1041    });
1042}
1043
1044/**
1045 * Add selected shade in session on the citationSelection process.
1046 *
1047 * @param argId an argument id
1048 * @param shade an argument link shade, if any
1049 * @return ok if given argId and shade are good
1050 */
1051function citationSelectionShade(argId, shade) {
1052    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.citationSelectionShade(argId, shade).ajax({ async: true });
1053}
1054
1055/**
1056 * See all arguments that are linked with the given citation
1057 *
1058 * @param excId an citation id
1059 * @return {*}
1060 */
1061function seeCitationArguments(excId) {
1062    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.seeCitationArguments(excId).ajax({ async: true });
1063}
1064
1065/**
1066 * open modal for a new citation with given excerpt
1067 *
1068 * @param textId the text where add the citation
1069 * @param excerpt the original excerpt of the new citation
1070 * @returns {*}
1071 */
1072function newCitation(textId, excerpt) {
1073    startWaitingModal();
1074    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.newCitation(textId, excerpt).aja
1074x({ async: true });
1075}
1076
1077/**
1078 * open modal for edit an citation
1079 *
1080 * @param excId the citation id to edit
1081 * @param fromContribution a contribution id from where we add the citation
1082 * @param contributionRole the role of the contribution in the citation
1083 * @returns {*}
1084 */
1085function editCitation(excId, fromContribution, contributionRole) {
1086    excId = excId == null ? -1 : excId;
1087    fromContribution = fromContribution === undefined ? -1 : fromContribution;
1088    contributionRole = contributionRole === undefined ? -1 : contributionRole;
1089    startWaitingModal();
1090    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.editFromModal(excId, fromContribution, contributionRole).ajax({ async: true });
1091}
1092
1093/**
1094 * Get modal frame to add citations in a particular context
1095 *
1096 * @param contextId the context where add the citations
1097 * @param subContextId a tag sub context id
1098 * @param categoryId if the citations must be in a specific category
1099 * @param argumentId if the citations justify an argument
1100 * @param isJustification true if a justification link must be add, false for a position link
1101 * @param shadeId the shade of the potential link
1102 * @returns {*|{}}
1103 */
1104function citationSelection(contextId, subContextId, categoryId, argumentId, isJustification, shadeId) {
1105    startWaitingModal();
1106    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.citationSelection(contextId, subContextId, categoryId, argumentId, isJustification, shadeId).ajax({ async: true });
1107}
1108
1109/**
1110 * Submit citation form
1111 *
1112 * @param excId the citation id
1113 * @param form the form with the citation details
1114 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
1115 */
1116function saveCitation(excId, form) {
1117    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.saveFromModal(excId).ajax({
1118        type: 'POST',
1119        data: form.serialize(),
1120        async: true
1121    });
1122}
1123
1124/**
1125 * Submit citation justification links form
1126 *
1127 * @param context       a contribution context id
1128 * @param subContext     a tag sub context id
1129 * @param category      a tag category id
1130 * @param argument an argument id
1131 * @param shade           a justification link shade
1132 * @param group           the group where save this link
1133 * @param ids the list of citations ids for which create the justification links
1134 * @returns {*|{}} either an empty ok response (200) or bad request if an error occured
1135 */
1136function saveCitationJustificationLinks(context, subContext, category, argument, shade, group, ids) {
1137    subContext = subContext != null && subContext ? subContext : -1;
1138    category = category != null ? category : -1;
1139    argument = argument != null ? argument : -1;
1140
1141    let idsObject = {};
1142    idsObject.ids = ids;
1143
1144    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.saveCitationJustificationLinks(context, subContext, category, argument, shade, group).ajax({
1145        type: 'POST',
1146        contentType: "application/json; charset=utf-8",
1147        data: JSON.stringify(idsObject),
1148        async: true
1149    });
1150}
1151
1152/**
1153 * Submit citation position links form
1154 *
1155 * @param context       a contribution context id
1156 * @param subContext     a tag sub context id
1157 * @param shade           a position link shade
1158 * @param group           the group where save this link
1159 * @param ids the list of citations ids for which create the position links
1160 * @returns {*|{}} either an empty ok response (200) or bad request if an error occured
1161 */
1162function saveCitationPositionLinks(context, subContext, shade, group, ids) {
1163    subContext = subContext != null && subContext ? subContext : -1;
1164
1165    let idsObject = {};
1166    idsObject.ids = ids;
1167
1168    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.saveCitationPositionLinks(context, subContext, shade, group).ajax({
1169        type: 'POST',
1170        contentType: "application/json; charset=utf-8",
1171        data: JSON.stringify(idsObject),
1172        async: true
1173    });
1174}
1175
1176/**
1177 * Search for citations base
1178 *
1179 * @param term the values to search for
1180 * @param type the type of citation browse
1181 * @param context the context where the browse is, if any
1182 * @param subContext a tag sub context id
1183 * @param category the tag category where the browse is, if any
1184 * @param argument the argument where the browse is, if any
1185 * @param isJustification true if a justification link must be add, false for a position link
1186 * @param shade a justification link shade, if any
1187 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
1188 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
1189 * @param filters a string that contains data for filter results
1190 * @param linkType a enum if a link must not already exists in context
1191 * @return the list of citations
1192 */
1193function searchCitationByType(term, type, context, subContext, category, argument, isJustification, shade, fromIndex, toIndex, filters, linkType) {
1194    context = context != null ? context : -1;
1195    subContext = subContext != null ? subContext : -1;
1196    category = category != null ? category : -1;
1197    argument = argument != null ? argument : -1;
1198    shade = shade != null ? shade : -1;
1199    filters = filters != null ? filters : "";
1200    linkType = linkType != null ? linkType : -1;
1201    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.searchCitationByType(term, type, context, subContext, category, argument, isJustification, shade, fromIndex, toIndex, filters, linkType).ajax({ async: true });
1202}
1203
1204/**
1205 * Get the edit temporary citation form for given tmp citation to be added into current page
1206 *
1207 * @param excId id of tmp citation to retrieve
1208 * @returns {*}
1209 */
1210function editExternalCitation(excId) {
1211    return jsRoutes.be.webdeb.presentation.web.controllers.validate.ValidateActions.editExternalCitation(excId).ajax({ async: true });
1212}
1213
1214/**
1215 * Submit temporary citation form after manual validation
1216 *
1217 * @param excId the temporary citation id
1218 * @param form the form with the citation details
1219 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
1220 */
1221function submitExternalCitation(excId, form) {
1222  return jsRoutes.be.webdeb.presentation.web.controllers.validate.ValidateActions.submitExternalCitation(excId).ajax({
1223    type: 'POST',
1224    data: form.serialize(),
1225    async: true
1226  });
1227}
1228
1229/**
1230 * Set the rejected state for given temporary argument, ie, if rejected is true, this argument will not be shown again.
1231 * Reversible action until the user quit the validation screen.
1232 *
1233 * @param excId a temporary argument id
1234 * @param rejected true to reject this argument
1235 * @returns {*}
1236 */
1237function setExternalContributionState(excId, rejected) {
1238  return jsRoutes.be.webdeb.presentation.web.controllers.validate.ValidateActions.setExternalContributionState(excId, rejected).ajax({ async: true });
1239}
1240
1241/**
1242 * Set the rejected state for given temporary argument, ie, if rejected is true, this argument will not be shown again.
1243 * Reversible action until the user quit the validation screen.
1244 *
1245 * @param tweetID the WDTAL ID of the Tweet
1246 * @returns {*}
1247 */
1248function rejectTweet(tweetID) {
1249  return jsRoutes.be.webdeb.presentation.web.controllers.validate.ValidateActions.rejectTweet(tweetID).ajax({ async: true });
1250}
1251
1252/**
1253 * Get the arguments structure of the given context
1254 *
1255 * @param context a context contribution
1256 * @return the context arguments structure if given super context / context exists
1257 */
1258function getContextArgumentStructure(context) {
1259    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.getContextArgumentStructure(context).ajax({ async: true });
1260}
1261
1262/**
1263 * Move an element of the context arguments structure
1264 *
1265 * @param linkId the link to change
1266 * @param newSubContextId the new tag sub context id for the given link
1267 * @param newCategoryId the new tag category id for the given link
1268 * @param newSuperArgumentId the new super argument id for the given link
1269 * @param newShade the new link shade id for the given link
1270 * @param newLink true if it must be a new link, false otherwise
1271 * @param order the order of the link in the context
1272 * @returns {*}
1273 */
1274function changeContextArgumentStructure(linkId, newSubContextId, newCategoryId, newSuperArgumentId, newShade, newLink, order) {
1275    newSubContextId = newSubContextId != null ? newSubContextId : -1;
1276    newCategoryId = newCategoryId != null ? newCategoryId : -1;
1277    newSuperArgumentId = newSuperArgumentId != null ? newSuperArgumentId : -1;
1278    newShade = newShade != null ? newShade : -1;
1279    newLink = newLink != null ? newLink : false;
1280    order = order != null ? order : 0;
1281
1282    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.changeContextArgumentStructure(linkId, newSubContextId, newCategoryId, newSuperArgumentId, newShade, newLink, order).ajax({
1283        type: 'POST',
1284        async: true
1285    });
1286}
1287
1288/**
1289 * Change the given justification link shade
1290 *
1291 * @param link a justification link id
1292 * @return ok if the link shade is well changed, badrequest otherwise
1293 */
1294function changeJustificationShade(link) {
1295    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.changeJustificationShade(link).ajax({ async: true });
1296}
1297
1298/**
1299 * Get the modal to add a text to a debate
1300 *
1301 * @param debate a debate id
1302 * @returns {*}
1303 */
1304function getAddTextToDebateModal(debate) {
1305    startWaitingModal();
1306    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.getAddTextToDebateModal(debate).ajax({ async: true });
1307}
1308
1309/**
1310 * Save given debate has text
1311 *
1312 * @param debate a debate id
1313 * @param text a text id,
1314 * @param textForm if needed
1315 * @returns {*}
1316 */
1317function addTextToDebate(debate, text, form) {
1318    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.addTextToDebate(debate, text).aja
1318x({
1319        type: 'POST',
1320        processData: false,
1321        contentType: false,
1322        data: new FormData(form[0]),
1323        async: true
1324    });
1325}
1326
1327/**
1328 * Get all contextualized argument for given context contribution id
1329 *
1330 * @param id a context contribution id
1331 * @returns {*}
1332 */
1333function getContextualizedArguments(id) {
1334  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getContextualizedArguments(id).ajax({ async: true });
1335}
1336
1337/**
1338 * Get all contextualized argument for given context contribution id filter on given shade link type
1339 *
1340 * @param id a context contribution id
1341 * @param shade the link shade type to filter on
1342 * @returns {*}
1343 */
1344function getContextualizedArgumentsByShade(id, shade) {
1345    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getContextualizedArgumentsByShade(id, shade).ajax({ async: true });
1346}
1347
1348/**
1349 * Get all justification links for given text id
1350 *
1351 * @param id a context contribution id
1352 * @returns {*}
1353 */
1354function getJustificationLinks(id) {
1355    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getJustificationLinks(id).ajax({ async: true });
1356}
1357
1358/**
1359 * Get all justification links for given text id filter on given shade link type
1360 *
1361 * @param id a context contribution id
1362 * @param shade the link shade type to filter on
1363 * @returns {*}
1364 */
1365function getJustificationLinksByShade(id, shade) {
1366    return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.getJustificationLinksByShade(id, shade).ajax({ async: true });
1367}
1368
1369/**
1370 * Save given justification links passed as serialized LinkForms
1371 *
1372 * @param text text id
1373 * @param links json-representation of LinkForms with all justification links of given text
1374 * @param group the group id in which the link must be saved
1375 * @returns {*}
1376 */
1377function saveJustificationLinks(text, links, group) {
1378  return jsRoutes.be.webdeb.presentation.web.controllers.entry.text.TextActions.saveJustificationLinks(text, group).ajax({
1379    type: 'POST',
1380    contentType: "application/json; charset=utf-8",
1381    data: links,
1382		async: true
1383  });
1384}
1385
1386/**
1387 * Search for citations with given query title
1388 *
1389 * @param query a query string
1390 * @param textToLook the text id where to search, if any
1391 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
1392 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
1393 * @returns {*}
1394 */
1395function searchCitation(query, textToLook, fromIndex, toIndex) {
1396    textToLook = textToLook === undefined ? -1 : textToLook;
1397    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.searchCitation(query, textToLook, fromIndex, toIndex).ajax({ async: true });
1398}
1399
1400/**
1401 * Get the modal to change the position shade
1402 *
1403 * @param positionId a position citation link id
1404 * @returns {*}
1405 */
1406function changeCitationPositionShadeModal(positionId) {
1407    startWaitingModal();
1408    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.changeCitationPositionShadeModal(positionId).ajax({ async: true });
1409}
1410
1411/**
1412 * Save change of citation position link
1413 *
1414 * @param positionId a position citation link id
1415 * @param shade the new shade id
1416 * @returns {*}
1417 */
1418function changeCitationPositionShadel(positionId, shade) {
1419    startWaitingModal();
1420    return jsRoutes.be.webdeb.presentation.web.controllers.entry.citation.CitationActions.changeCitationPositionShade(positionId, shade).ajax({
1421        type: 'POST',
1422        async: true
1423    });
1424}
1425
1426/*
1427 * TAGS
1428 */
1429
1430/**
1431 * Search for tags with given query
1432 *
1433 * @param query a query string
1434 * @param idToIgnore the tag id to ignore, or null
1435 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
1436 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
1437 * @returns {*}
1438 */
1439function searchTag(query, type, fromIndex, toIndex) {
1440    type = type === undefined ? -1 : type;
1441    return jsRoutes.be.webdeb.presentation.web.controllers.entry.tag.TagActions.searchTag(query, type, fromIndex, toIndex).ajax({ async: true });
1442}
1443
1444/**
1445 * open modal for create a tag category
1446 *
1447 * @param contextId the context where add the tag category
1448 * @param asCategory if the tag must be added as category, false if it is a sub debate of a multiple debate
1449 * @returns {*}
1450 */
1451function newTagCategory(contextId, asCategory) {
1452    return jsRoutes.be.webdeb.presentation.web.controllers.entry.tag.TagActions.newTagCategory(contextId, asCategory).ajax({ async: true });
1453}
1454
1455/**
1456 * Submit a link between tags
1457 *
1458 * @param parent the parent tag id
1459 * @param child the child tag id
1460 * @returns {*|{}}
1460 either an empty ok response (200) or the full page to be reloaded
1461 */
1462function saveTagLink(parent, child) {
1463  return jsRoutes.be.webdeb.presentation.web.controllers.tag.saveTagLink(parent, child).ajax({
1464    type: 'POST',
1465    data: form.serialize(),
1466    async: true
1467  });
1468}
1469
1470/**
1471 * open modal for edit a tag
1472 *
1473 * @param tagId the tag id to edit
1474 * @param contextId the context where add the tag category
1475 * @param fromContribution a contribution id from where we add the citation
1476 * @param asParent true if the fromContribution is a tag, and that tag must be added as parent
1477 * @returns {*}
1478 */
1479function editTag(tagId, contextId, fromContribution, asParent) {
1480    contextId = contextId !== undefined ? contextId : -1;
1481    fromContribution = fromContribution !== undefined ? fromContribution : -1;
1482    asParent = asParent !== undefined ? asParent : true;
1483    return jsRoutes.be.webdeb.presentation.web.controllers.entry.tag.TagActions.editFromModal(tagId, contextId, fromContribution, asParent).ajax({ async: true });
1484}
1485
1486/**
1487 * Handle tag form submission from modal frame
1488 *
1489 * @param form the tag form
1490 * @returns either a bad request with the content of the form in error, or a success status code
1491 */
1492function saveTagFromModal(form) {
1493  return jsRoutes.be.webdeb.presentation.web.controllers.entry.tag.TagActions.saveFromModal().ajax({
1494      type: 'POST',
1495      data: form.serialize(),
1496      async: true
1497  });
1498}
1499
1500/**
1501 * Get all linked contributions with a tag by viz pane type
1502 *
1503 * @param tag the tag id
1504 * @param type the name of the viz pane type
1505 * @param pov for a specific contains in pane, -1 if none
1506 * @returns {*}
1507 */
1508function getTagLinkedContributions(tag, type, pov) {
1509    pov = pov === undefined ? -1 : pov;
1510    return jsRoutes.be.webdeb.presentation.web.controllers.entry.tag.TagActions.getLinkedContributions(tag, type, pov).ajax({ async: true });
1511}
1512
1513/**
1514 * Find the tag hierarchy of the given tag
1515 *
1516 * @param tagId a tag id
1517 * @param forParents true for the parents of the given tag
1518 * @param forContributionType a contribution type if tags must be sorted by linked contributions of given type
1519 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
1520 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
1521 * @param filters a string that contains data for filter results
1522 * @returns {*}
1523 */
1524function findHierarchyFromTag(tagId, forParents, forContributionType, fromIndex, toIndex, filters) {
1525    forParents = forParents != null ? forParents : false;
1526    forContributionType = forContributionType != null ? forContributionType : -1;
1527    fromIndex = fromIndex != null ? fromIndex : -1;
1528    toIndex = toIndex != null ? toIndex : -1;
1529
1530    return jsRoutes.be.webdeb.presentation.web.controllers.entry.tag.TagActions.findHierarchy(tagId, forParents, forContributionType, fromIndex, toIndex, filters).ajax({ async: true });
1531}
1532
1533/*
1534 * DEBATES
1535 */
1536
1537/**
1538 * open modal for edit a debate
1539 *
1540 * @param debateId the debate id to edit
1541 * @param fromContribution a contribution id from where we add the citation
1542 * @returns {*}
1543 */
1544function editDebate(debateId, fromContribution) {
1545    fromContribution = fromContribution === undefined ? -1 : fromContribution;
1546    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.editFromModal(debateId, fromContribution).ajax({ async: true });
1547}
1548
1549/**
1550 * Submit debate form
1551 *
1552 * @param debateId the debate id
1553 * @param form the form with the debate details
1554 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
1555 */
1556function saveDebate(debateId, form) {
1557    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.saveFromModal(debateId).ajax({
1558        type: 'POST',
1559        processData: false,
1560        contentType: false,
1561        data: new FormData(form[0]),
1562        async: true
1563    });
1564}
1565
1566/**
1567 * Validate current step of the given debate form
1568 *
1569 * @param form the debate form to validate
1570 * @returns either a bad request, internal server error, or a success status code
1571 */
1572function debateStepValidation(form) {
1573    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.validateStep().ajax({
1574        type: 'POST',
1575        data: form.serialize(),
1576        async: true
1577    });
1578}
1579
1580/**
1581 * Search for debates with given query
1582 *
1583 * @param query a query string
1584 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
1585 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
1586 * @returns {*}
1587 */
1588function searchDebate(query, fromIndex, toIndex) {
1589    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.searchDebate(query, fromIndex, toIndex).ajax({ async: true });
1590}
1591
1592/**
1593 * Get all linked contributions with a debate by viz pane type
1594 *
1595 * @param debate the debate id
1596 * @param type the name of the viz pane type
1597 * @param pov for a specific contains in pane, -1 if none
1598 * @returns {*}
1599 */
1600function getDebateLinkedContributions(debate, type, pov) {
1601    pov = pov === undefined ? -1 : pov;
1602    return jsRoutes.be.webdeb.presentation.web.controllers.entry.debate.DebateActions.getLinkedContributions(debate, type, pov).ajax({ async: true });
1603}
1604
1605/*
1606 * CONTRIBUTORS and GROUPS
1607 */
1608
1609/**
1610 * Post authenticate with open id
1611 *
1612 * @param form the whole form containing the open id form
1613 * @returns {*}
1614 */
1615function authenticateWithOpenId(form) {
1616    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.authenticateWithOpenId().ajax({
1617        type: 'POST',
1618        data: form,
1619        async: true
1620    });
1621}
1622
1623/**
1624 * Logout and clean the session.
1625 *
1626 * @return the main index page url
1627 */
1628function logoutAsync() {
1629    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.logoutAsync().ajax({ async: true });
1630}
1631
1632/**
1633 * Get edit advices modal page
1634 *
1635 * @returns {*}
1636 */
1637function editAdvices() {
1638    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.editAdvices().ajax({ async: true });
1639}
1640
1641/**
1642 * Post contributors advices
1643 *
1644 * @param form the whole form containing the advices form
1645 * @returns {*}
1646 */
1647function sendAdvices(form) {
1648    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.sendAdvices().ajax({
1649        type: 'POST',
1650        data: new FormData(form[0]),
1651        contentType: false,
1652        processData: false,
1653        async: true
1654    });
1655}
1656
1657/**
1658 * Get contact user to user form
1659 *
1660 * @returns {*}
1661 */
1662function userContactUser(contributor) {
1663    contributor = contributor === undefined ? -1 : contributor;
1664    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.userContactUser(contributor).ajax({ async: true });
1665}
1666
1667/**
1668 * Post contact user to user form
1669 *
1670 * @param form the whole form containing the contact form
1671 * @returns {*}
1672 */
1673function sendUserContactUser(form) {
1674    startWaitingModal();
1675    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.sendUserContactUser().ajax({
1676        type: 'POST',
1677        data: new FormData(form[0]),
1678        contentType: false,
1679        processData: false,
1680        async: true
1681    });
1682}
1683
1684/**
1685 * Get the modal to claim a contributin
1686 *
1687 * @return the modal
1688 */
1689function getClaimContribution(contribution, url) {
1690    startWaitingModal();
1691    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.getClaimContribution(contribution, url).ajax({ async: true });
1692}
1693
1694/**
1695 * Save a contributor claim about a contribution
1696 *
1697 * @form the claim form
1698 * @return ok if saved
1699 */
1700function saveClaimContribution(form) {
1701    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.saveClaimContribution().ajax({
1702        type: 'POST',
1703        contentType: "application/json; charset=utf-8",
1704        data: form,
1705        async: true
1706    });
1707}
1708
1709/**
1710 * Delete given claim
1711 *
1712 * @returns {*}
1713 */
1714function deleteClaim(contribution, contributor) {
1715    startWaitingModal();
1716    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.deleteClaim(contribution, contributor).ajax({ async: true });
1717}
1718
1719/**
1720 * Retrieve claims
1721 *
1722 * @returns {*}
1723 */
1724function retrieveClaims(fromIndex, toIndex) {
1725    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.retrieveClaims(fromIndex, toIndex).ajax({ async: true });
1726}
1727
1728/**
1729 * Get send mail to group modal page
1730 *
1731 * @returns {*}
1732 */
1733function editContributionsToExplore(contributionType) {
1734    contributionType = contributionType === undefined ? -1 : contributionType;
1735    return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.editContributionsToExplore(contributionType).ajax({ async: true });
1736}
1737
1738/**
1739 * Post contributions to explore
1740 *
1741 * @param form the whole form containing the contributions to explore
1742 * @returns {*}
1743 */
1744function sendContributionsToExplore(contributionType, form) {
1745    contributionType = contributionType === undefined ? -1 : contributionType;
1746    return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.sendContributionsToExplore(contributionType).ajax({
1747        type: 'POST',
1748        data: new FormData(form[0]),
1749        contentType: false,
1750        processData: false,
1751        async: true
1752    });
1753}
1754
1755/**
1756 * Get modal frame to search and select after an existing contribution
1757 *
1758 * @param contributionType a given contribution
1759 * @returns {*|{}}
1760 */
1761function contributionSelection(contributionType) {
1762    contributionType = contributionType === undefined ? -1 : contributionType;
1763    return jsRoutes.be.webdeb.presentation.web.controllers.entry.EntryActions.contributionSelection(contributionType).ajax({ async: true });
1764}
1765
1766/**
1767 * Get contact us modal frame to contact administrator
1768 *
1769 * @returns {*}
1770 */
1771function getContactus() {
1772    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.contactus().ajax({ async: true });
1773}
1774
1775/**
1776 * Set contact us modal frame to contact administrator
1777 *
1778 * @param form the whole form containing the contact form
1779 * @returns {*}
1780 */
1781function sendContactus(form) {
1782    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.sendContactus().ajax({
1783        type: 'POST',
1784        data: new FormData(form[0]),
1785        contentType: false,
1786        processData: false,
1787        async: true
1788    });
1789}
1790
1791/**
1792 * Upload a picture for a given contributor (in form)
1793 *
1794 * @param form the form query (post request) with the file and the id to post
1795 * @param contributorId the contributor id for whom we add a new picture
1796 * @returns {*|{}}
1797 */
1798function uploadContributorPicture(form, contributorId) {
1799  return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.uploadContributorPicture(contributorId).ajax({
1800    type: 'POST',
1801    data: new FormData(form[0]),
1802    contentType: false,
1803    processData: false,
1804		async: true
1805  });
1806}
1807
1808/**
1809 * Get modal page to change current user's email
1810 *
1811 * @param id the contributor id (used to check match with user id in session cookie)
1812 * @returns {*|{}}
1813 */
1814function askChangeMail(id) {
1815	return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.askChangeMail(id).ajax({ async: true });
1816}
1817
1818/**
1819 * Send request to change contributor mail
1820 *
1821 * @param id the contributor id asking for the request (used to check match with user id in session cookie)
1822 * @param form the form with the new email
1823 * @returns {*|{}}
1824 */
1825function changeMail(id, form) {
1826	return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.changeMail(id).ajax({
1827		type: 'POST',
1828		data: form.serialize(),
1829		async: true
1830	});
1831}
1832
1833/**
1834 * Get modal page to change current user's password
1835 *
1836 * @param id the contributor id (used to check match with user id in session cookie)
1837 * @returns {*|{}}
1838 */
1839function askChangePassword(id) {
1840	return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.askChangePassword(id).ajax({ async: true });
1841}
1842
1843/**
1844 * Send request to change contributor password
1845 *
1846 * @param id the contributor id asking for the request (used to check match with user id in session cookie)
1847 * @param form the form with the new password
1848 * @returns {*|{}}
1849 */
1850function changePassword(id, form) {
1851	return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.changePassword(id).ajax({
1852		type: 'POST',
1853		data: form.serialize(),
1854		async: true
1855	});
1856}
1857
1858/**
1859 * Get modal page to delete contributor's account
1860 *
1861 * @param id the contributor id (used to check match with user id in session cookie)
1862 * @returns {*|{}}
1863 */
1864function askDeleteAccount(id) {
1865    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.askDeleteAccount(id).ajax({ async: true });
1866}
1867
1868/**
1869 * Send request to delete contributor's account
1870 *
1871 * @param id the contributor id (used to check match with user id in session cookie)
1872 * @param form the form with the deletion
1873 * @returns {*|{}}
1874 */
1875function deleteAccount(id, form) {
1876    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.deleteAccount(id).ajax({
1877        type: 'POST',
1878        data: form.serialize(),
1879        async: true
1880    });
1881}
1882
1883/**
1884 * Get modal page to ask a password recovery
1885 *
1886 * @returns {*}
1887 */
1888function recoverPassword() {
1889	return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.recoverPassword().ajax({ async: true });
1890}
1891
1892/**
1893 * Send request to recover a lost password for email passed in form
1894 *
1895 * @param form a form containing an email
1896 * @returns {*}
1897 */
1898function sendPasswordRecovery(form) {
1899	return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.sendPasswordRecovery().ajax({
1900		type: 'POST',
1901		data: form.serialize(),
1902		async: true
1903	});
1904}
1905
1906/**
1907 * Get modal page to resend the signup mail
1908 *
1909 * @returns {*}
1910 */
1911function resendSignupMail() {
1912    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.resendSignupMail().ajax({ async: true });
1913}
1914
1915/**
1916 * Send the mail to confirme the subscription to WebDeb
1917 *
1918 * @param form a form containing an email
1919 * @returns {*}
1920 */
1921function sendSignupMail(form) {
1922    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.sendSignupMail().ajax({
1923        type: 'POST',
1924        data: form.serialize(),
1925        async: true
1926    });
1927}
1928
1929/**
1930 * Get places by query
1931 *
1932 * @param query the query to excecute
1933 * @returns {*}
1934 */
1935function searchPlace(query){
1936  return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.searchPlace(query).ajax({ async: true });
1937}
1938
1939/**
1940 * Get existing places by query
1941 *
1942 * @param query the query to excecute
1943 * @returns {*}
1944 */
1945function searchExistingPlace(query){
1946    return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.searchExistingPlace(query).ajax({ async: true });
1947}
1948
1949/**
1950 * Set the user warned about old browser danger
1951 *
1952 * @returns {*}
1953 */
1954function userIsBrowserWarned(){
1955  return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.userIsBrowserWarned().ajax({ async: true });
1956}
1957
1958/**
1959 * Leave from given group for current user 
1960 *
1961 * @param group a group id
1962 * @returns {*}
1963 */
1964function leaveGroup(group) {
1965  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.leaveGroup(group).ajax({ async: true });
1966}
1967
1968/**
1969 * Revoke given user from given group
1970 *
1971 * @param user a user id
1972 * @param group a group id
1973 * @param ban true if user must be banned, false to unban
1974 * @returns {*}
1975 */
1976function setBannedInGroup(user, group, ban) {
1977  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.setBannedInGroup(user, group, ban).ajax({ async: true });
1978}
1979
1980/**
1981 * Change default group for current user
1982 *
1983 * @param group a group id
1984 * @returns {*}
1985 */
1986function changeDefaultGroup(group) {
1987  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.changeDefaultGroup(group).ajax({ async: true });
1988}
1989
1990/**
1991 * Get modal page to search for groups
1992 *
1993 * @returns {*}
1994 */
1995function newSubscription() {
1996  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.newSubscription().ajax({ async: true });
1997}
1998
1999/**
2000 * Retrieve a contributor group
2001 *
2002 * @param groupId the id of the group to retrieve
2003 * @returns {*}
2004 */
2005function retrieveContributorGroup(groupId) {
2006  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.retrieveContributorGroup(groupId).ajax({ async: true });
2007}
2008
2009/**
2010 * Search for groups (for typeahead)
2011 * 
2012 * @param query a partial group name to search for
2013 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
2014 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
2015 * @returns {*}
2016 */
2017function searchGroups(query, fromIndex, toIndex) {
2018  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.searchGroups(query, fromIndex, toIndex).ajax({ async: true });
2019}
2020
2021/**
2022 * Search for groups and get partial result page
2023 *
2024 * @param query a partial group name to search for
2025 * @returns {*}
2026 */
2027function getGroupResults(query) {
2028  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.getGroupResults(query).ajax({ async: true });
2029}
2030
2031/**
2032 * Add a contributor (retrieved from passed session cookie) as new member to given group
2033 * 
2034 * @param group a group id
2035 * @returns {*}
2036 */
2037function joinGroup(group) {
2038  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.joinGroup(group).ajax({ async: true });
2039}
2040
2041/**
2042 * Edit details of given group
2043 * 
2044 * @param group a group id 
2045 * @returns {*}
2046 */
2047function editGroup(group) {
2048  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.editGroup(group).ajax({ async: true });
2049}
2050
2051/**
2052 * Save details of given group
2053 *
2054 * @param form the form element containing the data to save
2055 * @returns {*}
2056 */
2057function saveGroup(form) {
2058  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.saveGroup().ajax({
2059    type: 'POST',
2060    data: form.serialize(),
2061		async: true
2062  });
2063}
2064
2065/**
2066 * Empty all contributions and member in given group and possibly delete completely the group itself
2067 * @param group a group id
2068 * @param deleteGroup true if the group itself must be deleted too
2069 * @returns {*}
2070 */
2071function emptyGroup(group, deleteGroup) {
2072	return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.emptyGroup(group, deleteGroup).ajax({ async: true });
2073}
2074
2075/**
2076* Get the list of editable groups
2077*
2078* @returns {*}
2079*/
2080function loadGroups() {
2081    return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.groups().ajax({ async: true });
2082}
2083
2084/**
2085 * Change roles of member inside a given group
2086 * @param group a group id
2087 * @returns {*}
2088 */
2089function changeMembersRole(group) {
2090    return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.changeMembersRole(group).ajax({ async: true });
2091}
2092
2093/**
2094 * Change role of member inside a given group
2095 * @param group a group id
2096 * @param userId the user to change the role if we only change one (-1 otherwise)
2097 * @returns {*}
2098 */
2099function changeMemberRole(group, userId) {
2100  userId = userId || -1;
2101  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.changeMemberRole(group, userId).ajax({ async: true });
2102}
2103
2104/**
2105 * Change members role
2106 *
2107 * @param group a group id
2108 * @param form the form element containing the data to save
2109 * @returns {*}
2110 */
2111function sendChangeMemberRole(group, form) {
2112  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.sendChangeMemberRole(group).ajax({
2113    type: 'POST',
2114    data: form.serialize(),
2115    async: true
2116  });
2117}
2118
2119/**
2120 * Send followed state to given group for given contributor
2121 *
2122 * @param group the id of group to follow
2123 * @param follow the follow state to put
2124 * @returns {*}
2125 */
2126function followGroup(group, follow) {
2127  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.followGroup(group, follow).ajax({ async: true });
2128}
2129
2130/**
2131 * Send followed state for all groups linked with given contributor
2132 *
2133 * @param form the form element containing the data to save
2134 * @returns {*}
2135 */
2136function followGroups(form) {
2137    return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.followGroups().ajax({
2138        type: 'POST',
2139        contentType: "application/json; charset=utf-8",
2140        data: form,
2141        async: true
2142    });
2143}
2144
2145/**
2146 * Apply given role to given contributor in given group
2147 * 
2148 * @param contributor a contributor id
2149 * @param group a group id
2150 * @param role a role id
2151 * @returns {*|{}}
2152 */
2153function changeRole(contributor, group, role) {
2154  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.changeRole(contributor, group, role).ajax({ async: true });
2155}
2156
2157/**
2158 * Get modal page to invite new members in group
2159 * 
2160 * @param group a group id
2161 * @returns {*|{}}
2162 */
2163function inviteInGroup(group) {
2164  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.inviteInGroup(group).ajax({ async: true });
2165}
2166
2167/**
2168 * Send invitations to filled-in persons/emails 
2169 * 
2170 * @param form the form to serialize
2171 * @returns {*|{}}
2172 */
2173function sendInvitations(form) {
2174  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.sendInvitations().ajax({
2175    type: 'POST',
2176    data: form.serialize(),
2177		async: true
2178  });
2179}
2180
2181/**
2182 * Get modal page to send mail to group
2183 *
2184 * @param group a group id
2185 * @returns {*|{}}
2186 */
2187function getMailToGroupModal(group) {
2188  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.getMailToGroupModal(group).ajax({ async: true });
2189}
2190
2191/**
2192 * Send mail to group
2193 *
2194 * @param form the form to serialize
2195 * @returns {*|{}}
2196 */
2197function sendMailToGroup(form) {
2198  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.sendMailToGroup().ajax({
2199    type: 'POST',
2200    data: form.serialize(),
2201    async: true
2202  });
2203}
2204
2205/**
2206 * Search for contributors as a list of contributor holders
2207 * 
2208 * @param query a query string
2209 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
2210 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
2211 * @returns {*}
2212 */
2213function searchContributors(query, fromIndex, toIndex) {
2214  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.searchContributors(query, fromIndex, toIndex).ajax({ async: true });
2215}
2216
2217/**
2218 * Search for contributors as a partial result page (with their groups and roles)
2219 *
2220 * @param query a query string
2221 * @param sort either 'name' or 'date' for resp. sorting the result by name or registration date
2222 * @returns {*}
2223 */
2224function searchContributorsAndRoles(query, sort) {
2225  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.searchContributorsAndRoles(query, sort).ajax({ async: true });
2226}
2227
2228/**
2229 * Search for contributor's contributions
2230 *
2231 * @param searchText a query string
2232 * @param id the contributor id
2233 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
2234 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
2235 * @returns {*}
2236 */
2237function searchContributorContributions(searchText, id, fromIndex, toIndex) {
2238  return jsRoutes.be.webdeb.presentation.web.controllers.account.ContributorActions.searchContributorContributions(searchText, id, fromIndex, toIndex).ajax({ async: true });
2239}
2240
2241/**
2242 * Get the partial page with all csv reports
2243 *
2244 * @param type the contribution type that need reports
2245 */
2246function getCsvReports(type) {
2247	return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.getCsvReports(type).ajax({ async: true });
2248}
2249
2250/**
2251 * Get modal page to upload csv files
2252 *
2253 * @param type the contribution type that need reports
2254 * @returns {*|{}}
2255 */
2256function importCsvFile(type) {
2257	return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.importCsvFile(type).ajax({ async: true });
2258}
2259
2260/**
2261 * Upload given csv file(s) passed in form to be pushed into the DB
2262 *
2263 * @param form the form to serialize (containing the csv file-s-)
2264 * @param type the contribution type that need reports
2265 * @param charset the selected character set for the csv file
2266 * @param delimiter the selected delimiter for the csv file
2267 * @param groupid the group id in which the import must be performed
2268 * @returns {*|{}}
2269 */
2270function uploadCsvFile(form, type, charset, delimiter, groupid) {
2271	return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.uploadCsvFile(type, charset, delimiter, groupid).ajax({
2272		type: 'POST',
2273		data: new FormData(form[0]),
2274		contentType: false,
2275		processData: false,
2276		async: true
2277	});
2278}
2279
2280/**
2281 * Get the list of rss sources (partial html page)
2282 *
2283 * @returns {*}
2284 */
2285function getRssFeeders() {
2286  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.getRssFeeders().ajax({ async: true });
2287}
2288
2289/**
2290 * Get the modal page to edit given rss channel
2291 *
2292 * @returns {*}
2293 */
2294function editRssFeed(id) {
2295  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.editRssFeed(id).ajax({ async: true });
2296}
2297
2298/**
2299 * Activate / Deactivate Rss source feeding
2300 *
2301 * @param id an Rss source id
2302 * @param activate true if this source must be activated
2303 * @returns {*|{}}
2304 */
2305function activateRssFeed(id, activate) {
2306  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.activateRssFeed(id, activate).aja
2306x({ async: true });
2307}
2308
2309/**
2310 * Save given rss feed form
2311 *
2312 * @param form an rss form to save
2313 * @returns {*}
2314 */
2315function saveRssFeed(form) {
2316  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.saveRssFeed().ajax({
2317    type: 'POST',
2318    data: form.serialize(),
2319    async: true
2320  });
2321}
2322
2323/**
2324 * Remove Rss source feeding
2325 *
2326 * @param id an Rss source id
2327 * @returns {*|{}}
2328 */
2329function removeRssFeed(id) {
2330  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.removeRssFeed(id).ajax({ async: true });
2331}
2332
2333/**
2334 * Get the list of twitter accounts (partial html page)
2335 *
2336 * @returns {*}
2337 */
2338function getTwitterAccounts() {
2339  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.getTwitterAccounts().ajax({ async: true });
2340}
2341
2342/**
2343 * Get the modal page to edit given twitter account
2344 *
2345 * @returns {*}
2346 */
2347function editTwitterAccount(id) {
2348  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.editTwitterAccount(id).ajax({ async: true });
2349}
2350
2351/**
2352 * Save given twitter account form
2353 *
2354 * @param form a twitter form to save
2355 * @returns {*}
2356 */
2357function saveTwitterAccount(form) {
2358  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.saveTwitterAccount().ajax({
2359    type: 'POST',
2360    data: form.serialize(),
2361    async: true
2362  });
2363}
2364
2365/**
2366 * Delete Twitter account from feeding sources
2367 *
2368 * @param account a twitter account name
2369 * @returns {*|{}}
2370 */
2371function removeTwitterAcccount(account) {
2372  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.removeTwitterAccount(account).ajax({ async: true });
2373}
2374
2375/**
2376 * Delete TextFreeCopyrightSource
2377 *
2378 * @param idSource the id of the free source to delete
2379 * @returns {*|{}}
2380 */
2381function removeFreeCopyrightSource(idSource) {
2382  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.removeFreeCopyrightSource(idSource).ajax({ async: true });
2383}
2384
2385
2386/*
2387 * PROJECT
2388 */
2389
2390/**
2391 * Get the page to manage given project
2392 *
2393 * @param projectId the project to manage
2394 * @returns {*|{}}
2395 */
2396function manageProject(projectId) {
2397    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.manageProject(projectId).ajax({ async: true });
2398}
2399
2400/**
2401 * Get a project activity modal as project form for the given id
2402 *
2403 * @param projectId the project id
2404 * @returns {*|{}}
2405 */
2406function getProjectActivity(projectId) {
2407    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.getProjectActivity(projectId).ajax({ async: true });
2408}
2409
2410/**
2411 * Generate project users
2412 *
2413 * @param projectId a project id
2414 * @returns {*|{}}
2415 */
2416function generateProjectUsers(projectId) {
2417    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.generateProjectUsers(projectId).ajax({
2418        type: 'POST',
2419        async: true
2420    });
2421}
2422
2423/**
2424 * Delete all project users
2425 *
2426 * @param projectId a project id
2427 * @returns {*|{}}
2428 */
2429function deleteProjectUsers(projectId) {
2430    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.deleteProjectUsers(projectId).ajax({
2431        type: 'POST',
2432        async: true
2433    });
2434}
2435
2436/**
2437 * Get the modal page to edit given project
2438 *
2439 * @param projectId a project id
2440 * @returns {*|{}}
2441 */
2442function editProject(projectId) {
2443    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.editProject(projectId).ajax({ async: true });
2444}
2445
2446/**
2447 * Get the modal page to edit given project group
2448 *
2449 * @param projectId the project id that owns the group
2450 * @param projectGroupId the project group id to edit
2451 * @returns {*|{}}
2452 */
2453function editProjectGroup(projectId, projectGroupId) {
2454    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.editProjectGroup(projectId, projectGroupId).ajax({ async: true });
2455}
2456
2457/**
2458 * Get the modal page to edit given project subgroup
2459 *
2460 * @param projectId the project id context
2461 * @param projectGroupId the project group id that owns the subgroup
2462 * @param projectSubgroupId the project subgroup id to edit
2463 * @returns {*|{}}
2464 */
2465function editProjectSubgroup(projectId, projectGroupId, projectSubgroupId) {
2466    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.editProjectSubgroup(projectId, projectGroupId, projectSubgroupId).ajax({ async: true });
2467}
2468
2469/**
2470 * Submit project form
2471 *
2472 * @param form the form with the project details
2473 * @returns {*|{}}
2473 either an empty ok response (200) or the full page to be reloaded
2474 */
2475function saveProject(form) {
2476    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.saveProject().ajax({
2477        type: 'POST',
2478        data: form.serialize(),
2479        async: true
2480    });
2481}
2482
2483/**
2484 * Submit project group form
2485 *
2486 * @param form the form with the project group details
2487 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
2488 */
2489function saveProjectGroup(form) {
2490    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.saveProjectGroup().ajax({
2491        type: 'POST',
2492        data: form.serialize(),
2493        async: true
2494    });
2495}
2496
2497/**
2498 * Submit project subgroup form
2499 *
2500 * @param form the form with the project subgroup details
2501 * @returns {*|{}} either an empty ok response (200) or the full page to be reloaded
2502 */
2503function saveProjectSubgroup(form) {
2504    return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.project.ProjectActions.saveProjectSubgroup().ajax({
2505        type: 'POST',
2506        data: form.serialize(),
2507        async: true
2508    });
2509}
2510
2511
2512/**
2513 * Change current scope for contributor, ie, update scope id in cookie
2514 * 
2515 * @param group the selected group id (for current scope)
2516 */
2517function changeScope(group) {
2518  return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.changeCurrentScope(group).ajax({ async: true });
2519}
2520
2521/**
2522 * Add given contribution to given group's scope
2523 *
2524 * @param group a group id
2525 * @param contribution a contribution id
2526 * @param type the contribution type id
2527 */
2528function addContributionToGroup(group, contribution, type) {
2529	return jsRoutes.be.webdeb.presentation.web.controllers.account.group.GroupActions.addContributionToGroup(group, contribution, type).ajax({ async: true });
2530}
2531
2532
2533/*
2534 * AJAX-based SEARCH
2535 */
2536
2537/**
2538 * Execute a search query (post request) with a given search form
2539 *
2540 * @param form the form element that will be serialized to be sent to server
2541 * @param card boolean saying if contribution cards must be retrieved (optional, default false)
2542 * @param embedded boolean saying if the search is done from an embedded frame
2543 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
2544 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
2545 * @param filters a string that contains data for filter results
2546 * @returns {*|{}}
2547 */
2548function doSearch(form, card, embedded, fromIndex, toIndex, filters) {
2549    card = typeof card === 'boolean' ? card : false;
2550    embedded = typeof embedded === 'boolean' ? embedded : false;
2551    fromIndex = !isNaN(fromIndex) ? fromIndex : -1;
2552    toIndex = !isNaN(toIndex) ? toIndex : -1;
2553    filters = filters === undefined ? '' : filters;
2554
2555	return jsRoutes.be.webdeb.presentation.web.controllers.browse.BrowseActions.doSearch(card, embedded, fromIndex, toIndex, filters).ajax({
2556    type: 'POST',
2557    data: form.serialize(),
2558		async: true
2559  });
2560}
2561
2562/**
2563 * Search for contributions (auto-complete feature)
2564 *
2565 * @param query the search query
2566 * @param group the group to search for
2567 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
2568 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
2569 * @returns a list of jsonified contribution holders
2570 */
2571function searchContributions(query, group, fromIndex, toIndex) {
2572	return jsRoutes.be.webdeb.presentation.web.controllers.entry.EntryActions.searchContributions(query, group, fromIndex, toIndex).ajax({ async: true });
2573}
2574
2575/**
2576 * Search for professions as a partial result page
2577 *
2578 * @param query a query string
2579 * @param idToIgnore an profession id to ignore
2580 * @param json true if the return must be a json
2581 * @param fromIndex the low endpoint of contributions to retrieve (only strictly positive values are considered)
2582 * @param toIndex the high endpoint of contributions to retrieve (only strictly positive values are considered)
2583 * @returns {*}
2584 */
2585function searchProfessions(query, idToIgnore, json, fromIndex, toIndex) {
2586    idToIgnore = idToIgnore === undefined ? -1 : idToIgnore;
2587  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.searchProfessions(query, idToIgnore, json, fromIndex, toIndex).ajax({ async: true });
2588}
2589
2590/**
2591 * Get modal page to edit profession names
2592 *
2593 * @param profession the profession concerned
2594 * @returns {*|{}}
2595 */
2596function editProfession(profession) {
2597  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.editProfession(profession).ajax({ async: true });
2598}
2599
2600/**
2601 * Confirm the editing of profession names
2602 *
2603 * @param form the form to serialize
2604 * @returns {*|{}}
2605 */
2606function sendEditProfession(form) {
2607  return jsRoutes.be.webdeb.presentation.web.controllers.entry.actor.ActorActions.sendEditProfession(form).aja
2607x({
2608    type: 'POST',
2609    data: form.serialize(),
2610    async: true
2611  });
2612}
2613
2614/**
2615 * Get modal page to edit link between professions
2616 *
2617 * @param profession the profession concerned
2618 * @returns {*|{}}
2619 */
2620function editProfessionHasLink(profession) {
2621  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.editProfessionHasLink(profession).ajax({ async: true });
2622}
2623
2624/**
2625 * Confirm the editing of profession links
2626 *
2627 * @param form the form to serialize
2628 * @returns {*|{}}
2629 */
2630function sendProfessionHasLink(form, id) {
2631  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.sendProfessionHasLink(id).ajax({
2632    type: 'POST',
2633    data: form.serialize(),
2634    async: true
2635  });
2636}
2637
2638/**
2639 * Get modal page to merge professions
2640 *
2641 * @param profession the profession concerned
2642 * @returns {*|{}}
2643 */
2644function mergeProfessions(profession) {
2645  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.mergeProfessions(profession).ajax({ async: true });
2646}
2647
2648/**
2649 * Confirm the merge of professions
2650 *
2651 * @param form the form to serialize
2652 * @returns {*|{}}
2653 */
2654function sendMergeProfessions(form, id) {
2655  return jsRoutes.be.webdeb.presentation.web.controllers.account.admin.AdminActions.sendMergeProfessions(id).ajax({
2656    type: 'POST',
2657    data: form.serialize(),
2658    async: true
2659  });
2660}
2661
2662/*
2663 * OTHERS
2664 */
2665
2666/**
2667 * Get all linked places to a given contribution
2668 *
2669 * @param id a contribution id
2670 * @param selectedPlace the selected place by the user if any
2671 */
2672function getContributionPlaces(id, selectedPlace){
2673    return jsRoutes.be.webdeb.presentation.web.controllers.entry.EntryActions.getContributionPlaces(id, selectedPlace).ajax({ async: true });
2674}
2675
2676/**
2677 * Get the modal frame to search a contribution to merge with given contribution
2678 *
2679 * @param id a contribution id
2680 * @param type its contribution type id
2681 * @returns {*|{}}
2682 */
2683function getMergeContributionModal(id, type) {
2684	return jsRoutes.be.webdeb.presentation.web.controllers.entry.EntryActions.getMergeContributionsModal(id, type).ajax({ async: true });
2685}
2686
2687/**
2688 * Get the modal frame to search a contribution to merge with given contribution
2689 *
2690 * @param id a contribution id
2691 * @param type its contribution type id
2692 * @param group the contributor group
2693 * @param force true to force
2694 * @param noChange true to no change
2695 * @returns {*|{}}
2696 */
2697function deleteContributionAsync(id, type, group, force, noChange) {
2698    group = group !== undefined ? group : 0;
2699    force = force !== undefined ? force : true;
2700    noChange = noChange !== undefined ? noChange : false;
2701    return jsRoutes.be.webdeb.presentation.web.controllers.entry.EntryActions.delete(id, type, group, force, noChange, true).ajax({ async: true });
2702}
2703
2704/**
2705 * Get the modal frame to show the history of a contribution
2706 *
2707 * @param id a contribution id
2708 * @param type its contribution type id
2709 * @returns {*|{}}
2710 */
2711function getContributionHistoryModal(id, type) {
2712	return jsRoutes.be.webdeb.presentation.web.controllers.entry.EntryActions.getContributionHistoryModal(id, type).ajax({ async: true });
2713}
2714
2715/**
2716 * Check if the "accept cookies" message has already been showed on main page
2717 *
2718 * @returns {*}
2719 */
2720function acceptCookies() {
2721  return jsRoutes.be.webdeb.presentation.web.controllers.Application.acceptCookies().ajax({ async: true });
2722}
2723
2724/**
2725 * Check if given picture file is offensive (nudity or violence)
2726 *
2727 * @param form the whole form containing the picture
2728 * @returns {*}
2729 */
2730function checkOffensivePicture(form) {
2731  return jsRoutes.be.webdeb.presentation.web.controllers.Application.checkOffensivePicture().ajax({
2732    type: 'POST',
2733    data: new FormData(form[0]),
2734    contentType: false,
2735    processData: false,
2736    async: true
2737  });
2738}
2739
2740/**
2741 * Get help modal
2742 *
2743 * @returns {*}
2744 */
2745function getHelpModal(names){
2746    return jsRoutes.be.webdeb.presentation.web.controllers.Application.getHelpModal().ajax({
2747        type: 'POST',
2748        contentType: 'application/json',
2749        data: JSON.stringify(names),
2750        async: true
2751    });
2752}
2753
2754/**
2755 * Get a image modal for the given image
2756 *
2757 * @param path the path of the image
2758 * @returns {*}
2759 */
2760function imageModal(path) {
2761    return jsRoutes.be.webdeb.presentation.web.controllers.Application.imageModal(path).ajax({ async: true });
2762}
2763
2764/**
2765 * Display the modal with details about a collaborator
2766 *
2767 * @param id the id of the collaborator
2768 * @returns {*}
2769 */
2770function collaboratorDetails(id) {
2771    return jsRoutes.be.webdeb.presentation.web.controllers.Application.collaboratorDetails(id).ajax({ async: true });
2772}
2773
2774/*
2775 * EXPORTATION
2776 */
2777
2778/**
2779 * Get the complete model description (all classes and attributes)
2780 *
2781 * @returns {*}
2782 */
2783function getModelDescription() {
2784    return jsRoutes.be.webdeb.presentation.web.controllers.Application.getModelDescription().ajax({ async: true });
2785}
2786
2787/**
2788 * Execute the given query to transform into a sql query to perform it into the DB et get the results as a list of list of values.
2789 *
2790 * @param query the query to execute
2791 * @returns {*}
2792 */
2793function executeApiQuery(query) {
2794    return jsRoutes.be.webdeb.presentation.web.controllers.Application.executeApiQuery().ajax({
2795        type: 'POST',
2796        data: query,
2797        async: true
2798    });
2799}
2800
2801/*
2802 * ELECTIONS 2019
2803 */
2804
2805/**
2806 * Get data async about stats page for election 2019
2807 *
2808 * @param id the id of the page
2809 * @return {*}
2810 */
2811function otherElectionStatsPageAsync(id) {
2812    return jsRoutes.be.webdeb.presentation.web.controllers.Application.otherElectionStatsPageAsync(id).ajax({ async: true });
2813}
2814
2815/*
2816 * MANUAL REDIRECTS
2817 * 
2818 * Using the same "pattern" as Play routes file to abstract concrete routes behind javascript functions.
2819 * Must be maintained together with the routes file
2820 */
2821
2822function cancelCitationEdit(textId, excId) {
2823    window.location = "/entry/citation/cancel?textId=" + textId + "&excId=" + excId;
2824}
2825
2826function redirectToEdit(id) {
2827  window.location = "/entry/edit?id=" + id;
2828}
2829
2830function redirectToTextCitations(id) {
2831  window.location = "/entry/text/edit?id=" + id;
2832}
2833
2834function redirectToExplore() {
2835	window.location = "/browse";
2836}
2837
2838function redirectToContribute() {
2839	window.location = "/entry";
2840}
2841
2842function redirectToBrowse(query, contributionId) {
2843    var contribution = (contributionId !== undefined ? "+id_contribution=" + contributionId : "");
2844	window.location = "/browse/query=" + encodeURIComponent(query) + contribution + "+all=true";
2845}
2846
2847function deleteContribution(contribution, type, group, force, noChange) {
2848	window.location = '/entry/delete?id=' + contribution + '&type=' + type + '&group=' + group + '&force=' + force + '&noChange=' + noChange +' &async=false';
2849}
2850
2851function redirectToEditActor(id) {
2852    window.location = "/entry/actor?id=" + id;
2853}
2854
2855function redirectToEditTag(id) {
2856    window.location = "/entry/tag?id=" + id;
2857}
2858
2859function redirectToEditDebate(id) {
2860    window.location = "/entry/debate?id=" + id;
2861}
2862
2863function redirectToEditCitation(id) {
2864    window.location = urlOfEditCitation(id);
2865}
2866
2867function redirectToDoMerge(originId, replacementId, contributionId) {
2868    window.location = "/entry/domerge?origin=" + originId + '&replacement=' + replacementId + '&type=' + contributionId;
2869}
2870
2871function redirectToGivenLink(link) {
2872    window.location = link;
2873}
2874
2875function redirectToLogin() {
2876    let userId = $('#user-id');
2877
2878    if(userId.exists() && userId.val() && userId.val() > 0) {
2879        slideDefaultWarningMessage(Messages('general.contribution.private.edit.msg'));
2880    } else {
2881        window.location = "/login";
2882    }
2883}
2884
2885function redirectToActorViz(id, pane) {
2886    window.location = urlOfActorViz(id, pane);
2887}
2888
2889function redirectToDebateViz(id, pane) {
2890    window.location = urlOfDebateViz(id, pane);
2891}
2892
2893function redirectToTextViz(id, pane, pov) {
2894    window.location = urlOfTextViz(id, pane, pov);
2895}
2896
2897function redirectToTagViz(id, pane) {
2898    window.location = urlOfTagViz(id, pane);
2899}
2900
2901function redirectToDetailsPage(id) {
2902    window.location = urlOfDetailsPage(id);
2903}
2904
2905function redirectToNewCitation(id, excerpt) {
2906    window.location = encodeURI("/entry/citation/new?textId=" + id + "&excerpt=" + excerpt);
2907}
2908
2909function openInNewTab(url){
2910    let win = window.open(url, '_blank');
2911    win.focus();
2912}
2913
2914/*
2915 * URL locations
2916 */
2917
2918function urlOfContribute() {
2919    return '/entry';
2920}
2921
2922function urlOfEditCitation(id) {
2923    return '/entry/citation?id=' + id;
2924}
2925
2926function urlOfDetailsPage(id) {
2927    return '/viz/details/' + id;
2928}
2929
2930function urlOfActorViz(id, pane) {
2931    return '/viz/actor/' + id + (pane !== undefined ? '?pane=' + pane : '');
2932}
2933
2934function urlOfDebateViz(id, pane) {
2935    return '/viz/debate/' + id + (pane !== undefined ? '?pane=' + pane : '');
2936}
2937
2938function urlOfTextViz(id, pane, pov) {
2939    return '/viz/text/' + id +
2940        (pane !== undefined ? '?pane=' + pane : '') +
2941        (pov !== undefined ? '&pov=' + pov : '');
2942}
2943
2944function urlOfTagViz(id, pane) {
2945    return '/viz/tag/' + id + (pane !== undefined ? '?pane=' + pane : '');
2946}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.