diff --git a/armand.json b/armand.json new file mode 100644 index 0000000..eb5dc0c --- /dev/null +++ b/armand.json @@ -0,0 +1,111 @@ +[ + { "character": 0, "text": "hey, are you up?" }, + + { "character": 1, "text": "It's like lunchtime here lol" }, + + { "character": 0, "text": "i'll take that as a yes then" }, + { "character": 0, "text": "good because i'm spiralling" }, + + { "character": 1, "text": "What's up?" }, + + { "character": 0, "text": "it feels like there's this thing in my head, right" }, + { "character": 0, "text": "this golden, wonderful thing that's capable of such wonderful things" }, + { "character": 0, "text": "but it's timid - so timid! - and always in flux" }, + { "character": 0, "text": "i try to approach it and it hides" }, + { "character": 0, "text": "every time i tihnk i'vve got a hold on it, it changes into something else" }, + { "character": 0, "text": "like i see my goal and it's not that far away, but then i get over to it and it turns out it's actually a bridge, or a tunnel" }, + { "character": 0, "text": "and now i have to go through that instead" }, + { "character": 0, "text": "it never ends!" }, + + { "character": 1, "text": "That sounds like, the archetypical Journey of Creative Self-Discovery, friend" }, + { "character": 1, "text": "Get new material" }, + + { "character": 0, "text": ">:|" }, + { "character": 0, "text": "it's frustrating" }, + { "character": 0, "text": "i'm frustrated" }, + + { "character": 1, "text": "Maybe you need a change of scenery" }, + { "character": 1, "text": "Have you tried going for a walk?" }, + + { "character": 0, "text": "i immediately regret messaging you" }, + { "character": 0, "text": "i don't know what i expected" }, + { "character": 0, "text": "i just wanted to vent a bit i guess" }, + + { "character": 1, "text": "Hey, you vent away" }, + { "character": 1, "text": "I'm not in any rush" }, + + { "character": 0, "text": "like, i see people with these honed skills, right" }, + { "character": 0, "text": "artists online, musicians, authors, whatever" }, + { "character": 0, "text": "and i love all of these things" }, + { "character": 0, "text": "and i know that honing a skill takes time, too" }, + { "character": 0, "text": "i am more than aware of that" }, + { "character": 0, "text": "but i feel like you kind of have to pick one, and run with it?" }, + { "character": 0, "text": "specialise, you know?" }, + { "character": 0, "text": "and my specialty is plants" }, + + { "character": 1, "text": "You like plants" }, + + { "character": 0, "text": "yeah i do like plants" }, + { "character": 0, "text": "plants are great" }, + { "character": 0, "text": "but plants aren't music" }, + { "character": 0, "text": "they're not a novel, or a poignant game or something" }, + { "character": 0, "text": "they're creative, but only in the abstract way that, like, running is creative" }, + { "character": 0, "text": "the kind of trophy-for-taking-part creative" }, + { "character": 0, "text": "maybe" }, + { "character": 0, "text": "idk" }, + { "character": 0, "text": "maybe i'm imposter syndroming myself" }, + { "character": 0, "text": "but i want to make those \"real\" creative things too" }, + { "character": 0, "text": "and i am frustrated because i feel like i can't pick" }, + { "character": 0, "text": "i can't specialise" }, + { "character": 0, "text": "i love all of them, how could i focus on writing at the cost of anything visual?" }, + { "character": 0, "text": "there's so precious little time to use on any of these things" }, + { "character": 0, "text": "and i feel like i waste that time trying to pick something, instead of actually doing anything" }, + + { "character": 1, "text": "I don't think you want to be a writer" }, + { "character": 1, "text": "I don't think you want to be a musician either" }, + { "character": 1, "text": "You're definitely a creative, though" }, + { "character": 1, "text": "Non-creatives are never this difficult" }, + { "character": 1, "text": "Look, if you want to write, write, if you want to draw, draw" }, + { "character": 1, "text": "You don't have to pick one!" }, + { "character": 1, "text": "You don't have to define yourself by that label, or use it at all" }, + { "character": 1, "text": "If you'll indulge a little anecdote" }, + + { "character": 0, "text": "please" }, + + { "character": 1, "text": "You remember when I lived in Madrid?" }, + { "character": 1, "text": "for a year I agonised over whether I was fluent enough" }, + { "character": 1, "text": "I had a social life, studied the culture, explored the country and stuff all in Spanish, but always just reckoned nah, I got lucky, or the locals were being kind with my fumbled locution" }, + { "character": 1, "text": "In my head I was (and honestly, still am) a total beginner" }, + { "character": 1, "text": "It was only when I was on the way back home I got to talking to some guy in a bar, and somehow got onto languages" }, + { "character": 1, "text": "He only spoke English himself, but he asked me: can you have a conversation? Can you make friends? Can you help someone who's lost?" }, + { "character": 1, "text": "And I figured well, yeah" }, + { "character": 1, "text": "By those measures, I'm fluent" }, + { "character": 1, "text": "I don't know what CEFR level I am, but also, I don't really care?" }, + { "character": 1, "text": "It's not like someone's going to check my credentials before engaging in conversation" }, + { "character": 1, "text": "Sorry it was a bit wandering but I think my point is basically that it's about what you do, not what you are" }, + { "character": 1, "text": "Or what you think you are" }, + { "character": 1, "text": "We are defined by our actions" }, + { "character": 1, "text": "What you think you are, or even what someone else thinks you are, doesn't really matter at all" }, + { "character": 1, "text": "Labels and nouns are useful to get ideas across, but they're not real, right?" }, + { "character": 1, "text": "So don't try to force them upon things which are" }, + + { "character": 0, "text": "<3" }, + { "character": 0, "text": "thanks" }, + { "character": 0, "text": "thanks for getting me out of my head" }, + + { "character": 1, "text": "No problem Rye" }, + { "character": 1, "text": "You take care up there" }, + + { "character": 0, "text": "i will" }, + { "character": 0, "text": "hey, could you do me a favour?" }, + + { "character": 1, "text": "If it's not insane" }, + + { "character": 0, "text": "next time you see a tree" }, + { "character": 0, "text": "send me a picture?" }, + { "character": 0, "text": "i miss trees" }, + + { "character": 1, "text": "I'll grab one on my walk home" }, + + { "character": 0, "text": "xoxo" } +] diff --git a/armand.txt b/armand.txt new file mode 100644 index 0000000..ea19b28 --- /dev/null +++ b/armand.txt @@ -0,0 +1,109 @@ +hey, are you up? + +It's like lunchtime here lol + +i'll take that as a yes then +good because i'm spiralling + +What's up? + +it feels like there's this thing in my head, right +this golden, wonderful thing that's capable of such wonderful things +but it's timid - so timid! - and always in flux +i try to approach it and it hides +every time i tihnk i'vve got a hold on it, it changes into something else +like i see my goal and it's not that far away, but then i get over to it and it turns out it's actually a bridge, or a tunnel +and now i have to go through that instead +it never ends! + +That sounds like, the archetypical Journey of Creative Self-Discovery, friend +Get new material + +>:| +it's frustrating +i'm frustrated + +Maybe you need a change of scenery +Have you tried going for a walk? + +i immediately regret messaging you +i don't know what i expected +i just wanted to vent a bit i guess + +Hey, you vent away +I'm not in any rush + +like, i see people with these honed skills, right +artists online, musicians, authors, whatever +and i love all of these things +and i know that honing a skill takes time, too +i am more than aware of that +but i feel like you kind of have to pick one, and run with it? +specialise, you know? +and my specialty is plants + +You like plants + +yeah i do like plants +plants are great +but plants aren't music +they're not a novel, or a poignant game or something +they're creative, but only in the abstract way that, like, running is creative +the kind of trophy-for-taking-part creative +maybe +idk +maybe i'm imposter syndroming myself +but i want to make those "real" creative things too +and i am frustrated because i feel like i can't pick +i can't specialise +i love all of them, how could i focus on writing at the cost of anything visual? +there's so precious little time to use on any of these things +and i feel like i waste that time trying to pick something, instead of actually doing anything + +I don't think you want to be a writer +I don't think you want to be a musician either +You're definitely a creative, though +Non-creatives are never this difficult +Look, if you want to write, write, if you want to draw, draw +You don't have to pick one! +You don't have to define yourself by that label, or use it at all +If you'll indulge a little anecdote + +please + +When I lived in Madrid for a year I agonised over whether I was fluent enough +I had a social life, studied the culture, explored the country and stuff all in Spanish, but always just reckoned nah, I got lucky, or the locals were being kind with my fumbled locution +In my head I was (and honestly, still am) a total beginner +It was only when I was on the way back home I got to talking to some guy in a bar, and somehow got onto languages +He only spoke English himself, but he asked me: can you have a conversation? Can you make friends? Can you help someone who's lost? +And I figured well, yeah +By those measures, I'm fluent +I don't know what CEFR level I am, but also, I don't really care? +It's not like someone's going to check my credentials before engaging in conversation +Sorry it was a bit wandering but I think my point is basically that it's about what you do, not what you are +Or what you think you are +We are defined by our actions +What you think you are, or even what someone else thinks you are, doesn't really matter at all +Labels and nouns are useful to get ideas across, but they're not real, right? +So don't try to force them upon things which are + +<3 +thanks +thanks for getting me out of my head + +No problem Rye +You take care up there + +i will +hey, could you do me a favour? + +If it's not insane + +next time you see a tree +send me a picture? +i miss trees + +I'll grab one on my walk home + +xoxo + diff --git a/main.js b/main.js index 73d9e37..989ae20 100644 --- a/main.js +++ b/main.js @@ -17,15 +17,25 @@ class Conversation { } start() { - setTimeout(() => { - this.messageIdx = 0; - this.pings = 1; + const firstMessage = this.messageData[0]; + if (this.isMessageDataOurs(firstMessage)) { + setTypingIndicator(false); - const data = this.messageData[this.messageIdx]; - const message = new ReceivedMessage(data); - this.messages.push(message); - this.onMessageReceived(message); - }, 3623); + console.log("first message is ours!"); + updatePreview(); + + } else { + setTypingIndicator(true); + setTimeout(() => { + this.messageIdx = 0; + this.pings = 1; + + const data = this.messageData[this.messageIdx]; + const message = new ReceivedMessage(data); + this.messages.push(message); + this.onMessageReceived(message); + }, 3623); + } } peekNextMessageData() { @@ -222,6 +232,7 @@ class SentMessage { } getHtml() { + // TODO: generate this with DOM methods instead of string templating return `
  • @@ -231,6 +242,9 @@ class SentMessage { setProgress(amount) { let thisMessage = getMessageElement(this.idx); + if (!thisMessage) + return; + let progressBar = thisMessage.getElementsByClassName("progress")[0]; if (amount < 0.5) { @@ -262,6 +276,9 @@ class SentMessage { updateStatus(newStatus, color) { let thisMessage = getMessageElement(this.idx); let statusElement = thisMessage.getElementsByClassName("message-status")[0]; + if (!statusElement) + return; + statusElement.innerHTML = newStatus; statusElement.style.color = color; } @@ -310,10 +327,17 @@ function getRandomDelay(min, max) { return min + Math.random() * range; } -function updateChat(message) { - addMessage(message); +function updatePreview() { + if (!conversation) + return; + const previewText = conversation.getTypedMessageText(); document.getElementById("textbox-input").value = previewText; +} + +function updateChat(message) { + addMessage(message); + updatePreview(); updatePings(); } @@ -344,6 +368,20 @@ function onMessageSent(message) { updateChat(message); } +function clearMessages() { + // TODO: clear using DOM methods instead of just dumping innerHTML + getMessageList().innerHTML = ""; +} + +function loadConversation(filename) { + clearMessages(); + updatePreview(""); + + fetch(filename) + .then(response => response.json()) + .then(json => init(json)); +} + function init(messageData) { conversation = new Conversation(messageData, "Hester Gomez", onMessageReceived, onMessageSent); conversation.start(); @@ -354,6 +392,8 @@ function init(messageData) { startLightLagUpdateLoop(); } -fetch("hester.json") - .then(response => response.json()) - .then(json => init(json)); +// TODO: add other person's name to conversation data +// TODO: add base light delay to converastion data +// TODO: kill any messages that are about to be sent + +loadConversation("armand.json");