|
@@ -345,14 +345,14 @@ $(".next").click(function () {
|
|
|
var step;
|
|
|
let contentIdx = document.querySelectorAll(".txtsrc").length;
|
|
|
for (let i = 1; i < (contentIdx + 1); i++) {
|
|
|
- if ($(`.txtsrc${i}`).val() != "") {
|
|
|
- txtARR.push($(`.txtsrc${i}`).val())
|
|
|
+ if ($(`.txtsrc`).eq(i-1).val() != "") {
|
|
|
+ txtARR.push($(`.txtsrc`).eq(i-1).val())
|
|
|
}
|
|
|
}
|
|
|
let imgIdx = document.querySelectorAll(".imgsrc").length;
|
|
|
for (let i = 1; i < (imgIdx + 1); i++) {
|
|
|
- if ($(`.imgsrc${i}`).val() != "") {
|
|
|
- imgARR.push($(`.imgsrc${i}`).val())
|
|
|
+ if ($(`.imgsrc`).eq(i-1).val() != "") {
|
|
|
+ imgARR.push($(`.imgsrc`).eq(i-1).val())
|
|
|
}
|
|
|
}
|
|
|
multiLang = 0;
|
|
@@ -361,35 +361,35 @@ $(".next").click(function () {
|
|
|
objstr = JSON.stringify(dataOBJ);
|
|
|
console.log(dataOBJ)
|
|
|
jwt_token = get_jwt_token()
|
|
|
- var xhr = new XMLHttpRequest();
|
|
|
- xhr.open("POST", "https://www.choozmo.com:8887/make_anchor_video");
|
|
|
- xhr.setRequestHeader("accept", "application/json");
|
|
|
- xhr.setRequestHeader("Authorization","Bearer "+jwt_token)
|
|
|
- xhr.setRequestHeader("Content-Type", "application/json");
|
|
|
- xhr.onreadystatechange = function () {
|
|
|
- if (xhr.readyState === 4) {
|
|
|
- responseOBJ = JSON.parse(xhr.responseText)
|
|
|
- console.log(responseOBJ.msg);
|
|
|
- //let title = "資料已送出";
|
|
|
- let text;
|
|
|
- if(lan == 'en') {
|
|
|
- //title = 'Submitted Successfully!';
|
|
|
- text = responseOBJ.msg.eng;
|
|
|
- } else {
|
|
|
- text = responseOBJ.msg.zh;
|
|
|
- }
|
|
|
- Swal.fire({
|
|
|
- // title: title,
|
|
|
- icon: 'info',
|
|
|
- text: text,
|
|
|
- confirmButtonColor: '#3085d6',
|
|
|
- });
|
|
|
+ // var xhr = new XMLHttpRequest();
|
|
|
+ // xhr.open("POST", "https://www.choozmo.com:8887/make_anchor_video");
|
|
|
+ // xhr.setRequestHeader("accept", "application/json");
|
|
|
+ // xhr.setRequestHeader("Authorization","Bearer "+jwt_token)
|
|
|
+ // xhr.setRequestHeader("Content-Type", "application/json");
|
|
|
+ // xhr.onreadystatechange = function () {
|
|
|
+ // if (xhr.readyState === 4) {
|
|
|
+ // responseOBJ = JSON.parse(xhr.responseText)
|
|
|
+ // console.log(responseOBJ.msg);
|
|
|
+ // //let title = "資料已送出";
|
|
|
+ // let text;
|
|
|
+ // if(lan == 'en') {
|
|
|
+ // //title = 'Submitted Successfully!';
|
|
|
+ // text = responseOBJ.msg.eng;
|
|
|
+ // } else {
|
|
|
+ // text = responseOBJ.msg.zh;
|
|
|
+ // }
|
|
|
+ // Swal.fire({
|
|
|
+ // // title: title,
|
|
|
+ // icon: 'info',
|
|
|
+ // text: text,
|
|
|
+ // confirmButtonColor: '#3085d6',
|
|
|
+ // });
|
|
|
|
|
|
- }
|
|
|
- };
|
|
|
- var data = renderXHR_data(dataOBJ)
|
|
|
- console.log(data)
|
|
|
- result = xhr.send(objstr);
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ // var data = renderXHR_data(dataOBJ)
|
|
|
+ // console.log(data)
|
|
|
+ // result = xhr.send(objstr);
|
|
|
});
|
|
|
|
|
|
|
|
@@ -557,6 +557,14 @@ function load_data(tid, loaded_data, draft = false) {
|
|
|
txtinput.setAttribute('placeholder', `${i+1}`);
|
|
|
input_sec.appendChild(txtinput);
|
|
|
|
|
|
+ var removeSpan = document.createElement("span");
|
|
|
+ removeSpan.classList.add('remove-btn');
|
|
|
+ removeSpan.setAttribute('data-num', `${i}`);
|
|
|
+ removeSpan.textContent = '刪除';
|
|
|
+ removeSpan.setAttribute('data-bs-toggle', `modal`);
|
|
|
+ removeSpan.setAttribute('data-bs-target', `#deleteSecModal`);
|
|
|
+ input_sec.appendChild(removeSpan);
|
|
|
+
|
|
|
// img url input
|
|
|
var imginput = document.createElement("input");
|
|
|
imginput.setAttribute('type', 'text');
|
|
@@ -597,7 +605,7 @@ function load_data(tid, loaded_data, draft = false) {
|
|
|
input_sec.appendChild(img_box);
|
|
|
document.querySelector('.img-inputTest').append(input_sec);
|
|
|
}
|
|
|
-
|
|
|
+ addRemoveFunc()
|
|
|
}
|
|
|
|
|
|
|
|
@@ -676,6 +684,7 @@ function initial() {
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
renderInputSec(i+1) ;
|
|
|
}
|
|
|
+ addRemoveFunc()
|
|
|
console.log(document.querySelectorAll(".txtsrc").length + 1);
|
|
|
}
|
|
|
|
|
@@ -740,6 +749,7 @@ addsecbtn.addEventListener('click', addsecBlock);
|
|
|
function addsecBlock() {
|
|
|
let newsecIdx = document.querySelectorAll(".input-sec").length + 1;
|
|
|
renderInputSec(newsecIdx);
|
|
|
+ addRemoveFunc()
|
|
|
}
|
|
|
|
|
|
function renderInputSec(i) {
|
|
@@ -790,6 +800,14 @@ function renderInputSec(i) {
|
|
|
img_box.appendChild(imguploadlabel);
|
|
|
imgupload.addEventListener('change', prepareUpload);
|
|
|
|
|
|
+ var removeSpan = document.createElement("span");
|
|
|
+ removeSpan.classList.add('remove-btn');
|
|
|
+ removeSpan.setAttribute('data-num', `${i}`);
|
|
|
+ removeSpan.textContent = '刪除';
|
|
|
+ removeSpan.setAttribute('data-bs-toggle', `modal`);
|
|
|
+ removeSpan.setAttribute('data-bs-target', `#deleteSecModal`);
|
|
|
+ input_sec.appendChild(removeSpan);
|
|
|
+
|
|
|
input_sec.appendChild(img_box);
|
|
|
document.querySelector('.img-inputTest').append(input_sec);
|
|
|
}
|
|
@@ -837,14 +855,14 @@ $('.draft-btn').click(() => {
|
|
|
var step;
|
|
|
let contentIdx = document.querySelectorAll(".txtsrc").length;
|
|
|
for (let i = 1; i < (contentIdx + 1); i++) {
|
|
|
- if ($(`.txtsrc${i}`).val() != "") {
|
|
|
- txtARR.push($(`.txtsrc${i}`).val())
|
|
|
+ if ($(`.txtsrc`).eq(i-1).val() != "") {
|
|
|
+ txtARR.push($(`.txtsrc`).eq(i-1).val())
|
|
|
}
|
|
|
}
|
|
|
let imgIdx = document.querySelectorAll(".imgsrc").length;
|
|
|
for (let i = 1; i < (imgIdx + 1); i++) {
|
|
|
- if ($(`.imgsrc${i}`).val() != "") {
|
|
|
- imgARR.push($(`.imgsrc${i}`).val())
|
|
|
+ if ($(`.imgsrc`).eq(i-1).val() != "") {
|
|
|
+ imgARR.push($(`.imgsrc`).eq(i-1).val())
|
|
|
}
|
|
|
}
|
|
|
let multiLang = 0
|
|
@@ -938,4 +956,19 @@ $("#lang-manu").hide();
|
|
|
$( "#changeLanguage" ).click(function() {
|
|
|
$("#lang-manu").slideToggle();
|
|
|
$("#lang-arrow").toggleClass("arrowdoup");
|
|
|
-});
|
|
|
+});
|
|
|
+
|
|
|
+function addRemoveFunc() {
|
|
|
+ const testRemove = document.querySelectorAll('.remove-btn');
|
|
|
+ [ ...testRemove ].forEach((item) => {
|
|
|
+ item.addEventListener('click', testRemoving)
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function testRemoving(e) {
|
|
|
+ console.log(e.target.parentElement)
|
|
|
+ let el = e.target.parentElement
|
|
|
+ $('.deleteSec').click(function(){
|
|
|
+ el.remove();
|
|
|
+ })
|
|
|
+}
|