{"id":359,"date":"2015-04-20T15:21:36","date_gmt":"2015-04-20T19:21:36","guid":{"rendered":"http:\/\/www.lektrikpuke.com\/blog\/?p=359"},"modified":"2015-05-12T09:04:10","modified_gmt":"2015-05-12T13:04:10","slug":"having-conversations-with-javascript","status":"publish","type":"post","link":"https:\/\/lektrikpuke.com\/blog\/2015\/04\/20\/having-conversations-with-javascript\/","title":{"rendered":"Having Conversations With Javascript"},"content":{"rendered":"<p>Have you ever wanted wanted to animate inanimate objects?  I think we all have.  Well, that&#8217;s a lot of work.  A cheat that you can employ, however, is relatively easy with javascript and or jquery.  No, I&#8217;m not talking about jquery&#8217;s animate function, which moves an image across the screen a certain distance on an event.  To be sure, that could be used additionally.  Btw, that&#8217;s one of the ways that I played with to animate Chuckman flying (similar to what you see at the top of this blog).  <\/p>\n<p>Maybe I should define what I mean by animation?  In this instance, I am talking about the illusion of a conversation taking place between two snails.  To better understand, <a href=\"http:\/\/www.lektrikpuke.com\/additional-pages\/snailsInTheRain.php\" target=\"_blank\">click here<\/a>.  The default conversation that displays at that link can be changed.  <a href=\"http:\/\/www.lektrikpuke.com\/\/additional-pages\/snailsInTheRain.php?converse=dImg^im1^dTxt^This%20is%20a%20completely%20different%20conversation.^dImg^im2^dTxt^Yeah,%20but%20what%20does%20that%20mean%20to%20me?^dImg^im1^dTxt^That%20means%20you%20can%20make%20the%20snails%20say%20anything%20you%20want.^dImg^im2^dTxt^Oh,%20okay.^dImg^^dTxt^\" target=\"_blank\">Click here<\/a> to see a different conversation, or <a href=\"http:\/\/www.lektrikpuke.com\/additional-pages\/snailsInTheRain.php?converse=dImg^im1^dTxt^But%20how%20does%20this%20work,%20I%20wonder?^dImg^im2^dTxt^Well,%20the%20conversation%20is%20actually%20passed%20in%20via%20the%20link.^dImg^im1^dTxt^Really?^dImg^im2^dTxt^Yeah,%20just%20look%20at%20how%20long%20the%20link%20to%20this%20page%20is%20and%20you%27ll%20see.^dImg^^dTxt^\" target=\"_blank\">click here<\/a> for yet another.<\/p>\n<p>If you examine the links, you should observe a pattern.  First, you need the base url.  In this case that&#8217;s lektrikpuke.com\/additional-pages\/snailsInTheRain.php.  That needs to be followed by ?converse=.  Then enter a command separated by a ^ from the parameter to be passed in.  That&#8217;s pretty much it.  Note:  This script as yet is not bullet proof, meaning you can make it fail miserably.  As this was just a fun project for me I may continue working on it, but no promises.<\/p>\n<p>Commands that are currently present:<\/p>\n<ul>\n<li>dImg &#8211; short for display image<\/li>\n<li>dTxt &#8211; short for display text<\/li>\n<\/ul>\n<p>Images available:<\/p>\n<ul>\n<li>im1 &#8211; short for image one, which is the bubble that appears to issue forth from the left snail<\/li>\n<li>im2 &#8211; short for image two, which is the bubble that appears to issue forth from the right snail<\/li>\n<li>im3 &#8211; short for image three (the background image, calling this is a fun way to show the fragility of the script)<\/li>\n<\/ul>\n<p>Format for use is command^parameter^command^parameter, etc., so dImg^im1^dTxt^Say something<\/p>\n<p>In the above example we call the function dImg and pass it im1 (dImg(im1)) which overlays the bubble on the base image.  We then call dTxt and pass it &#8216;Say something&#8217; which prints &#8216;Say something&#8217; over the bubble.  Note:  Don&#8217;t worry about the %20&#8217;s if you&#8217;re looking at the link.  Percent 20 (and the likes) is just a web browser&#8217;s way of keeping spaces out of a url (link).  Your link will work with spaces, and if you copy and paste it somewhere, you may find that %20&#8217;s mysteriously showed up on their own.<\/p>\n<p>The script is commented, so if you want to see the inner workings, just look at the page source.<\/p>\n<p>Things on my to do list include:<\/p>\n<ul>\n<li>add a dynamically generated form for image\/text addition<\/li>\n<li>add character limit to conversation blurbs<\/li>\n<li>add parsing and overriding of timing<\/li>\n<li>add start\/stop<\/li>\n<li>maybe add navigation\/image jumping<\/li>\n<\/ul>\n<p>Have fun talking to yourself, I mean making the snails talk.  =)<\/p>\n<p>Note:  It should be obvious that different functions could be written in the same way, allowing for instance, sound files to be played in conjunction with the images.  Very interesting!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted wanted to animate inanimate objects? I think we all have. Well, that&#8217;s a lot of work. A cheat that you can employ, however, is relatively easy with javascript and or jquery. No, I&#8217;m not talking about &hellip; <a href=\"https:\/\/lektrikpuke.com\/blog\/2015\/04\/20\/having-conversations-with-javascript\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[171],"tags":[180,173,166,89],"class_list":["post-359","post","type-post","status-publish","format-standard","hentry","category-jquery-computer-stuff","tag-animation","tag-javascript","tag-jquery","tag-script"],"_links":{"self":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts\/359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/comments?post=359"}],"version-history":[{"count":5,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts\/359\/revisions"}],"predecessor-version":[{"id":368,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts\/359\/revisions\/368"}],"wp:attachment":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/media?parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/categories?post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/tags?post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}