浏览代码

user fomr added

ming 3 年之前
父节点
当前提交
eb6dfc3059
共有 4 个文件被更改,包括 739 次插入1 次删除
  1. 73 0
      index2.html
  2. 6 1
      main.py
  3. 221 0
      script_msg.js
  4. 439 0
      style.css

+ 73 - 0
index2.html

@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html lang="en" >
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>幸福空間 - 問卷調查</title>
+  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
+  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp"
+    crossorigin="anonymous">
+  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
+  <link rel="stylesheet" href="./style.css">
+  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
+</head>
+<body>
+  <div class="container">
+   
+
+    <form action="/step_questions/submit" method="post" id="msform">
+      
+      <!-- fieldsets -->
+      <fieldset>
+        <h2 class="fs-title">AI ANCHOR</h2>
+        <h3 class="fs-subtitle">標題</h3>
+        <input type="text" name='t1' class='title_new' value="" placeholder="1" /> <br/>
+        <h3 class="fs-subtitle">台詞</h3>
+        <input type="text" name='t1' class='txtsrc1' value="" placeholder="1" /> <br/>
+        <input type="text" name='t2' class='txtsrc2' value="" placeholder="2" /><br/>
+        <input type="text" name='t3' class='txtsrc3' value="" placeholder="3" /><br/>
+        <input type="text" name='t4'  class='txtsrc4' value="" placeholder="4" /><br/>
+        <input type="text" name='t5' class='txtsrc5' value="" placeholder="5" /><br/>
+        <input type="text" name='t6' class='txtsrc6' value="" placeholder="6" /><br/>
+        <input type="text" name='t7' class='txtsrc7' value="" placeholder="7" /><br/>
+        <input type="text" name='t8' class='txtsrc8' value="" placeholder="8" /><br/>
+        <input type="text" name='t9' class='txtsrc9' value="" placeholder="9" /><br/>
+        <input type="text" name='t10' class='txtsrc10' value="" placeholder="10" /><br/>
+        <h3 class="fs-subtitle">影像連結</h3>
+        <input type="text" name='m1' class='imgsrc1' value="" placeholder="1" /> <br/>
+        <input type="text" name='m2' class='imgsrc2' value="" placeholder="2" /><br/>
+        <input type="text" name='m3' class='imgsrc3' value="" placeholder="3" /><br/>
+        <input type="text" name='m4' class='imgsrc4' value="" placeholder="4" /><br/>
+        <input type="text" name='m5' class='imgsrc5' value="" placeholder="5" /><br/>
+        <input type="text" name='m6' class='imgsrc6' value="" placeholder="6" /><br/>
+        <input type="text" name='m7' class='imgsrc7' value="" placeholder="7" /><br/>
+        <input type="text" name='m8' class='imgsrc8' value="" placeholder="8" /><br/>
+        <input type="text" name='m9' class='imgsrc9' value="" placeholder="9" /><br/>
+        <input type="text" name='m10' class='imgsrc10' value="" placeholder="10" /><br/>
+        <input id="checker" type="button" name="next" class="next action-button" value="送出" />
+        
+      </fieldset>
+    </form>
+        
+    <div class="text-center">
+
+
+
+    </div>
+
+    <!-- <footer>
+      <img class="img-fluid mb-3" src="images/banner-bottom.jpg" alt="幸福空間 - 裝修市場問卷調查">
+
+      <div class="footer">
+        <div class="text-center">
+          <img class="img-fluid" src="images/banner-bottom.jpg" alt="幸福空間 - 裝修市場問卷調查">
+        </div>
+      </div>
+    </footer> -->
+  </div>
+  
+  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
+  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script>
+  <script src="./script_msg.js"></script>
+</body>
+</html>

+ 6 - 1
main.py

@@ -20,6 +20,9 @@ import math
 import hashlib
 import re
 import urllib.request
+from fastapi.responses import HTMLResponse
+from fastapi.staticfiles import StaticFiles
+from fastapi.templating import Jinja2Templates
 #service nginx restart
 #
 
@@ -52,7 +55,9 @@ class anchor_request(BaseModel):
 async def root():
     return {"message": "Hello, this is index"}
 
