Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <img class="imagecl" src="img/a cuddly toy.png">
- <img class="imagecl" src="file:///data/user/0/com.aacproject.mirel/files/files/MyAppFolder/1560707846571.jpg">
- <head>
- <meta name="format-detection" content="telephone=no">
- <meta name="msapplication-tap-highlight" content="no">
- <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover, user-scalable=no">
- </head>
- <body>
- [...]
- </div>
- <div class="image">
- <img class="imagecl" src="img/a cuddly toy.png"/>
- </div>
- <div class="image">
- <img class="imagecl" src="img/a kind of.png"/>
- </div>
- <div class="image">
- <img class="imagecl" src="img/a part.png"/>
- </div>
- [...]
- </body>
- imageCLarray.forEach(image => {
- image.addEventListener('longtap', () => {
- navigator.camera.getPicture(onSuccess, onFail, {
- quality: 50,
- destinationType: Camera.DestinationType.FILE_URI
- });
- function onSuccess(imageURI) {
- window.localStorage.setItem('imagepath', imageURI)
- image.setAttribute("src", window.localStorage.getItem('imagepath'))
- }
- function onFail(message) {
- alert('Failed because: ' + message);
- }
- })
- })
- imageCLarray.forEach(image => {
- image.addEventListener('longtap', () => {
- navigator.camera.getPicture(onSuccess, onFail, {
- quality: 50,
- destinationType: Camera.DestinationType.DATA_URL
- });
- function onSuccess(imageData) {
- var base64imageData = "data:image/jpeg;base64," + imageData;
- window.localStorage.setItem('imagepath', base64imageData)
- image.setAttribute("src", window.localStorage.getItem('imagepath'))
- }
- function onFail(message) {
- alert('Failed because: ' + message);
- }
- })
- })
- imageCLarray.forEach(image => {
- image.addEventListener('longtap', () => {
- navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
- destinationType: Camera.DestinationType.FILE_URI,
- saveToPhotoAlbum: true });
- function onPhotoDataSuccess(imageURI) {
- movePic(imageURI)
- }
- function onFail(message) {
- alert('failed '+message)
- }
- function movePic(file) {
- window.resolveLocalFileSystemURI(file, resolveOnSuccess, resOnError)
- }
- // Callback function when the file system uri has been resolved
- function resolveOnSuccess(entry){
- var d = new Date();
- var n = d.getTime();
- //new file name
- var newFileName = n + ".jpg";
- var myFolderApp = 'MyAppFolder';
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
- //The folder is created if doesn't exist
- fileSys.root.getDirectory( myFolderApp,
- {create:true, exclusive: false},
- function(directory) {
- entry.moveTo(directory, newFileName, successMove, resOnError);
- },
- resOnError);
- }
- , resOnError);
- }
- function successMove(entry) {
- localStorage.setItem('imagepath', entry.toURL())
- image.src = localStorage.getItem('imagepath')
- console.log(image.src)
- }
- function resOnError (er) {
- alert('error is '+er.code)
- }
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement