to do app in html5

Posted by on February 26th, 2018  •  1 Comment  •  Full Article

I spent a full day trying to debug an indexedDB JavaScript lesson. It would work on my iPhone, and on codepen, but nowhere else. It wouldn’t  work at all on my MacBook, except for codepen.com. I knew my code was clean because typing errors are always the first thing I check. And the way it was behaving, I could tell it was some kind of security blockage either on the hosting servers or in the browsers.

While searching for an answer I came across another free online tutorial, and this one worked. I don’t know why it worked because it was structured much the same, though with subtle differences. Anyway I was able to combine stuff I’d learned in both tutorials to make a pretty sweet little  pure  HTML5 and vanilla JavaScript  note taking app.

Once I had it running I realized it was missing the drag and drop functionality I’ve come to expect in apps like wunderlist. After a quick google search, I found a tutorial that built a drag and drop list. Sadly, that one has a problem on mobile devices. You can drag the list items on a computer, but not on a phone. Phones have a different set of responses and the  eventListeners are set up completely different from computers.

But more searching led me to this cool tutorial page with links out to the slip.js library.

And finally I had a very nice little “todo” note taker app. It’s still not hooked up to a database…that may be coming. But it’s actually quite useable. There are 400 lines of code, not counting the slip javascript library. I prettied it up with some style sheets, and tried to make it mobile friendly.

It’s tricky to embed it in WordPress. There are conflicts with classes and ID’s. So instead, here is a direct link on my server.. It remembers your list items as long as you don’t clear your browsers cache. It does not sync with your computer though… You need wunderlist for that.

Just for practice, I’ve also posted it up on codepen so that you can tinker with it, if you should so desire.

There are two js files that run it. This is the one that hooks it up to the indexedDB database.

And here is the one where I did quite a bit of customization, you can see the drag and drop “slip” references at the bottom.

The style sheet got fairly long  because…well…I’m sort of artsy and I wanted it to be pretty.

 

HTML5 To Do shopping list app

Posted by on February 22nd, 2018  •  0 Comments  •  Full Article

I’ve been using both Evernote and Wunderlist for years. I’ve built a ToDo list before in jQuery that came close to Wunderlist. It had draggable list items, and delete item checkboxes. But when studying JavaScript, jQuery is considered cheating.

So I was pleased to see this one show up in my latest online lesson. I prettied it up with some style sheets. I’m waiting until later in my studies to figure out how to connect it to a database, hopefully with something like Node.js. For now though, it just works in the browser session memory. It’s cool to make useful things that actually work. This one embedded in WordPress has some extra padding related to WordPress styles, but the direct link outside of WordPress works as intended.

Shopping list


You can also access it here as a direct link outside of WordPress.

Custom HTML5 video player controls

Posted by on February 22nd, 2018  •  0 Comments  •  Full Article

We had an inch of snow today. I took a brisk walk around the block on the sunny, but slippery sidewalks before getting back to work programming.

Yesterday our exercise was to remove the default html5 video player controls, then substitute a handbuilt controller. As an added challenge, they asked if we could program in a clickable playhead. They gave us a couple clues, but thinking it through was a  brain squeezer. There was a 190 pixel wide area where the progress bar walked across as the video played.

Somehow that area needed to become clickable. When clicked, the video should play at that percentage. Meaning, if you click half way across the progress bar area, the video should jump to the halfway point.

I can’t post the video here in WordPress without a lot of trouble from width properties. So instead I’m linking to it here as an external page. But the code is shown below. The magic in the  clickable progress bar is on line 157: function jumpTo(e){…}

My solution isn’t a true draggable playhead, but it does at least navigate, and displays a nice red bar when clicked.

 

Rotate in 3D with JavaScript

Posted by on February 21st, 2018  •  0 Comments  •  Full Article

I’m taking online classes in Javascript for a few months while I’m between contracts. I learned how to animate a cube in 3 dimensions today. It uses a library called three.js. As with Jquery libraries, we plug them in (three.js) to make things easier.

I wrote these 50 lines of code that makes it work. It’s a fun lesson, but the full credit needs to go developer.mozilla.org. A lot of that stuff makes no sense to me. I gotta be honest…some of these lessons are so far above my head I wonder sometimes if I’m totally wasting my time learning this stuff. I mean these people are geniuses, probably with masters degrees in computer science. I can write their code and make the lesson work…but full understanding would only come with doing it full time.

 

