Guest User

Untitled

a guest
Dec 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. requestStorageAccessAndServe() {
  2. let thisObject = this;
  3. var promise = document.hasStorageAccess();
  4. promise.then(
  5. function (hasCookieAccess) {
  6. if (!hasCookieAccess) {
  7. document.requestStorageAccess().then(
  8. function successful() {
  9. // reload iframe to run with cookie access
  10. window.location.reload();
  11. },
  12. function fail() {
  13. thisObject.serveContent(); // Code goes into here
  14. });
  15. } else {
  16. thisObject.serveContent();
  17. }
  18. },
  19. function (reason) {
  20. thisObject.serveContent();
  21. }
  22. );
  23.  
  24. }
  25.  
  26. requestStorageAccessAndServe() {
  27. let thisObject = this;
  28. let hasCookieAccess = !!document.cookie;
  29. if (!hasCookieAccess) {
  30. document.requestStorageAccess().then(
  31. function successful() {
  32. window.location.reload();
  33. },
  34. function fail() {
  35. thisObject.serveContent();
  36. });
  37.  
  38. } else {
  39. thisObject.serveContent();
  40. }
  41. }
Add Comment
Please, Sign In to add comment