Comments (9)
Sounds fine to me. Would the python function still generate the words that are being used?
from textthem.
Yes, but it would be modified to only return json.
from textthem.
alrighty.
from textthem.
Accidently closed this. Realize the random generator still needs to be styled. Loving the changes though. got everything setup and installed on my laptop at home.
from textthem.
I've implemented the changes on https://github.com/syntonym/TextThem/tree/merge_random, but it's... slow. Each time the "random" button is pressed, an ajax request is send to /RandomGenerator which returns a json with {adjective: [adjective], noun: [noun]} and then entered in the form. But the request is still a request and needs some time to return.
Another possibility would be to load the entire dict of random words when loading the page and doing the random stuff in javascript only. Or maybe just load a subset of the dict. Or maybe load random words as soon the page loads.
To checkout my changes just clone my merge_random branch.
from textthem.
Looking good! Just trying to understand what you are doing,
$("#InputMessage").val(response.adjective + " " + response.noun);
This grabs the adjective and noun variables that were returned by the generatemessage() function correct? I am not that proficient in java script :P
from textthem.
$.getJSON("/RandomGenerator", function(response) {
This will get the json object lacated at "/RandomGenerator" (you can visit it with your webbrowser too see how it looks like) and pass it to the anonymous function as response.
$("#InputMessage").val(response.adjective + " " + response.noun);
This will then locate the form with the id=#InputMessage and set its value to response.adjective + " " + response.noun.
response is something like:
{ "adjective" : "greedy", "noun" : "rabbit" }
a simple json which is often used in compound with javascript and works similiar to a python dict. Infact python dicts can easy be converted to json with flask.jsonify which is used in TextThem.py line 151.
from textthem.
Makes sense! so what are the advantages to using json?
from textthem.
Json is a simple format for data and especially suited for "small things" like this. An alternative to json is XML but json is way more human readable.
from textthem.
Related Issues (20)
- Message not sending. Bad Request. HOT 8
- Homepage design. HOT 23
- Flag for Production HOT 4
- Users can submit by hitting enter HOT 1
- Clicking the "number" or "text" input fields disables the "Random" button
- Phonebook issues. HOT 1
- Add Server side validation HOT 3
- What should the Max Text be? HOT 1
- UnitTests HOT 3
- Website Design HOT 4
- Adding New Features Client Side vs Server Side HOT 8
- Grunt HOT 2
- Javascript Indentation HOT 1
- Irc channel HOT 2
- Make Updates to Site Responsiveness HOT 1
- Login and Register Page HOT 6
- Blower.io Alternative. HOT 48
- Polish? HOT 1
- Unittests HOT 2
- Path to static HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textthem.