Button that updates number on all sessions [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I've tried a lot of ways, like for example the fs module, but I just can't find out how to implement this. I need a button that:
Updates by one whenever any user presses the button
Persists on the server
Does anyone know how to do this?

If you are new and need to build something that stores stuff on the server you have a lot to learn. If you just need to solve this simple problem and get things working you could make huge progress using a hosted backend service. If you do this you can write a couple of lines in JS and the job will be done. Most offer a free account.
One such service is built.io see link below:
https://docs.built.io/api-reference
var project = Built.App('blt5d4sample2633b').Class('score').Object();
project = project.increment('points',10); //Increases points field value by 10
That code above would update the score by 10 and store it , you can then retreive it when you show the page. All users would see the score update.
There are realtime backend services too which are very good.
An example is:
www.firebase.com
You would need to decide which one is best for you, add their script to your page add a button, hook the click event upto a function that you would then add the simple code to update the score. See above.
It a nutshell that would be it. You can probably get it working in under 1 hour if you follow the guides on the vendors site.
Firebase is backed by google and has a huge online community.

Related

Update value of nested array in firebase database [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I'm building a web app with Vue.js using Firebase authentication and real time database, which I'm new to.
In this app the user answers to questions to achieve some points.
My problem is: I want to update an existing array already stored and created in the database so that the progress/points of that user will be under track to update all the components in my app.
For example let's say I want to increase +1 the highlighted value in the screenshot:
I was thinking about something like userid.progress[6][0] += 1 like in normal javascript, but I can't update the database, value still at 0.
I've read something about .set() or .update() but in that case I should rewrite all the array (and it would be a problem), but I might be completely wrong.
PS: it's not a problem about getting the user id or the current user, everything is working fine.
Hope to find someone to help me, thank you so much in advance!
If you're trying to update an existing score, you can write on the most granular level. So:
ref.child("pjoCy...0tl3/progress/0/6/0").set(1)
If you want to push a new score to the end of the array, you'll indeed need to read the entire score array to add a new value to the end. This is one of the many reasons why Firebase recommends against using array indices like you do. If you instead us so-called push-IDs, adding a new value becomes as easy as:
ref.child("pjoCy...0tl3/progress/0/6").push(1)
I recommend reading more about structuring lists in the Firebase documentation and the classic blog posts on handling arrays in Firebase.

How to make next page link when document size reaches to specific length? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have built an Admin section where i can see all the contents from database in a table. everything is fine but if the database table has thousands of rows I have to scroll down very deep. is there any way I can make links like `1,2,3.Next the way google search results do? or is there any even better way?
Isn't is going to be something like:
if($(document).height>2000){
//what should i do?
}
Looks like you are using jquery. If you are going to implement everything on your own it may be time consuming - although it would be fun!
To save some time, there are quite a few plugins available to achieve this. Refer:
https://datatables.net/
http://www.jqueryscript.net/table/Client-side-HTML-Table-Pagination-Plugin-with-jQuery-Paging.html
Since you may have huge data you should be using server side pagination instead of client side. Here is another SO link which explains the difference between them : Pagination: Server Side or Client Side?

Exchange Html Data form in Real Time [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
hey guys I'm totally new to programing and I need your help to walk me through this .
lets say we have 2 users that want to communicate through HTML forms
The first users fills out a html form ( first name , last name , age etc ... ) and submits it .
The second user receives the form without being able to apply any modifications to it and then submits back to the first user as either approved or disapproved ( by ticking a radio button )
all of this has to happen in Real Time.
can somebody please explain to me how it works ? Is it done with Ajax ?
what should i research ?
You should look into Web Sockets, this is how you can accomplish the functionality you would like. Here is a link to some information on web sockets and it has a few different libraries that implement and abstract web socket to make it easier to use:
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
If you develop in Visual Studio with .NET, then you can check out Microsoft's SignalR library. It makes WebSocket coding easy:
http://www.asp.net/signalr
If you are wanting to stay away from WebSockets completely, then you would be looking to use AJAX and "Long Polling". here is a good SO post on this:
how does long polling work javascript?

Browsing a database as the user is typing [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
This is probably a simple question, but I'm struggling with this.
Basically, how to browse in a database, as the user is typing something?
For example, in a website such as https://www.doesthedogdie.com/, how do they do it to show all the movies beggining with the string of characters you're typing, as you're typing it?
I guess javascript is involved?
It's called autocomplete
Please do some googling next time yourself.
You can use jQuery autocomplete or Bootstrap typeahead to achieve this.
Hope this helps
My personal preference on how to make these kind of systems is fairly awkward, yet it seems to work just fine for me without requiring too much client-side scripting.I use ASP.NET's Page_Load event to save all content in a SQL database into an XML file. Then, when the user enters some text into the field, I make a hidden div class underneath it unhidden to display filtered results from the XML document. This way, you can update the SQL database at any time fairly simply to add new records which should be listed on the website.This is server-side scripting, which I prefer to client-side because the user can disable features and mess around with it to view your code which is something I personally hate.I hope this helps you somewhat.

User Defined Rules in a Web Application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm required to implement a notification system integrated to a web application (JavaScript + PHP). Notifications should be fired based on user-defined rules. I don't have experience with rules engines and building rules. Therefore, I don't know what I'm doing or if what the following could be implemented by better solution.
I'm trying to figure out how to store and process the following hypothetical scenario. Let's say that the web app is a shopping online service for a store that has 3 lines of products, line A, line B and line C. Each line has different characteristics. User#1 selects an object from line A, then specifies some characteristics such as size and colors. User#2 selects an object from line B, the only characteristic for this kind is material, he selects wood. Then both users ask system to notify them whenever these objects with these characteristics become available.
From what I've read so far, this could be done through [user-defined rules]. If so, then
What's the best technology to handle it? I'm willing to learn but I need a direction to help me start.
Can I use openRules or similar for this?
How to sent user defined data to a web service? given that they change based on the line.
If you are using a database, or anything similar, you can make a table where you would save the rules for each user. You can than later load them with a php class as soon as the user logs in, and check against them before doing anything that was optional.
You can also make a table and set flags, once an item becomes available loop trough the table and notify every user waiting. You would need to store, item id and customer id, in the table and delete them once they have been notify.

Categories