In other news, I removed my woocomerce store and shopping cart. I had zero sales from it, and it was always worrisome that I would have a purchase while I wasn’t paying attention…which could lead to an unhappy customer. I’m thinking I might try etsy at some point as some artists are selling there.

Selling my paintings is very low on my priority list right now. I think of myself as being in college full-time. I’m hitting the books every weekday, 9 to 5. The only unusual thing is that I’m not enrolled anywhere. I’m doing self study. This stuff is all free online…no need to pay a teacher. Hmmm, that might be a contributing factor to why I’m not working this quarter as a teacher. Go figure.

Christmas at Joshua Tree 2017

Posted by on February 18th, 2018  •  0 Comments  •  Full Article

I can’t spare the time to write the story of my trip this year. But it was awesome, perhaps the best jtree trip in 9 years. Good climbing trips are all about finding a good partner.

Clouds high above Vitaliy on Sexy Grandma

Clouds high above Vitaliy on Sexy Grandma

~

Vitaliy

Vitaliy on Papa Woolsey

~

me on bambi and godzilla

me on bambi and godzilla

~

Me leading Fisticuffs, 10b

Me leading Fisticuffs, 10b

~

Vitaliy following Fisticuffs

Vitaliy following Fisticuffs

~

Night photography

~

Micah following The Watershute 10B

~

Vitaliy on Orphan

~

Craig following The Watershute

~

Me leading The Watershute. First bolt is 20 feet up. It’s a scary lead but the stemming feels secure to get there.

~

Vitaliy following my hangdog lead of Heart of Darkness, 5.11

~

Rapping off Strawberry Jam outhouse rock

~

Me and some awesome friends

~

New Years eve

~

New Years eve

~

~

~

~

~

~

Doubles Ping Pong

Posted by on February 16th, 2018  •  0 Comments  •  Full Article

ping pong Alex brother

I grew up with a ping pong table in dad’s basement. Three years ago Marty and I played pong on a climbing trip at Squamish and fell in love with the game again. We were having as much fun playing pong in the evenings as we did climbing during the day. We would trash talk each other’s climbing abilities with promises of revenge at the table after dinner.

And then the battles for superiority, man that game is fun! When I returned from that climbing trip I built a table from some scrap plywood and have it in our spare bedroom. Sue and I play when we can. This is a picture of a  friend who came over to play. So when I heard that our new community center had ping pong twice a week I decided it would be nice break from studying and a good way to get some exercise.

When I walked in I was a little alarmed to see people my age, and older. One woman was 73, and one of the guys has a stiff back.  But I try to never judge a book by it’s cover and was soon batting the ball around. They specialize in doubles in this gym, which I have rarely played. That first day, I ran over my partner going for a ball and knocked her to the ground. Everyone looked shocked, as if I’d committed a horrible sin. I felt terrible and apologized of course, though in my sports: climbing, skiing, hiking,  windsurfing, volleyball, falls are normal.

She got up slowly and kept playing, saying she was well padded. But I could see my first day with these people had got off to a bad start. Despite being seniors, several of them are a lot better than me. They have wicked serves and slams that rarely miss. Some of them are really good!

In doubles, you only hit every other ball. So if your partner is serving, you stand back. As soon as  the ball goes over the net, the table is yours. You hit the returning ball and dash out of the way. Your partner hits the next one while you stand behind them…or at least out of their way. Then it all repeats.

Often, because you are behind your partner when they are hitting the ball, you have no idea what has happened. Your partner hits, then circles around behind you while you assess the situation: where is the ball, and where is it headed…assuming the other side has managed to hit it back. It requires intense concentration to be in the right place to return the ball, while simultaneously avoiding colliding  with your partner, who is hovering nearby, getting ready to return to play.

I’d liken doubles table tennis (it’s official name) to a dance. When it’s done well for several rallies there is a beauty that builds up…a sense that magic is happening and we all try to keep it going for as long as possible. I know it all sounds a bit stupid, batting a little white plastic ball around a table. But after a couple hours I’m sweating and wishing I’d worn shorts and a tank top, in February.

Bouncing ball with collision detection

Posted by on February 14th, 2018  •  0 Comments  •  Full Article

Self Portrait 1989 charcoal and white conte crayon

The drawing above is a self portrait done so long ago I can’t even remember the year. I have dark hair, so it was probably during my twenties or thirties.

