Create Comment box in Javascript without any server side coding - javascript

I am new to web development, i need to develop a comment box, and save those comments in a file( either database or normal text pad), so that i can retrieve them later and display them on my web. The comments should be seen on web page even after refreshing the page.
Server side programming should not be used.so i believe that i have to code in javascript, can anyone please help me with the code for doing this, as to how to implement a comment box and save the comments in file using javascript.
Thanks in advance

I am assuming that you would also like other users (other than you - the visitor, creator of a comment) to see the comments. Unfortunately, you can't achieve this without server-side code. The comments have to be stored somewhere on a server.

You can't save programmatically anything to file within local filesystem without user participation - this is security limitation. You can use, for example, cookies instead, or any other local storage techniques. But without server-side only you will be able to see your comments.

Related

Store users information in a single file on the root of the web server JavaScript/HTML/CSS

I'm trying to do an authentication system for a website that is supposed to be stored on an intranet. The guy told me he wanted the credentials of the users (max 10 users) to be stored on a single file with some kind of protection. Do you have suggestions.? I really tried to find information, maybe I am not searching for the right thing but everybody uses mondoDB in this kind of situation. Which is not stored locally.
be gentle please... I trying to do it in JavaScript.
When you mentioned a single file on the server, I thought of SQLite. As per the projects description:
The complete state of an SQLite database is usually contained in a single file on disk called the "main database file".
But passwords - even on an intranet server - should never be stored in plain text. And one-way hashing where the source code is also present does not sound like a good idea.
However, sqlcipher seems to solve both those issues. As a starter, you might want to setup a brief tester with plain SQLite.(Here is one simple tutorial).
From there you can look at a sample like this one which shows how sqlcipher could be used with a JavaScript engine like Node.js.
I've tried like that to make it easy
The Javascript Code
SOOOOO, i ended up using nedb... VOILA

Detect changes in data on the front end and only upload those, then update the data on the backend

I am trying to build a rich text editor for a little application, and I ran into a problem. I don't want to upload the whole text every time the user saves the document. The most efficient way I could think of, would be to pick out the changes that were made on the client side, upload them, and then process them on the server. Of course you can't just upload newText - originalText, the server needs to know where exactly in the text those changes occurred, to piece everything back together on the server.
So I guess my questions are, how do I pick out the changes and how do I upload the changes so the Server knows where to put them again? Is there a common way to do it? If not, how would you do it? I can't think of any smart way to achieve this. I use PHP 7.3.8 and if you post js Code, jQuery would be appreciated (not that good with vanilla js).
As AD7six said: It is not a common practice to send updates as diffs, e.g. Wordpress (a publishing app/platform - used for everything from blogs to the New York times) doesn't do that.
It saves almost no bandwidth, so its not worth it.

How do I log information a user has submitted to a form in JavaScript

So. I have a working code for defining a user set variable.
Currently, I use the var data= prompt("prompt", "default entry")
for cleanliness sake.
Is there a way I could log this variable string to a .txt file or some information on my server so I could access the user's input?
This is for a Linux Based Web Server, but I do file management remotely through an FTP Server on Windows.
I am inexperienced in JavaScript, so I could be missing a glaring issue.
However, I have looked through much of Google, but I have not experienced any results with their methods.
No error messages come up on my console, on either end, with any of the methods I have tried. A couple of methods remove the prompt entirely.
No file has shown up with any of the methods I've tried so far.
You need to be running some kind of server side application, this is a topic way out of range for a StackOverflow question as you could choose a huge range of different technologies from Node.JS, ASP.NET Web API, Java, PHP and a huge list more.
One quick way I would recommend is read up on Node.js, create an end point expecting a post and just put an action on your form pointing to the end point and then log the contents of the post to a text file.
The proper solution would involve setting up a database but is way more involved.

Dynamic JavaScript Obfuscation

I've developed a system that polls a server and injects the response JavaScript into the clients web page. I want to obfuscate the JavaScript the server serves, but I also want to know if there is a tool that dynamically obfuscates it according to a token or key. Meaning every new session gets unique scripts that will only work with that client during that session.
If this doesn't already exist, could someone maybe provide me with a link on how to write my own JavaScript obfuscation tool.
Chris, I encourage you to look at this a different way.
First of all, your problem seems to be that you want to display something on your web page, but you want to disguise the methodology that it got there. The absolute best way to do this is to execute all of your code on the server.
This frees you up so that you don't have to obfuscate anything. Any Javascript that you execute would just be working on raw data anyway, and wouldn't be anything specialized that a hacker could do anything with.
A hacker could not see your business processes if all of the work was done on the server.
So, you can make an Ajax call out to the server, which executes the code, and returns HTML or JSON data that your app can then use to place on the webpage. The hacker has nothing to go on, and you don't have to build obfuscation into anything.
Heres a page that encrypt javascript acording to a key
http://scriptasylum.com/tutorials/encode-decode.html
Something you can do, to hide your javascript, is to send it this way:
<?php
header("Refresh: 0;javascript:document.writeln('');");
?>
your js code here
I have not tried it,but I think It will create a empty page wen viewed by a browser.

XML ajax / javascript / jquery

What would be the best way to write some values into a xml file?
In the .html file i have a certain score that gets its values from a js file called jsfuncions.js
Tried looking on several sites for this but never found a clear and simple answer.
Do i have to place the writer into my index file with script tags directly?
Also do i have to use the var xml = new xmlwriter(); Or is there something more simple in jquery to fit this purpose?
Pretty sure i have to use var XML = new XMLWriter();
But there is simply nothing to be found about this funcion. Can anyone point me in the right direction for a simple writer?
Regards.
JavaScript can not update the XML file permanently. You will need to use a serverside language to make the changes permanent.
Browser security sandboxing will prevent a web page being able generate a file and save it locally.
The only local persistence you can use is cookies - you could look at JSON format for storing records with properties and values inside a cookie - limitations are the max size allowed of the cookie.
There's a new local storage mechanism arriving with HTML5 which some of the latest browsers support.
http://people.w3.org/mike/localstorage.html
It really depends what you want to do with the resulting XML. If you want to save information entered by users, then you'll need to use a server side technology for the save operation.
Examples of server side technology include ASP.NET, PHP, Ruby on Rails, Java and Node.js. If you have no experience with any of these technologies, this will be your biggest learning curve. Microsoft provide a fantastic free application called WebMatrix which will help you get started with a number of different frameworks, but excels at ASP.NET.
If you're only interested in persisting information for the use of an individual user, you'll not be looking at an actual XML file. #BobTodd's answer gives a list of most of your options, but I would say the choice comes down to Cookie vs. local storage. The choice will be made based on the volume of information you would like to save. Cookies are a lot simpler, but only allow a small amount of data to be saved.

Categories