| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 | 
							
- $('input[type=file]').on('change', prepareUpload);
 
- // Grab the files and set them to our variable
 
- function prepareUpload(event) {
 
-   files = event.target.files;
 
-   var data = new FormData();
 
-   //data.append('file', $('.img_up1').prop('files')[0]);
 
-   data.append('file', files[0]);
 
-   // append other variables to data if you want: data.append('field_name_x', field_value_x);
 
-   $(this).next().text('');
 
-   $(this).next().html('<img src="static/img/Spinner-1s-181px.gif">');
 
-   $.ajax({
 
-     type: 'POST',
 
-     processData: false, // important
 
-     contentType: false, // important
 
-     data: data,
 
-     url: 'uploadfile',
 
-     dataType: 'json',
 
-     success: function (jsonData) {
 
-       event.target.previousSibling.value =jsonData.msg;
 
-       $(this).prev().val(jsonData.msg);
 
-       event.target.nextSibling.innerHTML = '';
 
-       event.target.nextSibling.textContent = '上傳檔案';
 
-       //console.log($(this).next());
 
-       //$(this).next().html('上傳檔案');
 
-       //$(this).next().text('上傳檔案');
 
-     },
 
-     error: function (error) {
 
-       event.target.nextSibling.innerHTML = '';
 
-       event.target.nextSibling.textContent = '上傳檔案';
 
-       alert('圖片錯誤');
 
-     }
 
-   });
 
- }
 
- const button = document.querySelector('.next');
 
- $(".next").click(function () {
 
-   button.setAttribute('disabled', '');
 
-   setTimeout(function () {
 
-     button.removeAttribute('disabled')
 
-   }, 4000);
 
-   avatar = $('.avatar').val();
 
-   name_title = $('.title_new').val();
 
-   txtARR = [];
 
-   imgARR = [];
 
-   var step;
 
-   for (step = 1; step <= 10; step++) {
 
-     if ($(".txtsrc" + step).val() != "") {
 
-       txtARR.push($(".txtsrc" + step).val())
 
-     }
 
-   }
 
-   var step2;
 
-   for (step2 = 1; step2 <= 10; step2++) {
 
-     if ($(".imgsrc" + step2).val() != "") {
 
-       imgARR.push($(".imgsrc" + step2).val())
 
-     }
 
-   }
 
-   dataOBJ = { "name": name_title, "text_content": txtARR, "image_urls": imgARR, "avatar": avatar, "client_id": client_id }
 
-   objstr = JSON.stringify(dataOBJ);
 
-   console.log(dataOBJ)
 
-   //alert('資料已送出! 請耐心等候')
 
-   $.ajax({
 
-     url: '192.168.1.106:8887/make_anchor_video_v2',
 
-     //url: 'http://www.choozmo.com:8888/qqreq',
 
-     dataType : 'json', // 預期從server接收的資料型態
 
-     contentType : 'application/json; charset=utf-8', // 要送到server的資料型態
 
-     type: 'post',
 
-     data: objstr,
 
-     success: function(suc_data) {
 
-       Swal.fire({
 
-         title: "資料已送出",
 
-         icon: 'success',
 
-         text: `${suc_data.msg}`,
 
-         confirmButtonColor: '#3085d6',
 
-       });  
 
-       },
 
-     //data:JSON.stringify({n1:"12",n2:"22"}),
 
-     error: function (error) {
 
-       console.error(error)
 
-     }
 
-   });
 
-   
 
-   });
 
- $(".gen_avatar").click(function () {
 
-   dataOBJ = { "imgurl": $('.imgsrc').val() }
 
-   objstr = JSON.stringify(dataOBJ);
 
-   console.log(dataOBJ)
 
-   //alert('資料已送出! 請耐心等候')
 
-   $.ajax({
 
-     url: '192.168.1.106:8887/swapFace',
 
-     dataType: 'json', // 預期從server接收的資料型態
 
-     contentType: 'application/json; charset=utf-8', // 要送到server的資料型態
 
-     type: 'post',
 
-     data: objstr,
 
-     success: function (suc_data) {
 
-       alert(suc_data.msg)
 
-     },
 
-     //data:JSON.stringify({n1:"12",n2:"22"}),
 
-     error: function (error) {
 
-       console.error(error)
 
-     }
 
-   });
 
- });
 
- var loaded_data = ''
 
- function openNav() {
 
-   document.getElementById("mySidenav").style.width = "250px";
 
-   document.querySelector('.loader').style.display = "block";
 
-   $.get("192.168.1.106:8887/history_input", function (data, status) {
 
-     console.log(data)
 
-     loaded_data = data
 
-     for (var obj of data) {
 
-       var historyList = document.querySelector('.historyList');
 
-       var list = document.createElement('li');
 
-       list.id = obj.id;
 
-       // div-imgfr
 
-       var divImgfr = document.createElement('div');
 
-       divImgfr.classList.add('item_imgfr');
 
-       var img = document.createElement('img');
 
-       img.setAttribute('src', obj['image_urls'][0]);
 
-       divImgfr.appendChild(img);
 
-       // div-content
 
-       var contentBox = document.createElement('div');
 
-       contentBox.classList.add('content-box');
 
-       var boxTitle = document.createElement('p');
 
-       boxTitle.classList.add('box-title');
 
-       boxTitle.textContent = obj.name;
 
-       boxTitle.id = obj.id;
 
-       boxTitle.setAttribute('onclick', 'load_data()');
 
-       var boxLink = document.createElement('span');
 
-       boxLink.classList.add('box-link');
 
-       boxLink.setAttribute("data-url", obj.link);
 
-       boxLink.setAttribute('onclick', 'view()');
 
-       boxLink.innerHTML = '<i class="fas fa-play-circle me-1"></i>觀看影片';
 
-       contentBox.appendChild(boxTitle);
 
-       contentBox.appendChild(boxLink);
 
-       list.classList.add("historyList-item");
 
-       list.setAttribute('onclick', 'load_data()');
 
-       list.appendChild(divImgfr);
 
-       list.appendChild(contentBox);
 
-       historyList.appendChild(list);
 
-     }
 
-     document.querySelector('.loader').style.display = "none";
 
-   });
 
- }
 
- function closeNav() {
 
-   document.getElementById("mySidenav").style.width = "250px";
 
- }
 
- function view() {
 
-   event.stopPropagation();
 
-   console.log(event.target);
 
-   if(event.target.nodeName === 'I') {
 
-     return;
 
-   } else {
 
-     window.open(`http://${event.target.dataset.url}`, '_blank');
 
-   }
 
- }
 
- function load_data() {
 
-   var title = document.getElementById("title");
 
-   var linker = document.getElementById("linker");
 
-   myModal.hide()
 
-   tid = event.srcElement.id
 
-   console.log(tid);
 
-   linker.setAttribute('href', `http://${loaded_data.find(item => item.id == tid).link}`)
 
-   linker.setAttribute('target', '_blank')
 
-   $("#linker").html(`http://${loaded_data.find(item => item.id == tid).link}`)
 
-   $("#linker").show();
 
-   $(".linker__box").show();
 
-   $(".title_new").val(loaded_data.find(item => item.id == tid).name)
 
-   var step;
 
-   for (step = 1; step <= 10; step++) {
 
-     $(".txtsrc" + step).val(loaded_data.find(item => item.id == tid).text_content[step - 1])
 
-   }
 
-   var step2;
 
-   for (step2 = 1; step2 <= 10; step2++) {
 
-     $(".imgsrc" + step2).val(loaded_data.find(item => item.id == tid).image_urls[step2 - 1])
 
-   }
 
- }
 
 
  |