I used to program games in flash that had rockets flying in space. They had motors that fired, directional thrusters, variable velocity, collision detection, gravity, friction and bounce. But flash is dead…or at least it doesn’t work on phones, and I like to make things that work on phones.

Now I’ve just finished another excellent lesson at https://developer.mozilla.org It was an applied application of OOP as it is used in JavaScript. It didn’t make a rocket, but it did make a bunch of balls that change colors when they collide. I added in a drop list that lets you change the number of balls. I got it to show up here in wordpress via the shortcoder plugin.

Here is the code if you are curious: https://codepen.io/markhwebster/pen/VQzyJM

Programmed a working calendar for journal

Posted by on February 12th, 2018  •  0 Comments  •  Full Article

On February 3 I posted the working example from a calendar lesson I had learned in JavaScript. All it did was generate months of the year with the correct number of days, depending on which month you selected. It was dumb but it got me thinking.

As I moved forward in my JavaScript studies I was mulling over a way to make use of that calendar. To the right of this story you will see two calendars. The top one is a free WordPress plugin. I didn’t build it, I just installed the plugin.  It lets you switch between journal entries going back to 2011 when I first started using WordPress. All the post entry links are automatically populated from the WordPress database.

But I was keeping an online journal long before they invented WordPress. I have been writing since late 1997,  a year after I got my first computer. There was a story that year in the Seattle times about a woman who was keeping an online journal. She started it in ’97, and it inspired me to do the same. But as my journal grew it was difficult to build a navigation system back through the entries. I’ve struggled with a number of solutions, as you will see if you prowl around.

The one I used the longest was a flash calendar that I built from scratch. But even I refuse to download flash anymore. So if I was on a smartphone,  I couldn’t navigate my own journal until just recently.

My solution? Build a real working calendar in Javascript and embed it on every page , or at least the pages starting at September 2001, which is when I changed the interface drastically. To get it to work I had to create a JavaScript array for every year, about 10 of them.

As you can see to the right, I also embedded that new JavaScript calendar right here in WordPress below the plug in calendar. I got it to appear by using a WordPress plugin called shortcoder. The shortcoder plugin presents itself as a box in which you can paste html, css and js. Then it gives you a short little snippet of code, called a shortcode. That shortcode references the longer code. I pasted the shortcode snippet into a standard text widget, and dropped the widget into my WordPress sidebar.

You can see it all working here. It’s not search engine friendly yet…I have to think about that. I’ve linked to the contents (hand built index of the journal) page. It has links out to most of the good writing, perhaps that will negate the fact that a dynamically generated calendar can’t be spidered by google.

I’m fairly happy with this solution. It’s not perfect, I think Jessamyn does a better job of archiving, but at least mine was a fun way to practice my JavaScript.

Here is the array for the year 2000. Note that I didn’t start writing until March of 1999, or, at least that is the first named file: three99.html

Next I modified the simpler calendar function from a week ago so that it dynamically generated the months for the selected year, complete with clickable links for each month. But there was a problem. If you selected say, April of 2004, when you got there, the calendar did not display. You had to choose a year again. This was bad usability. I wanted the calendar to always display all the months of the year you were reading, no matter which month you were reading. But that meant getting the pages to talk to each other. The technical term is: passing data between html pages. I had a vague idea that it might be doable with cookies, but I’ve never baked cookies.

Google to the rescue! I discovered there is a way to store and pass variables between pages that have JavaScript. It’s called localStorage. You can write to it, and pull data from it. As long as they are on a long session on your website, you can make your html pages pass data from page to page.

The first line below listens for you to make a choice from the drop list. If you do ‘change’ it, the script fires off the ‘createYear‘ function.

That function puts the year you chose into a variable called ‘choice‘. At the same time, it places that year into session memory via the localStorage.setItem command. This is like registering at a hotel and telling the concierge that you would like the Seattle Times news paper each time you walk in. He remembers your preference during your session at the hotel…all week long.

As you surf from month to month, the concierge (localStorage data) remembers your year preference and keeps that year’s calendar visible

Next I do a couple checks to see whether this is your second journal month choice, or if you just arrived and haven’t made any previous choices. If the latter, I present the first years calendar, which is 1999.

Further down I have a switch-case conditional that fires off the correct createMonths function for the year you selected.

