Jelajahi Sumber

refactor getImgElements naming

weichen 4 tahun lalu
induk
melakukan
4d76652f58
1 mengubah file dengan 13 tambahan dan 13 penghapusan
  1. 13 13
      backstage/static/js/blockElements.js

+ 13 - 13
backstage/static/js/blockElements.js

@@ -38,15 +38,15 @@ function getdescElements(blockDiv) {
 }
 
 function getImgElements(blockDiv) {
-  const imgDiv = document.createElement("div");
+  const div = document.createElement("div");
   const img = document.createElement("img");
-  const imgInput = document.createElement("INPUT");
+  const input = document.createElement("INPUT");
   const widthInput = document.createElement("INPUT");
   const heightInput = document.createElement("INPUT");
-  const imgInputButton = document.createElement('button');
-  const imgRemoveButton = document.createElement('button');
-  imgInput.setAttribute("type", "file");
-  imgInput.addEventListener('change', function(event) {
+  const inputButton = document.createElement('button');
+  const removeButton = document.createElement('button');
+  input.setAttribute("type", "file");
+  input.addEventListener('change', function(event) {
     if (event.target.files[0]) {
       let formData = new FormData();
       formData.append('image', event.target.files[0])
@@ -57,16 +57,16 @@ function getImgElements(blockDiv) {
       })
     }
   });
-  imgInputButton.textContent = 'Image新增/修改';
-  imgRemoveButton.textContent = 'Image刪除';
-  blockDiv.appendChild(imgDiv);
-  imgDiv.append(img, imgInput, widthInput, heightInput, imgInputButton, imgRemoveButton);
+  inputButton.textContent = 'Image新增/修改';
+  removeButton.textContent = 'Image刪除';
+  blockDiv.appendChild(div);
+  div.append(img, input, widthInput, heightInput, inputButton, removeButton);
   return {
     img: img,
-    imgInput: imgInput,
+    imgInput: input,
     widthInput: widthInput,
     heightInput: heightInput,
-    imgInputButton: imgInputButton,
-    imgRemoveButton: imgRemoveButton
+    imgInputButton: inputButton,
+    imgRemoveButton: removeButton
   };
 }