fac-11 / week-4-taaa Goto Github PK
View Code? Open in Web Editor NEWhttps://stormy-dawn-58180.herokuapp.com/
https://stormy-dawn-58180.herokuapp.com/
Create a function that takes in a string and an array of strings and returns all matching elements in an array of strings.
Research datasets of words online and produce with a JSON or an array of strings
We're finding the names of the server-side modules a little confusing. Handlers.js contains both routers and handling functionality and Api.js contains handling functionality. Is the function of apiRequest() to make a request or to handle the response? Could backend.js have a more descriptive name?
The examples we were given used the convention server - router - handler. Obviously, we don't have to follow conventions, but it might make code easier for other people to read.
This:
var logic = {
sendTextToApi: function(callback) {
var txt = document.getElementById('myInput').value;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
// appendAList(xhr.responseText);
callback(JSON.parse(xhr.responseText));
}
};
xhr.open("GET", '/API?' + txt, true);
xhr.send();
}
}
is functionally the same as:
function sendTextToApi(callback) {
var txt = document.getElementById('myInput').value;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
// appendAList(xhr.responseText);
callback(JSON.parse(xhr.responseText));
}
};
xhr.open("GET", '/API?' + txt, true);
xhr.send();
}
Except you don't need to call it as a method.
This is more of a personal opinion issue but ternary operators are often harder to read, especially when they're long and kept to one line.
Using the example from backend.js:
var shrunkResults = arrayOfStrings.length <= 5 ? arrayOfStrings : arrayOfStrings.slice(0,5);
That goes over the 80 character soft line limit and isn't (at least for me) instantly scan-able. I'm not you shouldn't use ternary operators, and this example is actually a great use-case, but where possible I try to keep code clarity by adding line-breaks or just using if statements, etc:
var shrunkResults = arrayOfStrings.length <= 5 ?
arrayOfStrings :
arrayOfStrings.slice(0, 5);
Make the server do the stuff
Structure
Show your readme:
Talk through the Why, What, How of your project
How did you split up the work?
How did you choose to pair?
Walk us through the UX (user experience) i.e. demo your website
How well does it conform to your brief - the user stories
Walk us through your code. Prioritise the things you learned that were new to you, which the rest of your cohort could benefit from hearing about:
something you're proud of
something that you found really hard / struggled with
Create a server with handlers so that it can serve front end files.
Wouldn't it be nicer if the other options in the dropdown menu disappeared when clicking on the selected ones?
modularise handlers in server.js file
Function will take an array of string and append to the dom either as a html dropdown or a an appended li/span list
Function will take a json and extract an array of strings.
Could the code be clarified into a single if/if-else/.../else structure?
Really love the idea + site ๐ ๐ป
Could you use a smaller file to speed your page loading? It might be difficult to make it look nice on larger browser windows.
You can save it as a Jpeg and use progressive rendering for it.
I love that you made the dropdown tab-able! It works so nicely!
It's a little weird that it only works on tab - the usual expected behaviour for dropdowns is that the arrow keys can be used to navigate through options.
Another kinda related issue is that the input doesn't regain focus when you press enter on an autocomplete result. Current version (I had to click to gain focus at the end):
Currently the filter function iterates over the entire array, but only five results are then passed on.
Perhaps you could use a for loop with a break in it after the results array length reaches five.
At the moment you're checking if(endpoint in contentType)
You could instead just instantiate contentType with endpoint for every request:
const contentType = {
// '/favicon.ico': 'image/x-icon',
'/index.html': 'text/html',
'/main.css': 'text/css',
'/dom.js': 'application/javascript',
'/logic.js': 'application/javascript',
'/background.jpg': 'image/jpeg',
}[endpoint];
This would remove the need for a loop - you'd just need to check if(contentType)
. It would also mean you could replace every further reference of contentType[endpoint]
with just contentType
Add favicon to our project to remove the errors in our server
At the moment, logic.js only has a case if 200 is returned. The server allows for 404 to be sent, but we can't see where xhr will make use of it.
When changing to smaller screens, the text in the dropdown menu goes outside the input-box
Shrink function is not being used re merge #55
Function will take an array and put it into an object - then stringify using json.parse
Look into how to set up Heroku and setup
Creating a function that takes the input text on keypress or onchange
Function will take an array and return an array of 5 elements.
If original array is less than 5 it will return original array.
Is there a better way than JSON to transfer array data over the internet
Add a bit to selector/ shrinker function to return a zero array if search text is empty
Change the default http port for server to run on heroku
Make tests to test all non-trivial logic only functions,
ie not functions which act on DOM, and not functions which make callbacks or touch the network.
Create folder for Public with:
Create folder for src with:
create folder Tests with:
Populate index.html with basic boilerplate with:
Initialise node and install:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.