Spaces:
Sleeping
Sleeping
ruchi
commited on
Commit
·
7100756
1
Parent(s):
534863f
Finishing on New Game template end to end flow
Browse files- flask-project/app.py +41 -2
- flask-project/requirement.txt +2 -1
- flask-project/scripts/__pycache__/db_util.cpython-310.pyc +0 -0
- flask-project/scripts/__pycache__/utils.cpython-310.pyc +0 -0
- flask-project/scripts/db_util.py +7 -0
- flask-project/scripts/utils.py +85 -38
- flask-project/templates/newGame.html +69 -10
flask-project/app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from flask import Flask, render_template, request, redirect, url_for
|
2 |
-
from scripts.utils import listNeeds
|
3 |
|
4 |
|
5 |
app = Flask(__name__)
|
@@ -23,5 +23,44 @@ def startGame():
|
|
23 |
sustainabilityNeeds,_ = listNeeds('sustainability')
|
24 |
return render_template("newGame.html", moneyNeeds=moneyNeeds, customerExpNeeds=customerExpNeeds, sustainabilityNeeds=sustainabilityNeeds)
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
if __name__ == "__main__":
|
27 |
-
app.run(debug=True, host="0.0.0.0", port=5000)
|
|
|
1 |
from flask import Flask, render_template, request, redirect, url_for
|
2 |
+
from scripts.utils import listNeeds, generatePropositionExample, evaluateProposition
|
3 |
|
4 |
|
5 |
app = Flask(__name__)
|
|
|
23 |
sustainabilityNeeds,_ = listNeeds('sustainability')
|
24 |
return render_template("newGame.html", moneyNeeds=moneyNeeds, customerExpNeeds=customerExpNeeds, sustainabilityNeeds=sustainabilityNeeds)
|
25 |
|
26 |
+
@app.route("/generate-proposition", methods = ['POST'])
|
27 |
+
def generateProposition():
|
28 |
+
|
29 |
+
print("Proposition generated")
|
30 |
+
productType = request.form['productType']
|
31 |
+
productName = request.form['productName']
|
32 |
+
|
33 |
+
moneyNeeds = request.form.getlist('moneyNeeds')
|
34 |
+
customerExpNeeds = request.form.getlist('customerExpNeeds')
|
35 |
+
sustainabilityNeeds = request.form.getlist('sustainabilityNeeds')
|
36 |
+
|
37 |
+
generatedProposition = generatePropositionExample(productName, productType, moneyNeeds, customerExpNeeds, sustainabilityNeeds)
|
38 |
+
print(generatedProposition)
|
39 |
+
return generatedProposition
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
@app.route("/submit-proposition", methods = ['POST'])
|
44 |
+
def submitProposition():
|
45 |
+
city = request.form['city']
|
46 |
+
|
47 |
+
productType = request.form['productType']
|
48 |
+
subcount1 = request.form['subcount1']
|
49 |
+
subcount2 = request.form['subcount2']
|
50 |
+
subcount3 = request.form['subcount3']
|
51 |
+
productName = request.form['productName']
|
52 |
+
|
53 |
+
|
54 |
+
moneyNeeds = request.form.getlist('moneyNeeds')
|
55 |
+
customerExpNeeds = request.form.getlist('customerExpNeeds')
|
56 |
+
sustainabilityNeeds = request.form.getlist('sustainabilityNeeds')
|
57 |
+
proposition = request.form['proposition']
|
58 |
+
|
59 |
+
matchingTopologies, predictedSubscriberTakeOut = evaluateProposition(city, productType, proposition, moneyNeeds, customerExpNeeds, sustainabilityNeeds)
|
60 |
+
val = "matching topologies = {} and predictedSubscriberTakeOut = {}".format(",".join(matchingTopologies), predictedSubscriberTakeOut)
|
61 |
+
print(val)
|
62 |
+
return val
|
63 |
+
|
64 |
+
|
65 |
if __name__ == "__main__":
|
66 |
+
app.run(debug=True, host="0.0.0.0", port=5000)
|
flask-project/requirement.txt
CHANGED
@@ -2,4 +2,5 @@ altair==4.0
|
|
2 |
transformers
|
3 |
google-generativeai
|
4 |
db-sqlite3
|
5 |
-
flask
|
|
|
|
2 |
transformers
|
3 |
google-generativeai
|
4 |
db-sqlite3
|
5 |
+
flask
|
6 |
+
python-dotenv
|
flask-project/scripts/__pycache__/db_util.cpython-310.pyc
CHANGED
Binary files a/flask-project/scripts/__pycache__/db_util.cpython-310.pyc and b/flask-project/scripts/__pycache__/db_util.cpython-310.pyc differ
|
|
flask-project/scripts/__pycache__/utils.cpython-310.pyc
CHANGED
Binary files a/flask-project/scripts/__pycache__/utils.cpython-310.pyc and b/flask-project/scripts/__pycache__/utils.cpython-310.pyc differ
|
|
flask-project/scripts/db_util.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import sqlite3
|
2 |
import os
|
|
|
3 |
|
4 |
DB_DIR = "db"
|
5 |
def fetch_db_rows_as_dicts(db_path, table_name):
|
@@ -31,6 +32,12 @@ def fetch_db_rows_as_dicts(db_path, table_name):
|
|
31 |
conn.close()
|
32 |
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# Example usage:
|
36 |
#dbPath = os.path.abspath(os.path.join(os.getcwd(), DB_DIR,'topologies.sqlite'))
|
|
|
1 |
import sqlite3
|
2 |
import os
|
3 |
+
import pandas as pd
|
4 |
|
5 |
DB_DIR = "db"
|
6 |
def fetch_db_rows_as_dicts(db_path, table_name):
|
|
|
32 |
conn.close()
|
33 |
|
34 |
|
35 |
+
def fetchTopologies():
|
36 |
+
topologiesPath = os.path.abspath(os.path.join(os.getcwd(), DB_DIR,'topologies_desc.csv'))
|
37 |
+
topologiesDf = pd.read_csv(topologiesPath, encoding = "ISO-8859-1")
|
38 |
+
return topologiesDf
|
39 |
+
|
40 |
+
|
41 |
|
42 |
# Example usage:
|
43 |
#dbPath = os.path.abspath(os.path.join(os.getcwd(), DB_DIR,'topologies.sqlite'))
|
flask-project/scripts/utils.py
CHANGED
@@ -1,8 +1,20 @@
|
|
1 |
-
from scripts.db_util import fetch_db_rows_as_dicts
|
2 |
import google.generativeai as genai
|
3 |
import json
|
4 |
import os
|
|
|
5 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
GOOGLE_API_KEY= os.getenv('GEMINI_API_KEY')
|
8 |
genai.configure(api_key=GOOGLE_API_KEY)
|
@@ -150,7 +162,7 @@ def findTop3Needs(proposition, needs):
|
|
150 |
|
151 |
def findTop3Topologies(proposition, demographic):
|
152 |
|
153 |
-
topologies =
|
154 |
|
155 |
topologies = topologies.dropna(axis=1, how='all')
|
156 |
|
@@ -214,50 +226,85 @@ def generatePropositionExample(productName, selectedProduct, moneyNeeds, custome
|
|
214 |
return response.text
|
215 |
|
216 |
|
217 |
-
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
# Find the best 3 strings out of the list which matches this proposition. Return output strictly only in json under a list called matches
|
229 |
-
# '''
|
230 |
|
231 |
-
|
232 |
-
# response = model.generate_content([moneyNeedsPrompt])
|
233 |
-
# output = response.text
|
234 |
-
# output = output.replace('```json', '')
|
235 |
-
# output = output.replace('```', '')
|
236 |
-
# obj = load_json_from_string(output)
|
237 |
-
# print(obj)
|
238 |
-
# return obj['matches']
|
239 |
|
|
|
|
|
|
|
|
|
240 |
|
241 |
-
|
242 |
-
# 'CharlesTown city people are young families people mostly with a population of 20000. Out of this 65% are between the age of 30-45. Most of them have kids aged between 0-15')
|
243 |
|
244 |
-
|
|
|
|
|
245 |
|
246 |
-
|
|
|
|
|
|
|
|
|
247 |
|
248 |
-
|
|
|
249 |
|
250 |
-
|
|
|
|
|
|
|
|
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
|
|
|
|
261 |
|
262 |
-
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from scripts.db_util import fetch_db_rows_as_dicts, fetchTopologies
|
2 |
import google.generativeai as genai
|
3 |
import json
|
4 |
import os
|
5 |
+
from dotenv import load_dotenv, dotenv_values
|
6 |
import pandas as pd
|
7 |
+
import math
|
8 |
+
|
9 |
+
load_dotenv()
|
10 |
+
|
11 |
+
demographicsDict ={
|
12 |
+
'CharlesTown': {
|
13 |
+
'demographic':'CharlesTown city people are Living for today people mostly with a population of 10000. Out of this 65% are between the age of 18-25.',
|
14 |
+
'population': 10000},
|
15 |
+
'Limburg': {'demographic':'Limburg city people are young families people mostly with a population of 20000. Out of this 65% are between the age of 30-45. Most of them have kids aged between 0-15',
|
16 |
+
'population': 20000}
|
17 |
+
}
|
18 |
|
19 |
GOOGLE_API_KEY= os.getenv('GEMINI_API_KEY')
|
20 |
genai.configure(api_key=GOOGLE_API_KEY)
|
|
|
162 |
|
163 |
def findTop3Topologies(proposition, demographic):
|
164 |
|
165 |
+
topologies = fetchTopologies()
|
166 |
|
167 |
topologies = topologies.dropna(axis=1, how='all')
|
168 |
|
|
|
226 |
return response.text
|
227 |
|
228 |
|
229 |
+
def evaluateProposition(selectedCity, selectedProduct, userProposal, moneyNeeds, customerExpNeeds, sustainabilityNeeds):
|
230 |
|
231 |
+
proposal = '''Given proposal is for the city {} with product {}. The propsal is as below.
|
232 |
+
{}'''
|
233 |
+
proposal = proposal.format(selectedCity, selectedProduct, userProposal)
|
234 |
+
|
235 |
+
_, moneyNeedsDict = listNeeds('money_needs')
|
236 |
+
_, customerExperienceDict = listNeeds('customer_exp')
|
237 |
+
_, sutainabilityNeedsDict = listNeeds('sustainability')
|
238 |
+
|
239 |
+
demographic = demographicsDict[selectedCity]['demographic']
|
240 |
+
population = demographicsDict[selectedCity]['population']
|
241 |
+
matchingTopologies, topologyDetails = findTop3Topologies(proposal, demographic)
|
242 |
+
|
243 |
+
topologySumDict = {}
|
244 |
+
|
245 |
+
for topology in matchingTopologies:
|
246 |
+
sumTopology = 0
|
247 |
+
for moneyNeed in moneyNeeds:
|
248 |
+
#print(" Money need = {}, Topology is {}".format(moneyNeed, topology))
|
249 |
+
sumTopology = sumTopology+int(moneyNeedsDict[moneyNeed][topology])
|
250 |
+
|
251 |
+
for customerExp in customerExpNeeds:
|
252 |
+
sumTopology = sumTopology+int(customerExperienceDict[customerExp][topology])
|
253 |
|
254 |
+
for sustainabilityNeed in sustainabilityNeeds:
|
255 |
+
sumTopology = sumTopology+int(sutainabilityNeedsDict[sustainabilityNeed][topology])
|
|
|
|
|
|
|
256 |
|
257 |
+
topologySumDict[topology] = math.floor(sumTopology/3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
+
totalSubscriberTakeOut = 0
|
260 |
+
for topology in matchingTopologies:
|
261 |
+
proportion = int(topologyDetails[topology]['Proportion Sample'].replace('%', ''))
|
262 |
+
topologyPopulation = math.floor((proportion * population) / 100)
|
263 |
|
264 |
+
topologyScore = topologySumDict[topology]
|
|
|
265 |
|
266 |
+
topologyPopulation = math.floor(topologyPopulation/2)
|
267 |
+
if topologyScore <=250:
|
268 |
+
topologyPopulation = topologyPopulation/2
|
269 |
|
270 |
+
elif topologyScore >250 and topologyScore<=260:
|
271 |
+
topologyPopulation = math.floor(topologyPopulation/1.8)
|
272 |
+
|
273 |
+
elif topologyScore >260 and topologyScore<=270:
|
274 |
+
topologyPopulation = math.floor(topologyPopulation/1.6)
|
275 |
|
276 |
+
elif topologyScore >270 and topologyScore<=280:
|
277 |
+
topologyPopulation = math.floor(topologyPopulation/1.4)
|
278 |
|
279 |
+
elif topologyScore >280 and topologyScore<=300:
|
280 |
+
topologyPopulation = topologyPopulation
|
281 |
+
|
282 |
+
elif topologyScore >300 and topologyScore<=310:
|
283 |
+
topologyPopulation = math.floor(topologyPopulation * 1.2)
|
284 |
|
285 |
+
elif topologyScore >310 and topologyScore<=320:
|
286 |
+
topologyPopulation = math.floor(topologyPopulation * 1.4)
|
287 |
+
|
288 |
+
elif topologyScore >320 and topologyScore<=340:
|
289 |
+
topologyPopulation = math.floor(topologyPopulation * 1.5)
|
290 |
+
|
291 |
+
elif topologyScore >340 and topologyScore<=360:
|
292 |
+
topologyPopulation = math.floor(topologyPopulation * 1.6)
|
293 |
+
|
294 |
+
else:
|
295 |
+
topologyPopulation = math.floor(topologyPopulation * 2)
|
296 |
|
297 |
+
totalSubscriberTakeOut = totalSubscriberTakeOut + topologyPopulation
|
298 |
+
|
299 |
+
return matchingTopologies, totalSubscriberTakeOut
|
300 |
+
# st.write("{}. {} and has subscriber takeout of {}".format(topology, topologySumDict[topology], topologyPopulation))
|
301 |
+
|
302 |
+
# st.write(" Target Subscriber takeout = {}".format(totalSubscriberTakeOut))
|
303 |
+
# st.write(" Total Subscriber take up for Year 3 = {}".format(subscriberTakeOutYear3))
|
304 |
+
|
305 |
+
# if totalSubscriberTakeOut<subscriberTakeOutYear3:
|
306 |
+
# st.write("Overall there is not a close match of your proposition to the main demographic. Takeout score difference = {}".format(subscriberTakeOutYear3-totalSubscriberTakeOut))
|
307 |
+
# elif totalSubscriberTakeOut==subscriberTakeOutYear3:
|
308 |
+
# st.write("Amazing! Your proposition exactly match the target subscriber take oup for year 3")
|
309 |
+
# else:
|
310 |
+
# st.write("Great Job! Your proposition exceeds the target subscriber take up for year 3. Additional takeout = {}".format(totalSubscriberTakeOut- subscriberTakeOutYear3))
|
flask-project/templates/newGame.html
CHANGED
@@ -275,11 +275,11 @@
|
|
275 |
<h2>Proposition Evaluation Game</h2>
|
276 |
</div>
|
277 |
<div class="form-inner">
|
278 |
-
<form
|
279 |
<div class="row clearfix">
|
280 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
281 |
<div class="select-box">
|
282 |
-
<select class="wide">
|
283 |
<option data-display="Select Town">Select Town</option>
|
284 |
<option value="CharlesTown">CharlesTown</option>
|
285 |
<option value="Limburg">Limburg</option>
|
@@ -288,7 +288,7 @@
|
|
288 |
</div>
|
289 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
290 |
<div class="select-box">
|
291 |
-
<select class="wide">
|
292 |
<option data-display="Select Product">Select Product</option>
|
293 |
<option value="Curent">Curent</option>
|
294 |
<option value="Mortgage">Mortgage</option>
|
@@ -311,9 +311,9 @@
|
|
311 |
</div>
|
312 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
313 |
<div><span>Please select top 3 money needs that you are targeting for your customer</span></div>
|
314 |
-
<select class="wide form-select needs"
|
315 |
{%for need in moneyNeeds%}
|
316 |
-
<option value={{need}}>{{need}}</option>
|
317 |
{%endfor%}
|
318 |
</select>
|
319 |
|
@@ -321,9 +321,9 @@
|
|
321 |
|
322 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
323 |
<div><span>Please select top 3 customer experience needs that you are targeting for your customer</span></div>
|
324 |
-
<select class="wide form-select needs"
|
325 |
{%for need in customerExpNeeds%}
|
326 |
-
<option value={{need}}>{{need}}</option>
|
327 |
{%endfor%}
|
328 |
</select>
|
329 |
|
@@ -331,25 +331,57 @@
|
|
331 |
|
332 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
333 |
<div><span>Please select top 3 sustainability needs that you are targeting for your customer</span></div>
|
334 |
-
<select class="wide form-select needs"
|
335 |
{%for need in sustainabilityNeeds%}
|
336 |
-
<option value={{need}}>{{need}}</option>
|
337 |
{%endfor%}
|
338 |
</select>
|
339 |
|
340 |
</div>
|
341 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group message-btn centred">
|
342 |
-
<button class="theme-btn btn-one" type="submit" name="
|
343 |
</div>
|
344 |
</div>
|
345 |
</form>
|
346 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
</div>
|
348 |
</section>
|
349 |
<!-- contact-section end -->
|
350 |
|
351 |
|
352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
<!--Scroll to top-->
|
355 |
<div class="scroll-to-top">
|
@@ -386,8 +418,35 @@
|
|
386 |
if($(this).children("option:selected").length >= 3) {
|
387 |
alert("You can only select maximum 3 options")
|
388 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
});
|
390 |
</script>
|
391 |
|
392 |
</body><!-- End of .page_wrapper -->
|
393 |
</html>
|
|
|
|
275 |
<h2>Proposition Evaluation Game</h2>
|
276 |
</div>
|
277 |
<div class="form-inner">
|
278 |
+
<form class="default-form" id="generate-proposition-form" name="generate-proposition-form">
|
279 |
<div class="row clearfix">
|
280 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
281 |
<div class="select-box">
|
282 |
+
<select class="wide" name="city">
|
283 |
<option data-display="Select Town">Select Town</option>
|
284 |
<option value="CharlesTown">CharlesTown</option>
|
285 |
<option value="Limburg">Limburg</option>
|
|
|
288 |
</div>
|
289 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
290 |
<div class="select-box">
|
291 |
+
<select class="wide" name="productType">
|
292 |
<option data-display="Select Product">Select Product</option>
|
293 |
<option value="Curent">Curent</option>
|
294 |
<option value="Mortgage">Mortgage</option>
|
|
|
311 |
</div>
|
312 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
313 |
<div><span>Please select top 3 money needs that you are targeting for your customer</span></div>
|
314 |
+
<select class="wide form-select needs" name="moneyNeeds" multiple>
|
315 |
{%for need in moneyNeeds%}
|
316 |
+
<option value="{{ need }}">{{need}}</option>
|
317 |
{%endfor%}
|
318 |
</select>
|
319 |
|
|
|
321 |
|
322 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
323 |
<div><span>Please select top 3 customer experience needs that you are targeting for your customer</span></div>
|
324 |
+
<select class="wide form-select needs" name="customerExpNeeds" multiple>
|
325 |
{%for need in customerExpNeeds%}
|
326 |
+
<option value="{{ need }}">{{need}}</option>
|
327 |
{%endfor%}
|
328 |
</select>
|
329 |
|
|
|
331 |
|
332 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
333 |
<div><span>Please select top 3 sustainability needs that you are targeting for your customer</span></div>
|
334 |
+
<select class="wide form-select needs" name="sustainabilityNeeds" multiple>
|
335 |
{%for need in sustainabilityNeeds%}
|
336 |
+
<option value="{{ need }}">{{need}}</option>
|
337 |
{%endfor%}
|
338 |
</select>
|
339 |
|
340 |
</div>
|
341 |
<div class="col-lg-12 col-md-12 col-sm-12 form-group message-btn centred">
|
342 |
+
<button class="theme-btn btn-one" type="submit" name="generate-proposition" id="generate-proposition">Generate Sample Proposition</button>
|
343 |
</div>
|
344 |
</div>
|
345 |
</form>
|
346 |
</div>
|
347 |
+
<div class="form-inner">
|
348 |
+
<form id="submit-proposition-form" style="display: none;">
|
349 |
+
<div class="row clearfix">
|
350 |
+
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
|
351 |
+
<textarea name="proposition" id="proposition"></textarea>
|
352 |
+
</div>
|
353 |
+
<div class="col-lg-12 col-md-12 col-sm-12 form-group message-btn centred">
|
354 |
+
<button class="theme-btn btn-one" type="submit" name="submit-proposition" id="submit-proposition">Submit Proposition</button>
|
355 |
+
</div>
|
356 |
+
</div>
|
357 |
+
</form>
|
358 |
+
</div>
|
359 |
</div>
|
360 |
</section>
|
361 |
<!-- contact-section end -->
|
362 |
|
363 |
|
364 |
|
365 |
+
<div id="dialog-content" style="display:none;max-width:500px;">
|
366 |
+
<h2>Hello, world!</h2>
|
367 |
+
<p>
|
368 |
+
<input type="text" value="" />
|
369 |
+
</p>
|
370 |
+
<p>
|
371 |
+
Try hitting the tab key and notice how the focus stays within the dialog
|
372 |
+
itself.
|
373 |
+
</p>
|
374 |
+
<p>
|
375 |
+
To close dialog hit the esc button, click on the overlay or just click the
|
376 |
+
close button.
|
377 |
+
</p>
|
378 |
+
<p>
|
379 |
+
Element used to launch the modal would receive focus back after closing.
|
380 |
+
</p>
|
381 |
+
</div>
|
382 |
+
<button data-fancybox data-src="#dialog-content">Launch Dialog</button>
|
383 |
+
|
384 |
+
|
385 |
|
386 |
<!--Scroll to top-->
|
387 |
<div class="scroll-to-top">
|
|
|
418 |
if($(this).children("option:selected").length >= 3) {
|
419 |
alert("You can only select maximum 3 options")
|
420 |
}
|
421 |
+
|
422 |
+
$("#generate-proposition").unbind().click( function (e) {
|
423 |
+
e.preventDefault()
|
424 |
+
|
425 |
+
$.ajax({
|
426 |
+
type: 'POST',
|
427 |
+
async:false,
|
428 |
+
url: '/generate-proposition',
|
429 |
+
data: $('#generate-proposition-form').serialize(),
|
430 |
+
success: function(data){
|
431 |
+
$('#proposition').val(data)
|
432 |
+
$('#submit-proposition-form').css({"display": "block"})
|
433 |
+
}})
|
434 |
+
|
435 |
+
|
436 |
+
})
|
437 |
+
|
438 |
+
|
439 |
+
$("#submit-proposition").unbind().click( function (e) {
|
440 |
+
e.preventDefault()
|
441 |
+
$.post('/submit-proposition', $('#generate-proposition-form').serialize()+"&"+$('#submit-proposition-form').serialize(), function(data){
|
442 |
+
|
443 |
+
})
|
444 |
+
})
|
445 |
+
|
446 |
+
|
447 |
});
|
448 |
</script>
|
449 |
|
450 |
</body><!-- End of .page_wrapper -->
|
451 |
</html>
|
452 |
+
|