In other news, Sue and I skied at Paradise yesterday. This was only her second trip of the year. She is still babying her rotator cuff surgery. It was a nice one inch covering of powder over a hard base. It wasn’t  grabby, and was lovely skiing, not counting the water runnels, which were as bad as moguls in spots. I went back up for another run, but the fog had settled in, masking the earlier bright blue sky. I turned around before Pan, and finished out the day.

Today I bought a $15 bouquet but discovered I’ve forgotten how to draw. Jeez! I’ve been so lost in programming I’ve not only forgotten how to climb, I can’t draw either. How come I can’t be good at everything? It would be so handy. Perhaps when I get a full time job again and get settled in I can get back to my hobbies. I miss them.

To keep from going crazy with all this studying I’ve been exercising every day and playing a fair amount of ping pong. Last week I played at the local community center with a bunch of seniors. We played doubles, which involves a very intricate dance around the end of the table. You have to hit the ball, but only every other time. This means you hit the ball, then run backwards to get out of the way so your partner can hit it…and repeat. It was so much fun I went to another public game out on 76th.

This was a beast of a different color. They were people of all ages, and they were serious, with a capital S! They literally wiped the floor with me. I lost.every.single.game. That’s nine games in a row, but who is counting? I walked out after an hour. I mean, what was the point? I love the game, but I don’t have the time to develop that kind of skill. I am already neglecting too many hobbies, don’t need to add ping pong to the list. I won’t stop playing, but I will avoid playing with people who live and breath the game.

OOP studies and a sold painting

Posted by on February 8th, 2018  •  0 Comments  •  Full Article

Crooked River Smith Rocks

Crooked River Smith Rocks SOLD

I spent today working through my first Object Oriented Programming exercise in JavaScript. Actually, I spent 2 hours of the day framing a painting for a climbing friend. We met at Jtree, and she came to the house and fell in love with this painting. She picked it up today, and I went back to programming. The code below will only work if it’s in  a script tag embedded in the <body> element. Then you go to the developer tool console of the browser. Finally, you type person1.bio() and press enter.

It will trigger an alert box that says: “Bob Wayno is 35 years old. He likes music, knitting, skiing, climbing, painting, inventing, and sewing. Shoe size is: 15 and their favorite color is orange.” OOP programming is a stepping stone towards some of the higher end languages I plan to pursue, such as React, AngularJS and Node.js.

If this sounds like a bunch of geek speak move on to the next blog entry. I posted it here because I want to be able to search for it later, and read the code with syntax highlighting. I’m building up some code libraries of my own to refer back to.

 

Vantage and an image gallery

Posted by on February 6th, 2018  •  0 Comments  •  Full Article

I studied Sunday so I could play hooky with Christine on Monday at Vantage. Chris was super strong and led Sinsemilla 10c and George and Martha cleanly.  I was very rusty after 6 weeks of not climbing. I can’t afford the climbing gym so my arms have become weak. As I said after lowering down from hanging on Pony Keg: “That was not the climber who came back from Joshua Tree on January 2!”

Chris: “I know, I wanted to meet that guy.”

Me: “He is gone, and I wonder if he ever really existed. Perhaps that was just a fairytale from some bizarre alternate universe.”

Such is my life as a 64 year old rock climber. It’s a sport for young people. Trying to do it at my advanced age of decrepitude requires a lot more work than it does for young people. I do the work, and happily, but it requires climbing every weekend, or 5 days straight, whichever comes first.

So now I’m back to my JavaScript studies at this super cool free website:

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Image_gallery

I’ve been using Evernote to take notes of the stuff I’m learning. But Evernote doesn’t have syntax highlighting. It’s going to clog up this blog with a bunch of code…but I suspect this blog never gets read by anyone but me anyway. Probably I screwed up the search engine functionality or something. Not that I care enough to sort it out. I have bigger priorities, like learning high end JavaScript.

So here is my latest “homework”. I built a barebones image gallery switcher. It’s too boring to show the working example in an iframe. But this is the code that makes it work, which is the fun part for me. On my main website, I use a awesome image gallery function called Photoswipe. You can see it here.

Whoever built that had the job that I want.

Meanwhile, back on the farm, this is the code for the one I built in my lesson. They gave me the images, html and JavaScript. But they only gave me clues as to how to write the script. I’m fairly happy I figured it all out. Baby steps…

Here is the html:

And here is the script that I wrote: