Skip to content

Instantly share code, notes, and snippets.

View thejungwon's full-sized avatar
🦄
Focusing

Jungwon Seo thejungwon

🦄
Focusing
View GitHub Profile
$('.interest').keypress(function(e) {
if(e.which == 13) {
var interest = e.target.value;
if(!interest) return;
newimage(interest);
if(!getCookie('picture')) return;
$('.interest').fadeOut(function(){
$('.greeting').html(`Hello ${username}.`);
$('.greeting').fadeIn(function(){
setCookie('interest', interest,365);
@thejungwon
thejungwon / index.html
Last active September 29, 2018 09:47
phase2
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="./style.css"/>
</head>
<body style="background-image:url(https://images.unsplash.com/photo-1520190282873-afe1285c9a2a);">
<div class="overlay">
<div class="top">
<div class="left">
var username = getCookie('username');
//check cookie
if(username){
$('.greeting').css('display','inline-block');
$('.user-name').css('display','none');
var interest = getCookie('interest');
if(interest){
$('.interest').css('display','none');
$('.interest-text').html(interest);
$('.interest').keypress(function(e) {
if(e.which == 13) {
var interest = e.target.value;
if(!interest) return;
newimage(interest);
if(!getCookie('picture')) return;
$('.interest').fadeOut(function(){
$('.greeting').html(`Hello ${username}.`);
$('.greeting').fadeIn(function(){
setCookie('interest', interest,365);
function newimage(keyword){
if(!ACCESS_KEY){
alert("Please update your access key");
return;
}
var url = `https://api.unsplash.com/search/photos?query=${keyword}&per_page=20&orientation=landscape&client_id=${ACCESS_KEY}`;
$.get(url,function(data){
var picture_url = data.results[0].urls.raw;
setCookie("picture",picture_url,0.5);
$('body').css('background-image',`url(${picture_url})`);
$('.greeting').html(`Hello <span class="stored-name">${username}</span>.`);
var picture_url = getCookie('picture');
if(!picture_url){
newimage(interest);
picture_url = getCookie('picture');
}
$('body').css('background-image',`url(${picture_url})`);
function newimage(keyword){
if(!ACCESS_KEY){
alert("Please update your access key");
return;
}
var url = `https://api.unsplash.com/search/photos?query=${keyword}&per_page=20&orientation=landscape&client_id=${ACCESS_KEY}`;
$.get(url,function(data){
var picture = data.results[0];
var picture_url = picture.urls.raw;
<div class="change-btn">
Choose a new interest
</div>
.change-btn{
position: absolute;
bottom: 20px;
font-size: 20px;
cursor:pointer;
display: none;
}
.change-btn:hover{
transition: all 0.5s ease-out;
text-decoration: underline;
@thejungwon
thejungwon / script.js
Last active September 30, 2018 12:50
$(document).ready(function(){
//current time
//update every 10 seconds;
setCurrentTime();
setInterval(function(){
setCurrentTime();
},10*1000);
var username = getCookie('username');
//check cookie