Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. <img class="imagecl" src="img/a cuddly toy.png">
  2.  
  3. <img class="imagecl" src="file:///data/user/0/com.aacproject.mirel/files/files/MyAppFolder/1560707846571.jpg">
  4.  
  5. <head>
  6. <meta name="format-detection" content="telephone=no">
  7. <meta name="msapplication-tap-highlight" content="no">
  8. <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover, user-scalable=no">
  9. </head>
  10.  
  11. <body>
  12. [...]
  13. </div>
  14. <div class="image">
  15. <img class="imagecl" src="img/a cuddly toy.png"/>
  16. </div>
  17. <div class="image">
  18. <img class="imagecl" src="img/a kind of.png"/>
  19. </div>
  20. <div class="image">
  21. <img class="imagecl" src="img/a part.png"/>
  22. </div>
  23. [...]
  24. </body>
  25.  
  26. imageCLarray.forEach(image => {
  27. image.addEventListener('longtap', () => {
  28. navigator.camera.getPicture(onSuccess, onFail, {
  29. quality: 50,
  30. destinationType: Camera.DestinationType.FILE_URI
  31. });
  32.  
  33. function onSuccess(imageURI) {
  34. window.localStorage.setItem('imagepath', imageURI)
  35. image.setAttribute("src", window.localStorage.getItem('imagepath'))
  36. }
  37.  
  38. function onFail(message) {
  39. alert('Failed because: ' + message);
  40. }
  41. })
  42. })
  43.  
  44. imageCLarray.forEach(image => {
  45. image.addEventListener('longtap', () => {
  46. navigator.camera.getPicture(onSuccess, onFail, {
  47. quality: 50,
  48. destinationType: Camera.DestinationType.DATA_URL
  49. });
  50.  
  51. function onSuccess(imageData) {
  52. var base64imageData = "data:image/jpeg;base64," + imageData;
  53. window.localStorage.setItem('imagepath', base64imageData)
  54. image.setAttribute("src", window.localStorage.getItem('imagepath'))
  55. }
  56.  
  57. function onFail(message) {
  58. alert('Failed because: ' + message);
  59. }
  60. })
  61. })
  62.  
  63. imageCLarray.forEach(image => {
  64. image.addEventListener('longtap', () => {
  65. navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
  66. destinationType: Camera.DestinationType.FILE_URI,
  67. saveToPhotoAlbum: true });
  68.  
  69. function onPhotoDataSuccess(imageURI) {
  70. movePic(imageURI)
  71. }
  72.  
  73. function onFail(message) {
  74. alert('failed '+message)
  75. }
  76.  
  77. function movePic(file) {
  78. window.resolveLocalFileSystemURI(file, resolveOnSuccess, resOnError)
  79. }
  80.  
  81. // Callback function when the file system uri has been resolved
  82. function resolveOnSuccess(entry){
  83. var d = new Date();
  84. var n = d.getTime();
  85. //new file name
  86. var newFileName = n + ".jpg";
  87. var myFolderApp = 'MyAppFolder';
  88. window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
  89. //The folder is created if doesn't exist
  90. fileSys.root.getDirectory( myFolderApp,
  91. {create:true, exclusive: false},
  92. function(directory) {
  93. entry.moveTo(directory, newFileName, successMove, resOnError);
  94. },
  95. resOnError);
  96. }
  97.  
  98. , resOnError);
  99. }
  100.  
  101. function successMove(entry) {
  102. localStorage.setItem('imagepath', entry.toURL())
  103. image.src = localStorage.getItem('imagepath')
  104. console.log(image.src)
  105. }
  106.  
  107. function resOnError (er) {
  108. alert('error is '+er.code)
  109. }
  110.  
  111. })
  112. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement