diff options
author | polo <ordipolo@gmx.fr> | 2025-03-31 22:50:11 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-03-31 22:50:11 +0200 |
commit | 7f13ca69bb71a0eb477cbf4f4bfcd08b2843bf9b (patch) | |
tree | 93cdc918764a09c1ebde1cea0c25f24324834850 /public/js/main.js | |
parent | 43c962f442165327d73756c62501ff823d43f9f3 (diff) | |
download | cms-7f13ca69bb71a0eb477cbf4f4bfcd08b2843bf9b.zip |
inversion de deux articles
Diffstat (limited to 'public/js/main.js')
-rw-r--r-- | public/js/main.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/public/js/main.js b/public/js/main.js index c86ec51..d985b71 100644 --- a/public/js/main.js +++ b/public/js/main.js | |||
@@ -27,4 +27,51 @@ function copyInClipBoard(link){ | |||
27 | element.parentNode.removeChild(element); | 27 | element.parentNode.removeChild(element); |
28 | 28 | ||
29 | alert('Cette adresse a été copiée dans le presse-papier:\n\n' + link); | 29 | alert('Cette adresse a été copiée dans le presse-papier:\n\n' + link); |
30 | } | ||
31 | |||
32 | // complète les fonctions dans tinymce.js | ||
33 | function switchPositions(articleId, direction) | ||
34 | { | ||
35 | const current_article = document.getElementById(articleId).parentElement.parentElement; | ||
36 | var other_article = current_article; | ||
37 | |||
38 | if(direction == 'down'){ | ||
39 | other_article = current_article.nextElementSibling; | ||
40 | } | ||
41 | else if(direction == 'up'){ | ||
42 | other_article = current_article.previousElementSibling; | ||
43 | } | ||
44 | const other_article_id = other_article.querySelector('div[id]').id; | ||
45 | |||
46 | fetch('index.php?action=switch_positions', { | ||
47 | method: 'POST', | ||
48 | headers: { | ||
49 | 'Content-Type': 'application/json' | ||
50 | }, | ||
51 | body: JSON.stringify({ id1: articleId, id2: other_article_id }) | ||
52 | }) | ||
53 | .then(response => response.json()) | ||
54 | .then(data => { | ||
55 | if(data.success) | ||
56 | { | ||
57 | if(direction == 'down'){ | ||
58 | current_article.parentElement.insertBefore(other_article, current_article); | ||
59 | console.log('Inversion réussie'); | ||
60 | } | ||
61 | else if(direction == 'up'){ | ||
62 | other_article.parentElement.insertBefore(current_article, other_article); | ||
63 | console.log('Inversion réussie'); | ||
64 | } | ||
65 | else{ | ||
66 | console.log('Échec de l\'inversion'); | ||
67 | } | ||
68 | } | ||
69 | else { | ||
70 | |||
71 | console.log('Échec de l\'inversion'); | ||
72 | } | ||
73 | }) | ||
74 | .catch(error => { | ||
75 | console.error('Erreur:', error); | ||
76 | }); | ||
30 | } \ No newline at end of file | 77 | } \ No newline at end of file |