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.
1275 function 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 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
93 function 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 }
254 function notifyOnImageComplete() { 255 var img = document.getElementById("sheet") 256 if (img.complete) { 257 onTextureLoaded() 258 } else { 259 img.addEventListener('load', onTextureLoaded) 260 } 261 }
54 async 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 }
218 function 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 = '<video width="320" height="240" controls>\r\n <source src="' + webRoot + data; 227 output += '" type="video/' + extv + '">Your browser does not support the video tag.\r\n</video>'; 228 } 229 else if (data.toLowerCase().match(/.(mp3|ogg|wav)$/i)) { 230 var exta = 'mp3'; 231 if (data.toLowerCase().match(/.(ogg)$/i)) { exta = 'ogg'; } 232 if (data.toLowerCase().match(/.(wav)$/i)) { exta = 'wav'; } 233 output = '<audio controls>\r\n <source src="' + webRoot + data; 234 output += '" type="audio/' + exta + '">Your browser does not support the audio tag.\r\n</audio>'; 235 } 236 else if (data.toLowerCase().match(/.(jpg|jpeg|png|gif)$/i)) { 237 output = '\r\n![' + output; 238 } 239 else { 240 output = '\r\n[' + output; 241 } 242 var selectedText = cm.getSelection(); 243 cm.replaceSelection(output); 244 }
259 function 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 ="<IMG class=\"screen1\" src=\"infohtml/" + LastIMG + "\" border=\"0\" usemap=\"#map_" + map + "\">"; 268 document.getElementById('screen2').innerHTML ="<IMG class=\"screen2\" src=\"infohtml/" + image + "\" border=\"0\" usemap=\"#map_" + map + "\">"; 269 document.getElementById('info').innerHTML = "<CENTER>" + group.toUpperCase() + " (" + (image_n + 1) + "/" + images.length + ")</CENTER>"; 270 fade_val = 0.0; 271 document.getElementsByClassName("screen2")[0].style.opacity = fade_val; 272 image_fade(); 273 LastIMG = image; 274 }
483 function 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 }
81 function 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 };
353 function 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 }
63 function 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 }