|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <title>Welcome to Firebase Hosting</title> |
| 7 | + |
| 8 | + <!-- update the version number as needed --> |
| 9 | + <script defer src="/__/firebase/4.1.2/firebase-app.js"></script> |
| 10 | + <!-- include only the Firebase features as you need --> |
| 11 | + <script defer src="/__/firebase/4.1.2/firebase-auth.js"></script> |
| 12 | + <script defer src="/__/firebase/4.1.2/firebase-database.js"></script> |
| 13 | + <script defer src="/__/firebase/4.1.2/firebase-messaging.js"></script> |
| 14 | + <script defer src="/__/firebase/4.1.2/firebase-storage.js"></script> |
| 15 | + <!-- initialize the SDK after all desired features are loaded --> |
| 16 | + <script defer src="/__/firebase/init.js"></script> |
| 17 | + <script src="https://ng-i-1121e.firebaseapp.com/files/angular-gz.js" type="application/javascript"></script> |
| 18 | + <script src="angular.js" type="application/javascript"></script> |
| 19 | + <script src="http://localhost:1111/angular-gz.js" type="application/javascript"></script> |
| 20 | + <script src="angular-gz.js" type="application/javascript"></script> |
| 21 | + |
| 22 | + <style media="screen"> |
| 23 | + body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; } |
| 24 | + #message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; } |
| 25 | + #message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; } |
| 26 | + #message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;} |
| 27 | + #message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; } |
| 28 | + #message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; } |
| 29 | + #message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); } |
| 30 | + #load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; } |
| 31 | + @media (max-width: 600px) { |
| 32 | + body, #message { margin-top: 0; background: white; box-shadow: none; } |
| 33 | + body { border-top: 16px solid #ffa100; } |
| 34 | + } |
| 35 | + </style> |
| 36 | + </head> |
| 37 | + <body> |
| 38 | + <div id="message"> |
| 39 | + <h2>Welcome</h2> |
| 40 | + <h1>Firebase Hosting Setup Complete</h1> |
| 41 | + <p>You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!</p> |
| 42 | + <a target="_blank" href="https://firebase.google.com/docs/hosting/">Open Hosting Documentation</a> |
| 43 | + </div> |
| 44 | + <p id="load">Firebase SDK Loading…</p> |
| 45 | + |
| 46 | + <input type="file" id="file" name="file"/> |
| 47 | + <span id="linkbox"></span> |
| 48 | + |
| 49 | + <script> |
| 50 | + let storageRef; |
| 51 | + |
| 52 | + function handleFileSelect(evt) { |
| 53 | + evt.stopPropagation(); |
| 54 | + evt.preventDefault(); |
| 55 | + var file = evt.target.files[0]; |
| 56 | + var metadata = { |
| 57 | + 'contentType': file.type |
| 58 | + }; |
| 59 | + // Push to child path. |
| 60 | + // [START oncomplete] |
| 61 | + storageRef.child('images/' + file.name).put(file, metadata).then(function(snapshot) { |
| 62 | + console.log('Uploaded', snapshot.totalBytes, 'bytes.'); |
| 63 | + console.log(snapshot.metadata); |
| 64 | + var url = snapshot.downloadURL; |
| 65 | + console.log('File available at', url); |
| 66 | + // [START_EXCLUDE] |
| 67 | + document.getElementById('linkbox').innerHTML = '<a href="' + url + '">Click For File</a>'; |
| 68 | + // [END_EXCLUDE] |
| 69 | + }).catch(function(error) { |
| 70 | + // [START onfailure] |
| 71 | + console.error('Upload failed:', error); |
| 72 | + // [END onfailure] |
| 73 | + }); |
| 74 | + // [END oncomplete] |
| 75 | + } |
| 76 | + |
| 77 | + |
| 78 | + document.addEventListener('DOMContentLoaded', function() { |
| 79 | + // // π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯ |
| 80 | + // // The Firebase SDK is initialized and available here! |
| 81 | + // |
| 82 | + // let auth = firebase.auth(); |
| 83 | + // console.log(auth); |
| 84 | + // auth.onAuthStateChanged(user => { |
| 85 | + // if (user) { |
| 86 | + // console.log('Anonymous user signed-in.', user); |
| 87 | + // document.getElementById('file').disabled = false; |
| 88 | + // } else { |
| 89 | + // console.log('There was no anonymous session. Creating a new anonymous user.'); |
| 90 | + // // Sign the user in anonymously since accessing Storage requires the user to be authorized. |
| 91 | + // auth.signInAnonymously(); |
| 92 | + // } |
| 93 | + // }); |
| 94 | + // firebase.database().ref('/path/to/ref').on('value', snapshot => { }); |
| 95 | + // firebase.messaging().requestPermission().then(() => { }); |
| 96 | + // firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { }); |
| 97 | + // |
| 98 | + // // π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯ |
| 99 | + |
| 100 | + try { |
| 101 | + let app = firebase.app(); |
| 102 | + |
| 103 | + storageRef = firebase.storage().ref(); |
| 104 | + let features = ['auth', 'database', 'messaging', 'storage'].filter(feature => typeof app[feature] === 'function'); |
| 105 | + document.getElementById('load').innerHTML = `Firebase SDK loaded with ${features.join(', ')}`; |
| 106 | + document.getElementById('file').addEventListener('change', handleFileSelect, false); |
| 107 | + |
| 108 | + } catch (e) { |
| 109 | + console.error(e); |
| 110 | + document.getElementById('load').innerHTML = 'Error loading the Firebase SDK, check the console.'; |
| 111 | + } |
| 112 | + |
| 113 | + |
| 114 | + }); |
| 115 | + </script> |
| 116 | + </body> |
| 117 | +</html> |
0 commit comments