10 examples of 'javascript image complete' in JavaScript

Every line of 'javascript image complete' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
1275function imageLoaded(image, callback) {
1276
1277 if (!image.nodeName || image.nodeName.toLowerCase() !== 'img')
1278 return callback(new Error('First argument must an image element'));
1279
1280 if (image.src && image.complete && image.naturalWidth !== undefined)
1281 return callback(null, true);
1282
1283 image.addEventListener('load', function() {
1284 callback(null, false);
1285 }.bind(this));
1286
1287 image.addEventListener('error', function(e) {
1288 callback(new Error('Failed to load image \'' + (image.src || '') + '\''));
1289 }.bind(this));
1290
1291 if (image.complete) {
1292 src = image.src;
1293 image.src = BLANK;
1294 image.src = src;
1295 }
1296}
93function onSuccessImageLoad(image, options) {
94 var canvas = document.createElement('canvas');
95 canvas.width = image.width;
96 canvas.height = image.height;
97 var context = canvas.getContext('2d');
98 // draw actual image.
99 context.drawImage(image, 0, 0);
100 var imageData = context.getImageData(0, 0, image.width, image.height);
101 var annotations = new Image();
102 annotations.src = options.annotation;
103 annotations.crossOrigin = null;
104 annotations.onerror = function() { onErrorImageLoad(annotations); };
105 annotations.onload = function() {
106 onSuccessAnnotationLoad(annotations, imageData, options);
107 };
108}
254function notifyOnImageComplete() {
255 var img = document.getElementById("sheet")
256 if (img.complete) {
257 onTextureLoaded()
258 } else {
259 img.addEventListener('load', onTextureLoaded)
260 }
261}
54async function imageLoad() {
55 loadedImages = [];
56 for (let i = 0; i < extractedImages.length; i++) {
57 let img = new Image();
58 let imgSrc = path.join(filePath, encodeURIComponent(extractedImages[i]));
59 img.src = imgSrc;
60 loadedImages.push(img);
61 }
62}
218function insertImageCallback(data) {
219 var cm = _editor.codemirror;
220 var output = data + '](' + webRoot + data + ')';
221
222 if (data.toLowerCase().match(/.(mp4|ogv|webm)$/i)) {
223 var extv = 'mp4';
224 if (data.toLowerCase().match(/.(ogv)$/i)) { extv = 'ogg'; }
225 if (data.toLowerCase().match(/.(webm)$/i)) { extv = 'webm'; }
226 output = '\r\n Your browser does not support the video tag.\r\n';
227 }
228 else if (data.toLowerCase().match(/.(mp3|ogg|wav)$/i)) {
229 var exta = 'mp3';
230 if (data.toLowerCase().match(/.(ogg)$/i)) { exta = 'ogg'; }
231 if (data.toLowerCase().match(/.(wav)$/i)) { exta = 'wav'; }
232 output = '\r\n Your browser does not support the audio tag.\r\n';
233 }
234 else if (data.toLowerCase().match(/.(jpg|jpeg|png|gif)$/i)) {
235 output = '\r\n![' + output;
236 }
237 else {
238 output = '\r\n[' + output;
239 }
240 var selectedText = cm.getSelection();
241 cm.replaceSelection(output);
242}
259function image_load (image) {
260 image_n = images.indexOf(image);
261 var group = image.split("_")[1].split(".")[0].replace(/^[0-9]|[0-9]$/g, "");
262 if (image == "sc_system2.png") {
263 var map = "system";
264 } else {
265 var map = "pn";
266 }
267 document.getElementById('screen').innerHTML ="";
268 document.getElementById('screen2').innerHTML ="";
269 document.getElementById('info').innerHTML = "" + group.toUpperCase() + " (" + (image_n + 1) + "/" + images.length + ")";
270 fade_val = 0.0;
271 document.getElementsByClassName("screen2")[0].style.opacity = fade_val;
272 image_fade();
273 LastIMG = image;
274}
483function doImage(err, canvas) {
484 var img = document.createElement('img');
485 var dimensions = map.getSize();
486 img.width = dimensions.x;
487 img.height = dimensions.y;
488 img.src = canvas.toDataURL("image/png");
489
490 var suffixe_file = $("select").val()[0];
491 var suffix;
492 auj = new Date();
493 auj.setDate(auj.getDate() - 1);
494 auj = auj.getFullYear() + '_' + parseInt(auj.getMonth() + 1) + '_' + auj.getDate();
495 if (suffixe_file === "1") {
496 suffix = 'centres_ebola_guinee_' + auj;
497 }
498 else if (suffixe_file === "2") {
499 suffix = 'cte_guinee_' + auj;
500 }
501 else if (suffixe_file === "3") {
502 suffix = 'cdt_guinee_' + auj;
503 }
504 else if (suffixe_file === "4") {
505 suffix = 'cts_guinee_' + auj;
506 }
507 else{
508 suffix = 'labos_guinee_' + auj;
509 };
510
511 $("a#print").attr("download", suffix + '.png')
512 $("a#print").attr("href", img.src)
513
514 $('#wheel').hide();
515 $("a#print").html("Télécharger la carte");
516 $('.dlmap').fadeIn("slow");
517 }
81function onLoadComplete() {
82 image.removeEventListener('load', onLoadComplete);
83 image.removeEventListener('error', onLoadComplete);
84 var texture:Texture = Texture.create(request.url);
85 texture.bitmapData = image;
86 TextureCache.getInstance().addTexture(request.url, texture);
87 request.callback.call(request.thisObj, texture);
88
89};
353function imgLoadedHandler(event) {
354 /*jshint validthis:true */
355 event = event || w.event;
356 // Unbind loaded handler from temporary image
357 unbind(this[ILID].tmpImg || {}, EVENTS, imgLoadedHandler);
358 // Leave the temporary image for garbage collection
359 this[ILID].tmpImg = null;
360 // Don't proceed if image is already loaded
361 if (inArray(this, self.loaded) === -1) {
362 imgLoaded(this, event.type !== 'load');
363 }
364}
63function onImageUploadComplete(data) {
64 lastAvatarUrl = null;
65 console.log('received', data);
66 if (typeof data == 'string') {
67 if (data.indexOf('{') == -1 && data.toLowerCase().indexOf('too large'))
68 data = {
69 error: 'Your file is too large. Please resize it and try again.'
70 };
71 else
72 data = JSON.parse(
73 data.substring(data.indexOf('{'), data.lastIndexOf('}') + 1)
74 );
75 }
76 try {
77 var img = data.postImg || data.file;
78 lastUploadUrl = (img.path[0] != '/' ? '/' : '') + img.path;
79 if (img.mime && img.mime.indexOf('image/') == 0) {
80 lastAvatarUrl = lastUploadUrl;
81 options.onImageUploadComplete &&
82 options.onImageUploadComplete(lastAvatarUrl);
83 } else options.onError('Invalid image. Please try with another image!');
84 } catch (e) {
85 options.onError(
86 data.error || 'Upload did not work... Please try again!',
87 e
88 );
89 }
90 setAvatar(lastAvatarUrl);
91}

Related snippets