Skip to content

Instantly share code, notes, and snippets.

View JCJang's full-sized avatar

Jennifer Jang JCJang

View GitHub Profile
//using authorInfluences as an example:
const [authorInfluenced, setAuthorInfluenced] = useState([])
const [authorInfluencedBooks, setAuthorInfluencedBooks] = useState([])
const openLinkedShelf = (shelfAndBook) =>{
setBookNumber(shelfAndBook.book[0].bookNumber)
setShelfId(shelfAndBook.shelfId)
setColumnFocus('shelfpanel')
}
//for each author, scan their 'influenced' list for the opened author
app.post("/influences", async(req,res)=>{
const languageSetting = req.body.languageSetting
const authorToFind = req.body.authorWikiTitle
AuthorModel.find({"editions.language":languageSetting, "authorInfluenced":authorToFind},{"editions.details.authorWikiTitle":1,"_id":0}, (err,results)=>{
if(err){
res.send(err)
console.log(err)
}
//adding a new shelf
app.post("/shelf", async(req,res)=>{
const shelfTitle = req.body.shelfTitle
const shelfLanguage = req.body.shelfLanguage
const bookTitle= req.body.bookTitle
const earliestPublicationYear = req.body.earliestPublicationYear
...
{
"_id": ".....",
"shelfSubjects": [
"0 Ancient and Modern Languages",
"1 Literature",
"4 Anthropology",
"5 Human Geography"
],
"editions": [
{
@JCJang
JCJang / Customize Historical Timelines to Each Author
Last active October 11, 2021 17:11
Customize Historical Timelines to Each Author
//timeline object consists of simple key-value pairs, but some keys have dates while others do not.
//"Timeline of ..." : {"1990 May 2":"Event description for 1990 May 2", "1992" : "Event description for 1992"}
//get array of [year, key, value]
const getKeyValueArr = (obj)=>{
const keys = Object.keys(obj);
const values = Object.values(obj);
const keyValueArr=[]
//combining and referencing code from 'react-zoom-pan-pinch' by Maciej Pyrc, 'react-image-fade-in' by Patrick Tran, react portal tutorial by Kyle Cook (WebDevSimplified)
import ImageFadeIn from '../../../../../customHooks/imageFadeIn';
import React from 'react'
import ReactDom from 'react-dom'
import {TransformWrapper, TransformComponent} from "react-zoom-pan-pinch";
import {VscZoomIn as ZoomInIcon} from "react-icons/vsc";
import {VscZoomOut as ZoomOutIcon} from "react-icons/vsc";
import {IoResizeOutline as ResetIcon} from "react-icons/io5";
/* Headers: Rufina - English, Genwan - Chinese */
.h1{
@apply text-4xl tracking-wider font-medium;
font-family: "Rufina","Genwan";
}
/* Body Text: Roboto - English, Genseki - Chinese */
.body{
import i18n from './../../i18n.js'
import { useTranslation } from 'react-i18next'
import NavLink from './NavLink.js'
const Navbar = () => {
const {t, i18n} = useTranslation();
return (
<nav>
//translationZHTW.json
{
"Navbar":{
"trekinn":"《 美崙遊記 》",
"about":"簡介",
"destinations+map":"觀光指南及地圖",
"rooms":"訂房",
"contact":"聯絡資訊",
"changeTo":"English",