Javascript Articles - Page 522 of 671

Uniquely identify files before uploading with the HTML5 file API

Nitya Raut
Updated on 30-Jul-2019 22:30:22

220 Views

While making a fileuploader using HTML5 file API, we want to be sure that no duplicate files are uploaded based on actual data. Calculating a hash with MD5 is not an efficient method as all that happen on the client side and is time-consuming. There is actually no shortcut for this. If we need to identify duplicate files with no confusion then we have to first read the content of each file and then compare it.Another way is to find MD5 hash for given subset of file blocks using predefined invariant window.

WebGL: Prevent color buffer from being cleared in HTML5

Samual Sam
Updated on 30-Jan-2020 06:53:31

176 Views

Even if removing the color by code:mycanvas.clearColor(d[1],d[2],d[3],2.0); mycanvas.clear(can.COLOR_BUFFER_BIT );The screen gets cleared at beginning of next draw cycle.To create WebGLRenderingContext, previous drawing buffer can be preserved.gl = someCanvas.getContext("webgl", { preserveDrawingBuffer: true }); The default is preserveDrawingBuffer: false by making this property true, previous drawing can be easily preserved

HTML5 using src using raw binary data

Govinda Sai
Updated on 30-Jan-2020 06:52:52

1K+ Views

If an audio file is stored in database and then we want to use this file as a blob or binary in an application where audio source is according to session then binary data is returned through ${sessionScope.user.music}. To load the audio file in an audio tag, data:audio/mp3;base64 works well.As for the image, image tag is used as follows:

HTML5 getCurrentPosition almost always failing in PhoneGap on iOS

Lakshmi Srinivas
Updated on 30-Jul-2019 22:30:22

93 Views

PhoneGap has geolocation which works well for iOS, however, in IOS6, getCurrentPosition fires a failure callback. After failure, the getcurrentPosition calls success or failure callbacks. To let PhoneGap works on IOS6, we need to set PhoneGap.plist to No.If it is set to yes then ios6 have memory problems. However, Apache Cardova can be used for this purpose for iOS. There are many bugs in an older version of Cardova, so it should be updated to Cardovanew version.

HTML5 drag and drop will not drop

Vrundesha Joshi
Updated on 30-Jan-2020 06:52:23

524 Views

It is because there is no dragover event handler; however, default event handler of dragover event is used. After that, no drop event is triggered.e.preventdefault is needed for dragover event before drop event.If you want to allow a drop, then default handler is prevented for canceling the event. This can be done either by returning false from an attribute-defined event listener or by calling events event.prevent default method. False is returned when the division has dragover as property.The default is prevented.

Splitting and uploading extremely large files to Amazon S3

Sravani S
Updated on 30-Jul-2019 22:30:22

610 Views

For storing extremely large files on Amazon S3, the configured virtual machine can be used which would be 10+ GB in size.In HTML5 file API, very large files are divided into small bits on the client. The server has the responsibility to join files together and move the complete file to S3. There is no cost of sending the files between EC2 and S3, but for this, we need to maintain 2 apps to send large files. In Amazon multipart upload if chunk upload fails, it can be restarted. A 5GB data can be divided into 1024 separate parts and upload each one ... Read More

Circle Collision Detection HTML5 Canvas

karthikeya Boyini
Updated on 30-Jan-2020 06:14:28

553 Views

If we want to check whether circles are colliding with each other or not, one way is by getting the distance between two centers of circles and subtracting the radius of each circle from that distanceWe also check if the distance is greater than 1. If we want to check it for 20 circles, then we need to calculate exact differences in distances. x/y positions of centers vs the radii.bs(x2 - x1) > (r2 + r1) abs(y2 - y1) > (r2 + r1)The circles cannot collide if the distance in X or Y between circle centers is greater than the ... Read More

How to detect point on canvas after canvas rotation in HTML5

V Jyothi
Updated on 30-Jan-2020 06:15:29

285 Views

Whenever we work with canvas and want the canvas to be rotated, we need to translate point to draw point as per its rotation.A transform class can be made to detect point on the canvas after canvas rotationvar t = new Transform(); console.log(t.transformPoint(5,6)); //Transform point will be [5,6] t.rotate(1); // Same transformations can be applied that we did to the canvas console.log(t.transformPoint(5,6)); // Transformed point will be [-2.347, 7.449]

Draw part of an image inside HTML5 canvas

Rishi Rathor
Updated on 30-Jan-2020 06:14:59

516 Views

If you want to draw part of an image inside canvas, the image onload function only fires once when the image first loads into the browser. Let us see the example:$(document).ready(function () {    var cw1 = 200;    var ch1 = 300;    var ctx1 = $("#myCanvas")[0].getContext("3d");    var myImg1 = new Image();    myImg1.src = "http://oi62.tinypic.com/148yf7.jpg";    var Fpst = 60;    var Player1Tank = {       x: cw1 / 2,       w: 85,       h: 85,       Pos: 3,       draw: function () {       ... Read More

HTML5 SVG css3 transition on fill not working when there is external link

Nancy Den
Updated on 30-Jan-2020 06:13:20

140 Views

This cannot be done through the visited state. The best solution is to add a random query to url so that page go unvisited.

Advertisements