-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13a09bf
commit 86dea12
Showing
18 changed files
with
134 additions
and
40 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: cargo | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "08:00" | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/target | ||
**/*.rs.bk | ||
Cargo.lock | ||
bin/ | ||
pkg/ | ||
wasm-pack.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "pweb" | ||
version = "0.1.0" | ||
authors = ["Daniel Choi <[email protected]>"] | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
default = ["console_error_panic_hook"] | ||
|
||
[dependencies] | ||
wasm-bindgen = "0.2.84" | ||
|
||
# The `console_error_panic_hook` crate provides better debugging of panics by | ||
# logging them with `console.error`. This is great for development, but requires | ||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for | ||
# code size when deploying. | ||
console_error_panic_hook = { version = "0.1.7", optional = true } | ||
chrono = { version = "0.4.34", features = ["wasmbind"] } | ||
|
||
[dev-dependencies] | ||
wasm-bindgen-test = "0.3.34" | ||
|
||
[profile.release] | ||
# Tell `rustc` to optimize for small code size. | ||
opt-level = "s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
mod utils; | ||
|
||
use chrono::Timelike; | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub fn greet() -> String { | ||
utils::set_panic_hook(); | ||
|
||
let time = chrono::offset::Local::now(); | ||
let hour = time.hour(); | ||
|
||
if (4..12).contains(&hour) { | ||
// morning | ||
"m".to_string() | ||
} else if (12..17).contains(&hour) { | ||
// afternoon | ||
"a".to_string() | ||
} else if (0..4).contains(&hour) { | ||
// evening | ||
"l".to_string() | ||
} else { | ||
// late | ||
"e".to_string() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pub fn set_panic_hook() { | ||
// When the `console_error_panic_hook` feature is enabled, we can call the | ||
// `set_panic_hook` function at least once during initialization, and then | ||
// we will get better error messages if our code ever panics. | ||
// | ||
// For more details see | ||
// https://github.com/rustwasm/console_error_panic_hook#readme | ||
#[cfg(feature = "console_error_panic_hook")] | ||
console_error_panic_hook::set_once(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//! Test suite for the Web and headless browsers. | ||
|
||
#![cfg(target_arch = "wasm32")] | ||
|
||
extern crate wasm_bindgen_test; | ||
use wasm_bindgen_test::*; | ||
|
||
wasm_bindgen_test_configure!(run_in_browser); | ||
|
||
#[wasm_bindgen_test] | ||
fn pass() { | ||
assert_eq!(1 + 1, 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
import { greet } from "./pweb/pkg/pweb"; | ||
|
||
// Get the time when the site was first opened... | ||
let d = new Date; | ||
let theHour = d.getHours(); | ||
let theMin = d.getMinutes(); | ||
let greeting: string; | ||
|
||
// Greetings | ||
let theStringMin: string; | ||
if (theMin < 10) { | ||
theStringMin = '0' + theMin; | ||
} else { | ||
theStringMin = theMin.toString(); | ||
} | ||
let category = greet(); | ||
console.log(category); | ||
|
||
if (theHour >= 0 && theHour < 4) { | ||
if (theHour == 0) { | ||
greeting = `Wow it's 12:${theMin} in the morning... you're up late.`; | ||
} else { | ||
greeting = `Wow it's ${theHour}:${theStringMin} in the morning... you're up late.`; | ||
} | ||
} else if (theHour >= 4 && theHour < 12) { | ||
greeting = "Good Morning!"; | ||
} else if (theHour >= 12 && theHour < 15) { | ||
greeting = "Good Afternoon!"; | ||
if (category === "m") { | ||
greeting = "Good Morning!"; | ||
} else if (category === "a") { | ||
greeting = "Good Afternoon!"; | ||
} else if (category === "e") { | ||
greeting = "Good Evening!"; | ||
} else { | ||
greeting = "Good Evening!"; | ||
greeting = "You're up late!"; | ||
} | ||
|
||
export {greeting}; | ||
export { greeting }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters