فهرست منبع

feat: update the video when the form is submit

Corentin NELHOMME 1 سال پیش
والد
کامیت
5c543e06ce
4فایلهای تغییر یافته به همراه34 افزوده شده و 16 حذف شده
  1. 22 6
      index.js
  2. 10 5
      nse.css
  3. 0 3
      nseImageEditorImage.js
  4. 2 2
      video.html

+ 22 - 6
index.js

@@ -1303,6 +1303,9 @@ let NEWSITEEDITOR = (function () {
       const title = document.getElementById(videoTitleInput)?.value?.trim();
       const ariaLabel = document.getElementById(ariaLabelInput)?.value?.trim();
 
+      const button = document.getElementById(buttonId);
+      const currentId = button.getAttribute("data-currentId");
+
       if (!poster && !video && !title && !ariaLabel) {
         hideModal();
         return;
@@ -1316,14 +1319,27 @@ let NEWSITEEDITOR = (function () {
       if (ariaLabel) formData.append("ariaLabel", ariaLabel);
       formData.append("videoId", Math.random() * 10000000);
 
-      await fetch("http://localhost/php/test.php", {
+      const response = await fetch("http://localhost/php/test.php", {
         method: "POST",
         body: formData,
-      })
-        .then((res) => res.json())
-        .then(console.log)
-        .then(hideModal())
-        .catch(console.error);
+      });
+
+      const result = await response.json();
+
+      const videoOldInfo = videoInfos.get(currentId);
+
+      videoInfos.set(currentId, {
+        poster: result.files.poster ? 'http://localhost/php/' + result.files.poster : videoOldInfo.poster,
+        src: result.files.video ? 'http://localhost/php/' + result.files.video : videoOldInfo.src,
+        title: result.title ?? videoOldInfo.title,
+        aria: result.text ?? videoOldInfo.aria,
+      });
+
+      const player = videojs(currentId);
+      player.poster('http://localhost/php/' + result.files.poster);
+      player.src({ src: 'http://localhost/php/' + result.files.video, type: "video/mp4" }); 
+
+      hideModal();
     }
   }
 

+ 10 - 5
nse.css

@@ -43,7 +43,7 @@ border-radius: 11px;
 */
 .fred .fred--launcher_btn_undo {
     background-color: #ed673e;
-    background-image: url("../images/back1.png");
+    background-image: url("https://onehealth-dev.livinweb.fr/assets/components/website/newsiteeditor/images/back1.png");
     position: absolute;
     bottom: 5px;
     left: 73px;
@@ -51,7 +51,7 @@ border-radius: 11px;
 
 .fred .fred--launcher_btn_redo {
     background-color: #0132b5;
-    background-image: url("../images/back2.png");
+    background-image: url("https://onehealth-dev.livinweb.fr/assets/components/website/newsiteeditor/images/back2.png");
     position: absolute;
     bottom: 5px;
     left: 132px;
@@ -59,7 +59,7 @@ border-radius: 11px;
 
 .fred .fred--launcher_btn_view {
     background-color: #549c89;
-    background-image: url("../images/symbole-de-l-oeil-noir.png");
+    background-image: url("https://onehealth-dev.livinweb.fr/assets/components/website/newsiteeditor/images/symbole-de-l-oeil-noir.png");
     position: absolute;
     bottom: 125px;
     left: 73px;
@@ -67,7 +67,7 @@ border-radius: 11px;
 
 .fred .fred--launcher_btn_edit {
     background-color: #549c89;
-    background-image: url("../images/650143.png");
+    background-image: url("https://onehealth-dev.livinweb.fr/assets/components/website/newsiteeditor/images/650143.png");
     position: absolute;
     bottom: 5px;
 }
@@ -76,7 +76,7 @@ border-radius: 11px;
     position: absolute;
     bottom: 65px ;
     left: 73px ;
-    background-image: url("../images/Settings-icon-symbol-vector.png");
+    background-image: url("https://onehealth-dev.livinweb.fr/assets/components/website/newsiteeditor/images/Settings-icon-symbol-vector.png");
     background-color : grey;
 }
 
@@ -198,6 +198,10 @@ label[for="paddingTop"],[for="paddingBottom"]{
     cursor: pointer;
 }
 
+.defaultNseButton.close {
+    background: #ed673e !important;
+}
+
 .defaultNseButton[data-movable] {
     position: absolute;
     z-index: 20000;
@@ -210,6 +214,7 @@ label[for="paddingTop"],[for="paddingBottom"]{
     top: 0;
     height: 100vh;
     width: 100%;
+    z-index: 10000;
     background-color: rgba(0, 0, 0, 0.247);
     justify-content: center;
     align-items: center;

+ 0 - 3
nseImageEditorImage.js

@@ -1,3 +0,0 @@
-
-
-

+ 2 - 2
video.html

@@ -54,7 +54,7 @@
               <div id="uppy-poster"></div>
 
                 <div class="modalButtonContainer">
-                  <button id="closeVideoModal" class="defaultNseButton">Close</button>
+                  <button id="closeVideoModal" class="defaultNseButton close">Close</button>
                   <button id="nextToVideo" class="defaultNseButton">
                     Next to Video
                   </button>
@@ -75,7 +75,7 @@
               </div>
 
               <div class="previewCenter">
-              <video controls class="preview" id="videoPreview"></video>
+              <video autoplay controls class="preview" id="videoPreview"></video>
                </div> 
 
               <div id="uppy-video"></div>