-
+@app.post("/index")
+async def input_table():
+    return templates.TemplateResponse("index2.html")
 
 @app.post("/make_video_req")
 async def make_video_req(req:request):

+ 221 - 0
script_msg.js

@@ -0,0 +1,221 @@
+//jQuery time
+var current_fs, next_fs, previous_fs; //fieldsets
+var left, opacity, scale; //fieldset properties which we will animate
+var animating; //flag to prevent quick multi-click glitches
+
+$(".next").click(function(){
+  if( !validate() ){
+    return false;
+  }
+  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}
+  console.log(txtARR);
+  console.log(imgARR);
+ 
+  $.ajax({
+	url: 'http://www.choozmo.com:8888/docs/make_anchor_video_v2',
+	type: 'post',
+	dataType: 'json',
+	data: dataOBJ,
+	success: function(data) {
+	  showThankyou();
+	},
+	error: function (error) {
+		console.error(error)
+	}
+});
+	if(animating) return false;
+	animating = true;
+	
+	current_fs = $(this).parent();
+	next_fs = $(this).parent().next();
+	
+	$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
+	
+	//show the next fieldset
+	next_fs.show(); 
+	//hide the current fieldset with style
+	current_fs.animate({opacity: 0}, {
+		step: function(now, mx) {
+			//as the opacity of current_fs reduces to 0 - stored in "now"
+			//1. scale current_fs down to 80%
+			scale = 1 - (1 - now) * 0.2;
+			//2. bring next_fs from the right(50%)
+			left = (now * 50)+"%";
+			//3. increase opacity of next_fs to 1 as it moves in
+			opacity = 1 - now;
+			current_fs.css({
+        'transform': 'scale('+scale+')',
+        'position': 'absolute'
+      });
+			next_fs.css({'left': left, 'opacity': opacity});
+		}, 
+		duration: 800, 
+		complete: function(){
+			current_fs.hide();
+			animating = false;
+		}, 
+		//this comes from the custom easing plugin
+		easing: 'easeInOutBack'
+	});
+});
+
+$(".previous").click(function(){
+	if(animating) return false;
+	animating = true;
+	
+	current_fs = $(this).parent();
+	previous_fs = $(this).parent().prev();
+	
+	//de-activate current step on progressbar
+	$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
+	
+	//show the previous fieldset
+	previous_fs.show(); 
+	//hide the current fieldset with style
+	current_fs.animate({opacity: 0}, {
+		step: function(now, mx) {
+			//as the opacity of current_fs reduces to 0 - stored in "now"
+			//1. scale previous_fs from 80% to 100%
+			scale = 0.8 + (1 - now) * 0.2;
+			//2. take current_fs to the right(50%) - from 0%
+			left = ((1-now) * 50)+"%";
+			//3. increase opacity of previous_fs to 1 as it moves in
+			opacity = 1 - now;
+			current_fs.css({'left': left});
+			previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
+		}, 
+		duration: 800, 
+		complete: function(){
+			current_fs.hide();
+			animating = false;
+		}, 
+		//this comes from the custom easing plugin
+		easing: 'easeInOutBack'
+	});
+});
+
+
+$("input[name=submit]").click(function(){
+	let stop;
+	   console.log($("#msform").serialize());
+	   
+   	if( $('input[name="q9"]:visible').val() !== undefined && !$('input[name="q9"]:visible').prop('checked') ) {
+		stop = 1;
+		$('#term-error').text('必須同意免責聲明與隱私使用政策');
+	}else {
+		stop = 0;
+		$('#term-error').text('');
+	}
+	if(stop == 0) {
+		/* $.ajax({
+			url: '/step_questions/submit',
+			type: 'post',
+			dataType: 'json',
+			data: $("#msform").serialize(),
+			success: function(data) {
+			  showThankyou();
+			},
+			error: function (error) {
+				console.error(error)
+			}
+		}); */
+		showThankyou();
+	}
+});
+
+// 依據管道導頁
+function showThankyou() {
+	document.location = '/a1/index_complete_msg.html';
+	// document.location = '/a1/index_complete_line.html';
+}
+// 跳離頁面
+$('.btn-exit').click(function() {
+	document.location = 'https://hhh.com.tw/';
+})
+
+$('.btn-term-exit').click(function () {
+	self.opener = null;
+	self.close();
+})
+
+function show_input_text(checkbox_id, input_id) {
+	var checkBox = document.getElementById(checkbox_id);
+	var inp = document.getElementById(input_id);
+	if (checkBox.checked == true){
+	  inp.style.display = "block";
+	} else {
+	  inp.style.display = "none";
+	}
+}
+
+function validate() {
+  function q2_validate() { 
+	let phoneno = /^\d{10}$/;
+    if( $('input[name="q2"]:visible').val() !== undefined && $('input[name="q2"]:visible').val().length <= 0) {
+      $('input[name="q2"]:visible').addClass('error');
+      if( !$('.error-text').length )
+          $('input.error').after('<p class="error-text">請輸入正確手機號碼</p>');
+      return false;
+    } else if($('input[name="q2"]:visible').val() !== undefined && !phoneno.test($('input[name="q2"]:visible').val())){
+		$('input[name="q2"]:visible').addClass('error');
+      if( !$('.error-text').length )
+          $('input.error').after('<p class="error-text">請輸入正確手機號碼</p>');
+      return false;
+	}else {
+        $('input[name="q2"]:visible').removeClass('error');
+        $('.error-text').remove();
+        return true;
+    }
+  }
+
+  function q3_validate() {
+	  let emailPattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+    if( $('input[name="q3"]:visible').val() !== undefined && $('input[name="q3"]:visible').val().length <= 0) {
+      $('input[name="q3"]:visible').addClass('error');
+      if( !$('.error-text').length )
+          $('input.error').after('<p class="error-text">請輸入E-mail</p>');
+      return false;
+    } else if ( $('input[name="q3"]:visible').val() !== undefined && !emailPattern.test($('input[name="q3"]:visible').val()) ){
+		$('input[name="q3"]:visible').addClass('error');
+      	if( !$('.error-text').length )
+          $('input.error').after('<p class="error-text">請輸入正確email格式</p>');
+      	return false;
+	}
+    else {
+        $('input[name="q3"]:visible').removeClass('error');
+        $('.error-text').remove();
+        return true;
+    }
+  }
+
+  function q4_validate() {
+	  if( $('input[name="q4"]:visible').val() !== undefined && $('input[name="q4"]:visible').val().length <= 0 ) {
+		$('input[name="q4"]:visible').addClass('error');
+		if( !$('.error-text').length )
+			$('input.error').after('<p class="error-text">請輸入建案名稱</p>');
+		return false;
+	  } 
+	  else {
+		$('input[name="q4"]:visible').removeClass('error');
+        $('.error-text').remove();
+        return true;
+	  }
+  }
+
+  return q2_validate() && q3_validate() && q4_validate();
+}

