I've done plenty of web development at a pretty basic level, and usually just local pages to be called from shared network drives.
Here is where I'm stuck:
I am attempting to build a simple application for work where other leads and I can open a local html page from our shared drive, and add/remove employee names to different tasks, so we can keep tabs on who's doing what.
The tasks are the same every day, just hardcoded titles on sectioned out divs.
Problem is, I can't figure out how to make it to where changes I make will populate for other people with the window open (considering this is just a local page and not a live environment being hosted on anything).
For the general design, I've toyed with hard coding all the employee names under each task in hidden div tags, with a bit of jquery to make the div visible when that worker is assigned.
I have also toyed with appending data to the existing tags using .innerHTML.
Still have no idea how to make this live so we can see each others changes.
Can you point me in the right direction?
I've figured it out. It may be a bit on the lazy side, but i'm just setting the HTML page to auto refresh every 5s. The data displayed will pull from a notepad doc that leads will be able to update and save.
I am assuming that you just want your peers to be able to see the changes your making live? If so you need to use Ajax. You could set it to ping the server every so often to update on the fly. I'm still quite uncertain as to whether or not that was your question, but if not please elaborate or post your code so I can help further.
Related
I know there are many similar questions, however, they are all piecemeal to the problem I have, and I haven't been successful in putting the information together.
I am using a FLIR ax8 thermal camera, and this camera has a web-interface that one can interact with via ethernet. Long story short, temperature values are constantly displayed and updated, and I would like to scrape those values. I would like to do this without opening a browser with a GUI, and just be able to call every so often to get them.
The first step is a simple login page, located at "cameraIP"/login. It's very basic, but I need a solution that gets me through this, and be able to maintain the login session. Then it's just the interface. Attached are two images, the first showing interface as seen in Chrome, and the second a terminal output of what I scraped using Python's Requests module.
As you can see, the numbers are clearly not there, as they are rendered by JavaScript. This is essentially all I have to work with. If someone could give advice on how this is possible to get those temperature values every so often, that would be great.
If there are ANY questions, just leave a comment down below and I can provide more information, such as the JS files listed under the web interface if they are needed.
I personally use scrapy splash to render the javascript when scraping using scrapy: http://splash.readthedocs.io/en/stable/
As RIAs and SPAs (or web apps with heavy javascript usage) have become more and more popular, I've been running into systems that, instead of using good old a href hyperlinks, I see them utilizing constructs using onclick with JavaScript code that manipulates navigation. This is particularly true with images.
For example, instead of seeing something like this:
<img src="...."/>
<div ... onclick='SomeJsFunctionThatNavsToAnotherPage()'><img src="..."/></a>
What is the advantage of this? It makes it incredibly hard to trace where pages transition to when debugging or trying to root cause a bug. I can get the idea when the target to navigate can change (so yes, here you could use a function that computes to what page to navigate to.)
But I see this pattern even when the pages to navigate to are constant. I find this extremely convoluted and hard to test. Not to mention that there is always the browser-specific bugs that come from stuff (sadly in my experience from over-complexifying the front-end.)
But I am not a RIA/SPA developer (just backend and traditional web development). Am I missing the rationale behind this?
TO CLARIFY
My question is not for the case when we want to redraw the page or change current content without changing the current location. My question is for plain
old transitions, from page A to page B.
In such a case, why use onclick=funcToChangeLocation() over <a href="some location"/>.
This has been a pain for me when troubleshooting systems that are already written (for I wouldn't write them like that), but there could be reasons I am not aware of.
Again, my question is not for pages that redraw themselves without changing the browser location, but for navigation from one page to the next.
ALSO
If you are going to vote to close this question, at least leave a message explaining why.
If you are making a web application, sometime you don't want to redirect the user to another page, but you want to dynamically change the content of the page without refreshing the page. It has some advantages. It can be faster. You can easily keep the state of the page/application. You are not obligated to communicate with the server. You can update only a part of the page.
You can also dynamically request data to print the page. If you are displaying an user profile page, you can only ask a json object that represent the user. This json object is smaller than the whole page and will be dynamically rendered. It can help to reduce the data transfer between users and server when your bandwidth is limited.
EDIT: In the case of a simple page redirection, I think it's a bad practice and I cannot see an advantage. I think it obfuscate the website when the google crawler try to parse the website.
I once had a pretty successful web directory website. One day Google decided that "directories" are competing businesses and started penalizing sites that had links on directories. I used the method you describe to cloak outgoing links to try and trick Google.
I get some data from a page abc.html using Ajax and I store it in a table.
Once the data get stored in the table(i.e. commit takes place), I want that data to be updated in the page xyz.html in runtime so that the users can see the updates without having to refresh the page.
I have got the data and updated the data in the table.
But I don't know what to do once the data gets stored in the table.
I believe ajax is required to update the webpage xyz.html.
It would be of great help if someone can point to a resource on what approach to follow to implement it.
--Update--
I am a newbie but I am not asking anyone to write the code for me. Thanks.
You are going to have to look into something like Socket.IO for real-time updating.
http://socket.io/
Basically, socket.io is a javascript library built on top of Node.JS that constantly trolls a servers looking for new activity. This is sort of ajax, but an ajax request is normally prompted by a user (by a button click or scrolling to the bottom of the page, for example).
I'm not gonna write the code for you. If you are new, it's not going to be an easy thing to accomplish. This may seem like a simple feature, but it's actually quite complex.
If you start writing code, and get stuck, come back and ask a question, but no one is going to write this feature for you for free buddy, sorry.
Here is a tutorial on how to write a real-time updating chat-application with Socket.IO. Take some time and get to know how Socket.IO works and you should be able to figure out how to make it work for your needs.
I am trying to conduct a online quiz competition for an event, I have disabled the user from selecting text, images etc.
But now important thing I need is to disable navigation. User should not be able to navigate to other window, or even can not open any other program for help until the quiz ends.
This page is created using HTML, PHP and Java Script.
Thanks for any help.
Your website is handled by the browser. No browser will allow you to access the desktop to this extent and put restrictions like this. Generally for such things, websites keep time limit. Since the websites cant control if the user refers somewhere else, they can control how much time you take to answer each question. You can set a time such that they may not get enough time to refer. Also you need to make sure that handling the time is fully done from php not js. Php can have a session variable to save the time when the question is request and when the answer is submitted, the php code can check how much time the user has taken. If you try from js it maybe easier by can be edited from the user.
If you still want to stop the user from using any other application, you need to create a software not a website.
I am trying to create a quiz on a web-page using HTML and JavaScript. Each question (having 4 options to choose from) is a seperate html file but uses the same JavaScript file to evaluate whether the choice entered is right or wrong.
However, I’m struggling to find a way to keep track of the number of correct answers provided by the users to calculate his/her score.
Is there a method to create static or static-like variables in JavaScript? Solutions involving cookies are also appreciated.
One possible solution is to load the HTML from your question file into a parent page, but have the whole quiz on that one page. That way, you still get the flexibility of having different pages for each question, but to the browser they are all one page. In addition, any variables created or traked in Javascript will persist throughout the entire quiz.
This is fairly easy to do with Jquery's .load function. You have a div in the middle of your page which loads its content from whichever HTML page you would have navigated to.
Do keep in mind that it is trivially easy for me to go into Javascript and change the number of correct answers. In fact, that problem exists for any client side solution. Should this be for more than fun, and accuracy is important, you may want to send results back to your server after each question. That way, no matter how you implement the quiz, results are persisted back on your end.
Have a look at http://www.electrictoolbox.com/jquery-cookies/
This allows you to easily set and read cookies.
You can keep the data in cookie. however an user may change the cookie and produce better result. Using session is a better choice in this scenario. because whatever you store in client side is unsafe.
However It is better to get the questions in json format with xhr and display them in browser and keep the track in memory
If you are developing a HTML5 application you may wish to investigate DOM storage facilities such as localStorage and sessionStorage: https://developer.mozilla.org/en-US/docs/DOM/Storage
Here are some useful resources / info:
http://ejohn.org/blog/dom-storage/
http://viralpatel.net/blogs/introduction-html5-domstorage-api-example/
http://msdn.microsoft.com/en-us/library/cc197062(v=vs.85).aspx
These days I would focus on making this a one-page app rather than relying on page loads. This not only has the advantage of solving your problem, it also means a more responsive, faster experience for the user.
If you must use page transitions, and you're happy to work with modern browsers only, look into localStorage. Far easier to use and more flexible than cookies - it works just like a serialised JavaSCript object.