script_msg.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //jQuery time
  2. var current_fs, next_fs, previous_fs; //fieldsets
  3. var left, opacity, scale; //fieldset properties which we will animate
  4. var animating; //flag to prevent quick multi-click glitasdaches
  5. $(".next").click(function(){
  6. if( !validate() ){
  7. return false;
  8. }
  9. avatar = $('.avatar').val();
  10. name_title = $('.title_new').val();
  11. txtARR=[];
  12. imgARR=[];
  13. var step;
  14. for (step = 1; step <= 10; step++) {
  15. if($(".txtsrc"+step).val()!=""){
  16. txtARR.push($(".txtsrc"+step).val())
  17. }
  18. }
  19. var step2;
  20. for (step2 = 1; step2 <= 10; step2++) {
  21. if($(".imgsrc"+step2).val()!=""){
  22. imgARR.push($(".imgsrc"+step2).val())
  23. }
  24. }
  25. dataOBJ = {"name":name_title,"text_content":txtARR,"image_urls":imgARR,"avatar":avatar}
  26. objstr = JSON.stringify(dataOBJ);
  27. console.log(dataOBJ)
  28. alert('資料已送出! 請耐心等候')
  29. $.ajax({
  30. url: 'http://www.choozmo.com:8888/make_anchor_video_v2',
  31. //url: 'http://www.choozmo.com:8888/qqreq',
  32. dataType : 'json', // 預期從server接收的資料型態
  33. contentType : 'application/json; charset=utf-8', // 要送到server的資料型態
  34. type: 'post',
  35. data: objstr,
  36. success: function(suc_data) {
  37. },
  38. //data:JSON.stringify({n1:"12",n2:"22"}),
  39. error: function (error) {
  40. console.error(error)
  41. }
  42. });
  43. });
  44. var loaded_data = ''
  45. function openNav() {
  46. document.getElementById("mySidenav").style.width = "250px";
  47. $.get("http://www.choozmo.com:8888/history_input", function(data, status){
  48. console.log(data)
  49. loaded_data = data
  50. for (var obj of data) {
  51. var sideBAR = document.getElementById('mySidenav')
  52. var message = document.createElement('a')
  53. var content = document.createTextNode(obj.name)
  54. message.id = obj.id
  55. message.setAttribute('href', "#")
  56. message.setAttribute('onclick', "load_data()")
  57. message.appendChild(content)
  58. sideBAR.appendChild(message)
  59. }
  60. });
  61. }
  62. function closeNav() {
  63. document.getElementById("mySidenav").style.width = "0";
  64. }
  65. function load_data(){
  66. var title = document.getElementById("title")
  67. tid = event.srcElement.id
  68. console.log(tid);
  69. $(".title_new").val(loaded_data.find(item => item.id == tid).name)
  70. var step;
  71. for (step = 1; step <= 10; step++) {
  72. $(".txtsrc"+step).val(loaded_data.find(item => item.id == tid).text_content[step-1])
  73. }
  74. var step2;
  75. for (step2 = 1; step2 <= 10; step2++) {
  76. $(".imgsrc"+step2).val(loaded_data.find(item => item.id == tid).image_urls[step2-1])
  77. }
  78. }