+ 439 - 0
style.css

@@ -0,0 +1,439 @@
+/*custom font*/
+@import url(https://fonts.googleapis.com/css?family=Montserrat);
+
+/*basic reset*/
+* {margin: 0; padding: 0;}
+
+html {
+	min-height: 100%;
+	height: auto;
+	/*Image only BG fallback*/
+	
+	/*background = gradient + image pattern combo*/
+	/* background: 
+		linear-gradient(rgba(196, 102, 0, 0.6), rgba(155, 89, 182, 0.6)); */
+}
+
+body {
+	font-family: montserrat, arial, verdana;
+	background-color: white;
+	font-size: 1.05rem;
+}
+
+.ml {
+	margin-left: 10px;
+}
+
+.mr {
+	margin-right: 10px;
+}
+
+.mb {
+	margin-bottom: 12px;
+}
+
+.top {
+	margin-top: 20px;
+	position: sticky;
+	top: 0;
+	left: 50%;
+	z-index: 20;
+	background-color: inherit;
+}
+
+.navbar {
+	background-color: white;
+}
+
+/* .imf {
+	position: fixed;
+	top: 0;
+	left: 50%;
+	transform: translateX(-50%);
+	z-index: 3;
+} */
+
+.img_banner {
+	background-image: url('images/banner_top1.jpg');
+	background-repeat: no-repeat;
+	background-size: contain;
+	background-position: center;
+	width: 100%;
+	height: 65px;
+}
+
+/*form styles*/
+.img_logo {
+	display: inline-block;
+	margin: 0 auto;
+	margin-bottom: 10px;
+}
+
+.title__block {
+	display: flex;
+	justify-content: center;
+	align-items: center;
+	margin: 0px auto;
+}
+
+.sub-logo {
+	display: inline-block;
+	font-weight: 700;
+	font-size: 1.4rem;
+	color: white;
+}
+
+.slogan {
+	display: block;
+	font-weight: 700;
+	font-size: 1.2rem;
+	color: white;
+}
+
+.notice_card {
+	box-sizing: border-box;
+	width: 80%;
+	margin: 0 10%;
+	margin-bottom: 1.5rem;
+	background: white;
+	border: 0 none;
+	border-radius: 3px;
+	box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
+	padding: 10px 20px;
+	line-height: 1.5rem;
+}
+
+/*form styles*/
+#msform {
+	min-width: 370px;
+	max-width: 1000px;
+	margin: 50px auto;
+	margin-bottom: 20px;
+	text-align: center;
+	position: relative;
+}
+#msform fieldset {
+	background: white;
+	border: 0 none;
+	border-radius: 3px;
+	box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
+	padding: 20px 30px;
+	box-sizing: border-box;
+	width: 80%;
+	margin: 0 10%;
+	
+	/*stacking fieldsets above each other*/
+	position: relative;
+}
+/*Hide all except first fieldset*/
+#msform fieldset:not(:first-of-type) {
+	display: none;
+}
+/*inputs*/
+#msform input[type="text"], #msform textarea, #msform input[type="email"] {
+	padding: 15px;
+	border: 1px solid #ccc;
+	border-radius: 3px;
+	margin-bottom: 16px;
+	width: 100%;
+	box-sizing: border-box;
+	font-family: montserrat;
+	color: #2C3E50;
+	font-size: 14px;
+}
+/*buttons*/
+#msform .action-button {
+	width: 100px;
+	background: #27AE60;
+	font-weight: bold;
+	color: white;
+	border: 0 none;
+	border-radius: 1px;
+	cursor: pointer;
+	padding: 10px 5px;
+	margin: 10px auto;
+	display: inline-block;
+}
+#msform .action-button:hover, #msform .action-button:focus {
+	box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
+}
+/*headings*/
+.fs-title {
+	font-size: 15px;
+	text-transform: uppercase;
+	color: #2C3E50;
+	margin-bottom: 10px;
+}
+.fs-subtitle {
+	display: inline-block;
+	font-weight: normal;
+	font-size: 13px;
+	color: #666;
+	margin-bottom: 20px;
+	padding-bottom: 3px;
+	border-bottom: 2px solid #27AE60;
+}
+.fs-label {
+	display: block;
+	text-align: left;
+	margin-bottom: 8px;
+}
+.fs-label > i {
+	margin-right: 3px;
+}
+
+/*progressbar*/
+#progressbar {
+	margin-bottom: 30px;
+	overflow: hidden;
+	/*CSS counters to number the steps*/
+	counter-reset: step;
+}
+#progressbar li {
+	list-style-type: none;
+	color: black;
+	text-transform: uppercase;
+	font-size: 12px;
+	width: 33.33%;
+	float: left;
+	position: relative;
+}
+#progressbar li:before {
+	content: counter(step);
+	counter-increment: step;
+	width: 20px;
+	line-height: 20px;
+	display: block;
+	font-size: 12px;
+	color: #333;
+	background: white;
+	border-radius: 3px;
+	margin: 0 auto 5px auto;
+}
+/*progressbar connectors*/
+#progressbar li:after {
+	content: '';
+	width: 100%;
+	height: 2px;
+	background: white;
+	position: absolute;
+	left: -50%;
+	top: 9px;
+	z-index: -1; /*put it behind the numbers*/
+}
+#progressbar li:first-child:after {
+	/*connector not needed before the first step*/
+	content: none; 
+}
+/*marking active/completed steps green*/
+/*The number of the step and the connector before it = green*/
+#progressbar li.active:before,  #progressbar li.active:after{
+	background: #27AE60;
+	color: white;
+}
+
+p.error-text {
+	bottom: -23px;
+	left: 24px;
+	color: rgba(255, 0, 0, .7);
+	font-size: .8em;
+}
+
+#term-error {
+	color: rgba(255, 0, 0, .7);
+	font-size: .8em;
+	bottom: -23px;
+	left: 24px;
+}
+
+select {
+	padding: 15px;
+	border: 1px solid #ccc;
+	border-radius: 3px;
+	margin-bottom: 10px;
+	width: 100%;
+	box-sizing: border-box;
+	font-family: montserrat;
+	color: #2C3E50;
+	font-size: 13px;
+
+	background-color: transparent;
+}
+
+.pl-0 {
+	padding-left: 0;
+}
+
+.terms {
+	font-size: .9rem;
+	width: 95%;
+	min-width: 250px;
+	height: auto;
+	overflow: scroll;
+	margin-bottom: 1rem;
+	margin-left: auto;
+	margin-right: auto;
+	border: 1px solid rgb(163, 163, 163);
+	line-height: 1.5rem;
+}
+
+.term-link a {
+	text-decoration: none;
+	color: black;
+}
+
+.h2 {
+	text-align: center;
+	font-size: 1.2rem;
+	font-weight: 500;
+	margin-top: 2rem;
+}
+
+.left_align {
+	font-size: 18px;
+	text-align: left;
+}
+
+#overlay {
+	position: fixed; /* Sit on top of the page content */
+	display: none;
+	width: 100%;
+	height: 100%;
+	top: 0; 
+	left: 0;
+	right: 0;
+	bottom: 0;
+	background-color: rgba(0,0,0,0.5);
+	z-index: 2;
+	cursor: pointer;
+}
+
+.thankyou {
+	margin: auto;
+	min-width: 350px;
+	height: 250px;
+	margin-top: 190px;
+	background: #fff;
+	padding: 15px 20px;
+	line-height: 25px;
+	border-radius: 4px;
+	text-align: center;
+	
+}
+.thankyou input {
+	margin-top: 40px;
+}
+.thankyou h3 {
+	font-size: 2rem;
+	font-weight: 700;
+	color: #21ba45;
+	line-height: 2.5rem;
+	margin-bottom: 1.5rem;
+}
+
+.check_button {
+	display: none;
+}
+
+.fs-label-type {
+	background: transparent;
+	padding: 5px;
+	border: 1px solid black;
+	border-radius: 5px;
+	display: inline-block;
+}
+
+.check_button:checked + .fs-label-type{
+	background-color: #27AE60;
+	color: white;
+	padding: 5px;
+	border: 1px solid #27AE60;
+	border-radius: 5px;
+}
+
+input[type="checkbox"] {
+	display: none;
+}
+
+#checker1, #checker2 {
+	display: inline;
+}
+
+.fs-label-info {
+	background: transparent;
+	padding: 5px;
+	border: 1px solid black;
+	border-radius: 5px;
+	display: inline-block;
+	margin-bottom: 8px;
+}
+
+input[type="radio"] {
+	display: none;
+}
+
+input[type="radio"]:checked + .fs-label-info {
+	background-color: #27AE60;
+	color: white;
+	padding: 5px;
+	border: 1px solid #27AE60;
+	border-radius: 5px;
+}
+
+input[type="checkbox"]:checked + .fs-label-info {
+	background-color: #27AE60;
+	color: white;
+	padding: 5px;
+	border: 1px solid #27AE60;
+	border-radius: 5px;
+}
+
+.btn-exit {
+	padding: .5rem .75rem;
+	background-color: transparent;
+	border: 1px solid black;
+	margin-top: .3rem;
+}
+
+.btn-term-exit {
+	padding: .5rem .75rem;
+	background-color: transparent;
+	border: 1px solid black;
+	margin-top: .3rem;
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+	margin-bottom: 2rem;
+}
+
+footer {
+	padding: 2rem;
+	padding-top: .5rem;
+}
+
+.footer {
+	display: flex;
+	justify-content: center;
+}
+
+.img_fr {
+	width: 80%;
+	max-width: 850px;
+	min-width: 300px;
+	height: 60px;
+	object-fit: contain;
+	object-position: center;
+}
+
+.img_fr img {
+	width: 100%;
+	height: 90%;
+}
+
+#msform #userid, #msform #area {
+	height: 0;
+	padding: 0;
+	margin: 0;
+	border: none;
+}
+