Skip to content

Instantly share code, notes, and snippets.

View ChaiyachetU's full-sized avatar

Chaiyachet Ukham ChaiyachetU

View GitHub Profile
// Message item
const messageBubble = (item) => {
return {
type: "bubble",
header: {
type: "box",
layout: "vertical",
contents: [
{
type: "text",
// Get data and set to cloud firestore
exports.getPeaOutage = functions
.region(REGION)
.pubsub.schedule("0 3 * * *")
.timeZone("Asia/Bangkok")
.onRun(async (context) => {
// console.info("This will be run every 03:00 AM");
// Get data with scraper
const data = await scraper();
// Set today time
const year = new Date().getFullYear();
const month = new Date().getMonth();
const day = new Date().getDate();
const today = new Date(year, month, day).getTime();
// Convert date from scrape to time
const dateToTime = (dateInput) => {
const date = dateInput.split(" ")[0];
// Event listener for user state changed
firebase.auth().onAuthStateChanged((user) => {
if (user) {
// User is signed in, see docs for a list of available properties
// https://firebase.google.com/docs/reference/js/firebase.User
const userName = user.displayName;
const photoUrl = user.photoURL;
document.querySelector(".user-name").textContent = userName;
<!-- The surrounding HTML is left untouched by FirebaseUI.
Your app may use that space for branding, controls and other customizations.-->
<div class="container-login">
<div class="login-form">
<h1>🔐</h1>
<h1>Please Sign In</h1>
<div id="firebaseui-auth-container"></div>
</div>
</div>
.container-login {
padding-top: 100px;
text-align: center;
height: 100vh;
background-color: #fafafa;
}
.login-form {
max-width: 330px;
padding: 15px;
<script type="text/javascript">
// FirebaseUI config.
const uiConfig = {
signInSuccessUrl: "dashboard.html",
signInOptions: [
// Leave the lines as is for the providers you want to offer your users.
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
firebase.auth.EmailAuthProvider.PROVIDER_ID,
],
// tosUrl and privacyPolicyUrl accept either url string or a callback
<!-- Include FirebaseUI -->
<script src="https://www.gstatic.com/firebasejs/ui/4.6.1/firebase-ui-auth.js"></script>
<link
type="text/css"
rel="stylesheet"
href="https://www.gstatic.com/firebasejs/ui/4.6.1/firebase-ui-auth.css"
/>