Tagged Questions
ECMAScript (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms and stand-alone interpreters / JIT engines. Use this tag for questions regarding ECMAScript 5 or 6 and its dialects / implementations: JavaScript, JScript, etc., excluding ...
-2
votes
1answer
15 views
Replacing inline onclick with unobtrusive JavaScript [on hold]
I built this web app to present a random group of questions for quizzes and tests. The page opens with random questions. Clicking anywhere shows (only) the spinner div. Clicking anywhere again brings ...
1
vote
0answers
7 views
Dynamically displaying different controllers
I have here a simple webapp for displaying different D3 demonstrations:
The idea is - the user can select one of many modules in the control bar at the top, and the corresponding controls for that ...
-1
votes
0answers
8 views
Showing overlay on onbeforeunload event [on hold]
I have two problem with event close tab.
I have a function to put a overlay with some text while browser ask to user if to close or not to close. I would like to show "Hello world!" instead of ...
4
votes
1answer
19 views
jQuery for revealing secondary menu
Below is some jQuery I recently wrote and I'm quite sure there is a more elegant and/or efficient way to write it. The gist is, when a user clicks on a Primary Nav link, its Secondary menu slides down....
3
votes
1answer
24 views
Filling Array with Alphanumeric values
I've done a function that does the following :
It takes an argument length that it will be the length of the result array.
The Array should start with alphabet ...
1
vote
2answers
26 views
Finds a position to break a string that is not part of a <br>
I have a 'read more' angular directive copied from:
https://github.com/doukasd/AngularJS-Components/blob/master/dd-text-collapse/dd-text-collapse.js
Some of my text can already have ...
2
votes
1answer
39 views
A clock implemented using Moment.js
This is a POC for a clock using moment.js, eventually I plan to recreate this in Raect.js. Any opimisations or a better way to do it?
...
3
votes
0answers
37 views
jQuery menus, click handlers, and scroll effects for a website
So far, I've been using codes based on solutions other people wrote, and I'm trying to learn by modifying those codes. My problem now is that my code ended up too messy (a lot of script tags, jquery ...
1
vote
0answers
22 views
Node.js MySql code using Promise API
I have written a javascript code for fetching data from mysql database.
I have used connection pooling, and Promise API also.
the code is as follows,
...
7
votes
1answer
49 views
Scale the ingredients of a recipe up/down
I wrote a React app to adjust the serving size of a recipe. For example, if the recipe serves 4 people and requires 4 eggs, scaling it down to serve only 1 person should only require 1 egg. I try to ...
6
votes
0answers
59 views
Bare bones battleship game
This is basically the beginnings of a battleship game. There is only 1 ship which takes up 3 of six locations on a 1 x 6 grid. The locations are created by finding a random location on the grid and ...
0
votes
0answers
25 views
Call parent component method from child component
For example, a parent component (called P) has modal and a subcomponent (called S). S has a text area and a button, and when the button is clicked, the modal in the parent has to be called.
My ...
0
votes
1answer
53 views
Return the last word of the url and capitalize the first letter
Can the below code be done in one line? Do you think it should or is it ok like this?
...
6
votes
1answer
36 views
Add timeline link to questions and answers on Stack Exchange
The following script is meant to be a user script, but it should work on the console. It takes the id of the question and adds the corresponding /posts/id/timeline ...
-2
votes
0answers
28 views
What are the best practices when constructing a Javascript function? [on hold]
I created a script to get the click url (a href) on a landing page. For example http://www.example.com/go/amazon, where I just want to return the value “amazon” (Note: and capitalize the 'a' of the ...
-1
votes
0answers
16 views
0
votes
0answers
20 views
Use es6 export const for dependency injection [on hold]
I'been thinking about the idea to implement dependency injection in my express app built using es6.
The actual project looks like this:
/controllers/myController.controller.js
...
1
vote
2answers
65 views
Displaying random elements for a quiz app
I'm a teacher and I built a one-page web app to display random question sets for quizzes and tests. The script I wrote selects one question from a set (array) of questions.
The script works fine, ...
3
votes
1answer
39 views
Dispatch events in JavaScript
I needed a simple and efficient way to use events in my JavaScript code, so I came up with a small event library.
Currently, I'm doing it like this:
...
0
votes
0answers
14 views
Get last n items from collection in order from least recent to most recent
I wanted to get the last n items from a mongodb collection starting with the least recently added element (lowest id) and ending with the most recently added element. After that I want to stream them ...
1
vote
1answer
50 views
Responsive jQuery menu
I have completed writing a responsive menu (it uses the HoverIntent plugin) for my WordPress theme and it looks like it is working fine on desktop/tablets/phones.
You can test the code here. Just ...
1
vote
0answers
44 views
Quiz MVC application
I am developing a Quiz module in which a user can create a quiz based on a large set of questions grouped on categories. But he can also repeat a certain quiz, or view it again read only.
The ...
2
votes
0answers
31 views
Overall assesment of portfolio website
I've just bought myself a domain and recently created a rough draft of a portfolio website.
A few of my friends have looked over the general design of it and given me some positive feedback so I ...
2
votes
0answers
20 views
HTML canvas element Encapsulation
I am preparing to write a widget for the browser that is both visual and interactive. I am a newbie to Javascript/Ecmascript and prototyping. I want to encapsulate the canvas element, abstract the ...
1
vote
0answers
24 views
Statistic Chart With Filter
I have created an app, which show chart, table detail of chart, with filter date. I created app with Backbone and Marionette, chart with Chartist.js, and the filter date I'm using Pikaday.js and ...
0
votes
3answers
65 views
Overwriting native console.log function in JavaScript
I want to override the console.log function in order to save the data other scripts log. My script executes before any other script, so I have full control over the ...
1
vote
0answers
36 views
Get a random movie based on user-provided criterion (release date, genre, etc.)
What could I do to better organize the Angular and Express code? On the other hand, is there anything that reflects a common beginner's mistake or violates a best practice? I've yet to touch up the ...
2
votes
1answer
43 views
Hand crafted longest common sub sequence
I know that the below solution is not the best one and I am in the way to learn that stuff till then I have applied the brute force to see how far I can go with my intuition.
...
3
votes
1answer
26 views
Currency converter built with AngularJS
I am fairly new to AngularJS and I am trying to improve my knowledge of this JavaScript Framework by building small real-world web-apps.
In this case, I have built a currency converter app with ...
0
votes
0answers
15 views
Simple localStorage utility functions
I wrote some simple localStorage get and set utility functions.
They seem to work well for my test cases but I wonder if there might be scenarios that I overlooked where this could break / be ...
1
vote
0answers
31 views
One-page quiz web app for teachers
I'm an EFL teacher, and I built this web app to present a random group of questions for quizzes and tests. The page opens with random questions. Clicking anywhere brings up the spinner. Clicking ...
1
vote
1answer
29 views
Showing the current view-position within the web page
I've made this coding for large web pages with lots of text, images etc. If the user scrolls down or up it shows where the current view approximately is. In relation to the overall document height.
I'...
0
votes
1answer
45 views
sportsRunning and sportsWalking
There are two functions, sportsRunning and sportsWalking, that will render different text. For this, I am using an ...
2
votes
2answers
75 views
Using jQuery string replacements to make labels bold
Instead of having multiple statements like the following, Is it possible to club them into one liner in jQuery?
...
1
vote
1answer
33 views
From Callbacks to Promises - MEAN Stack
I have a MEAN Stack app in which I have been using mongoose routes to update my data. Some of those routes have a lot of back and forth in terms of updating data across multiple users and collections. ...
0
votes
2answers
103 views
A function that updates JSON disk object
So I have created this function that will add a disk if needed and it takes a disk and a size as inputs. The idea is that I need to update data.disks with a few properties. Disk is called from an ...
2
votes
1answer
102 views
AngularJS application to display 10 search results at a time
I am working on an angular application. I have written a controller for a page which gets 10 objects from an api. On clicking the next button, it gets the next 10 objects and so on. I have also added ...
0
votes
0answers
31 views
Rating calculator [closed]
I want to rank content by rating, giving them a balance of "freshness" and "total votes up"
This is what I've come up with.
...
2
votes
1answer
82 views
Implementing redirect in Redux middleware
Let's say I have following action:
export function signIn(data) {
return {
type: USER_SIGN_IN,
promise: api.post('/sign_in', data)
}
}
and the ...
-6
votes
0answers
25 views
JS Object Element remove duplicates [closed]
I need to remove duplicate "Voltage" entries from this JSON.
Please help me.
Thanks.
...
3
votes
2answers
138 views
Codewars: Sum of Pairs
I've been working on this task (see screenshot).
Here's my answer to it so far:
...
-1
votes
1answer
37 views
Push val of input to array
Currently I'm pushing multiple inputs to a array but this is a lot of repeating code, how can I improve this?
...
3
votes
5answers
96 views
Selectable date filters
I created a simple app with Backbone and Marionette. In a view I created an onRender function.
I created a page that displays a Report with a date filter, using a select tag and affect to an input ...
-1
votes
0answers
8 views
I cannot get client side and server side validation to work [migrated]
Hi I have the following forms
...
1
vote
1answer
67 views
Simple Todo app
I'm writing a todo app as a test. Having never done Ionic nor Angular apps before, I am not sure if I am following best practices here.
What I have done is try to keep my controllers thin by placing ...
1
vote
0answers
35 views
Tabbed popup jQuery plugin
A plugin I'm writing that will have essentially be a tabbed popup. However, I feel like the method I use to remove tabs is completely unwieldy.
...
1
vote
0answers
41 views
+100
Building a multi-panel display with React and Bootstrap
The exercise is part of a React course in which I'm currently enrolled.
Description:
The way it shall look on desktop-screen:
How it shall look on mobile:
Here's my solution:
HTML
...
1
vote
0answers
27 views
AJAX Form Creator
I wrote an AJAX Form Creator (in the form of an js object constructor) that takes a form and a callback. I am a decent, slightly okay, completely novice developer, and could use feedback on coding ...
2
votes
1answer
30 views
Panning JS canvas
I'm experimenting in canvas and trying to create pan effect. I've managed to pan succesfully, but I'm curious if I'm doing it correctly. Since I've come up with the following code myself, I don't know ...
7
votes
1answer
121 views
Robust websocket server for use by a game running on node
This code is a server for websocket connections, it handles the low level stuff and delegates incoming messages to handler objects. I wanted performance to win in any trade off against maintenance ...