JavaScript

Important use cases are not tested

With a small change (styling, new fields) during the development lot of Use-Cases can crash. To avoid the high effort of the testing all the important cases, testing should be automated. Tools like Selenium provides an capture and replay mechanism. Build servers (Bamboo) can then be configured to start the test on if something gets merged into the master branch.

No logging of user behavior

When the application gets delivered to the client for the test production, there are usually exists bugs. The testing user creates BugTickets, with the necessary information‘s what was wrong during their test run. For lager workflows it‘s not possible to provide all the information‘s (selections, inputs) during their testing. It‘s necessary to provide a logging service to provide all the steps during the test. Kibana and Zipkin provides a tool to publish this huge amount of information.

Changed REST Endpoints

The problem occurs when separate teams needs to communicate over an REST Endpoint. When someone changes the endpoint and did not mentioned it, problems occur. Therefore it is necessary to use an SWAGGER API and publish all the endpoints and give warnings if changes occur.

Use the following javascript snippet to access the Users location.

var x = document.getElementById("pos"); function getLocation() {
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation not enabled.";
} }

function processPosition(position) {
x.innerHTML = "Lat: " +
position.coords.latitude + "<br>Long: " +
position.coords.longitude;
}

By navigator.geolocation the user will be asked for permission to share the location. navigator.geolocation.getCurrentPosition(showPosition) retrieves the location and passes it to the callback function showposition. In the position.coords object lat and long can be accessed, displayed or sent to a server via REST.

OperatingSystem:

ProgrammingLanguage:

Accessing location in browser

I want to implement a location dependent web application, is there any way of getting access to the users location in the browser?

While constant monitoring and optimizing of the code is always a good idea, there is also a process called “Minification” to do so. During a project for a university course I had to use the service minifier.org to reduce the file size of my js- and css-files. It reduces unnecessary text, like comments or whitespaces from those files and even optimizes Javascript code according to common programming optimization patterns.

Reducing load times and size of scripts and CSS-files

Web services that include a lot of scripts or costly style operations may be very slow, as a lot must be loaded in the background. Is there a way to make these pages load faster?

There are many different possibilities to answer this question. We will go top down beginning with the browser.
Most of the browsers support the html input tag of type "email" and most of them would automatically warn the user about a wrong format of the address. However there are many standards of email address pattern. Furthermore the user might disable the browser validation, so we should not rely on this.
The second station is the javascript of the browser. Probably the easiest way to validate the email address is to use a regular expression an match the input against this expression. However the user may disable the javascript or send a request in other way than browser. Therefore it's absolutely necessary to validate the email address on the server side. This might be done by a regular expression, but some more sophisticated systems would check the MX record of the domain given in the email address, to be sure it might be a real address of a real mail server.

OperatingSystem:

ProgrammingLanguage:

Technology:

Window.event does not exist in Firefox. Different browsers have different event models. Firefox handles the events slightly different IE and Chrome and for that reason it has not worked. A work-around is to pass the event as an argument to the function:
<a onclick="testfunction(event);">
 //...
</a>

testfunction(e){
 evt = e || window.event;
 //...
}

or use a library like jQuery to avoid dealing with all the differences between the browsers.

Disabling javascript on sites with pop-ups also might help.

Taggings:

Pages

Subscribe to JavaScript