Dave's Notebook

Cross Browser JavaScript Copy and Paste

I’ve searched all over the Internet for a Cross Browser JavaScript Copy and Paste solution.  I couldn’t find anything that really worked.  But I was able to put together the bits and pieces I found into a rather simple solutions. As you may have noticed, I’ve written quite a few articles about programming in JavaScript in the past couple of years because I’ve spent most of my time programming in JavaScript.  For the last three months, I’ve been working on a browser based application that needed to be able to copy and paste between the browser and an external spreadsheet.  The main struggle in making this all work correct is that what needs to be copied to the clipboard is the underlying data of the application.

Getting this all working in IE, even the most recent version that runs under Windows 10, was pretty easy.  And fortunately, the browser of choice at this company is Internet Explorer.  But, it is IE 11, which takes twice as long to do anything with JavaScript as Chrome does.  Chrome is their secondary browser and my mission has been to find a way to get copy and paste working reliably using Chrome so that the end user would have a better experience with the application.

While the work I’ve been doing has been using Angular, the solution that I provide in this article using plain JavaScript with no dependency on any framework.  I want the solution to be available regardless of what framework you might be predisposed to use.  If you use angular, or jQuery, or whatever, the code should be easy enough to adapt.

image

Read More

Increase Your Excellence Capacity

Today I saw a GREEN traffic light for the first time.

OK, that’s not entirely true.  What I mean to say is that I saw that it was green.

You see, I was born color blind.  This never really bothered me because, like most people who are handicapped from birth, I didn’t know what I was missing.

But then, I found out that there is this company that sells glasses that help color blind people see color.  They are pretty expensive, at least they seem pretty expensive when you believe you don’t really have a big problem.  But then I took the standard color blind test on their site and found out

  1. I’m color blind (duh!)
  2. there is an 80% chance that the glasses would help and
  3. I only see 2% of the available color spectrum.

Wow! Only 2%?  I knew I had issues.  But I’ve been able to function.  But only 2%.  What am I missing?

Well, my wife got me a pair of glasses for Christmas.  Unfortunately, I ordered indoor/computer glasses and what they sent are sunglasses.  I’m still trying to get that resolved. Sad smile  But just for kicks, I wore the sunglasses out while I was running errands today.  This is the first sunny day that I haven’t been stuck inside since Christmas.  The reds are redder, the yellows are yellower and, hey! Guess what?!  The green light is actually green!

So, what’s this got to do with programming?  You did know this was going to eventually relate to programming right?

image

Read More

JavaScript Alchemy with Strings, Numbers, and Booleans.

Those who are relatively new to JavaScript might have the impression that JavaScript has no variable types.  After all, we declare everything using var and we can treat

1
if(1 == "1")

The same as

1
if(1 == 1)

or

1
if("1" == "1")

But the reality is that JavaScript includes a very rich typing system with some well-known, and some little know methods of detecting types and converting from one type to another.

image

Read More

Adventures Working With Angular’s $scope

Every week when I write, I try to think back on the past week and think, “What have I learned that might be useful to others.”  Most weeks that is a pretty easy question to answer because I get most of my pleasure from learning new stuff.  But this week was different.

When I sat down to write today, I couldn’t come up with a subject that couldn’t be covered with a sentence.  More of a tweet than a blog post.  It was so bad that I decided to go run the errands that are on my list and come back to it once I got home.

Evidently, that was a good move because I think I have something that will be genuinely useful.  Although I will admit that if you’ve been working with AngularJS for very long at all, you may have already learned what I’m about to explain.

image

Read More

How to be (Personally) Agile

When I first wrote down the idea for this post, I was originally thinking about how we might use agile development practices in a work place that practices Water Fall or worse.  But since then, I’ve expanded my thinking to include the concept of using agile everywhere, including where it “isn’t allowed.” Here’s what I’m talking about.  What does your work environment look like?  Many of the places I end up working either are using no formal process at all, or weakly attempt some form of Scrum or Water Fall.  In fact, my current major gig has a “project manager” (I use the term loosely) that manages our project with MS Project.  There is not even a formal issue tracking system.  And this is at a very LARGE organization that SHOULD know better.

image

Read More

JavaScript Crazy Talk - Are you guilty?

I heard this so frequently, I decided it is time to write about it.

(When writing web applications)  Business rules always belong on the server.

One of the last conversations I had at the last place I was working was on this same issue.  And, I had a similar reaction a couple of years ago when I was doing a Selenium testing presentation and mentioned that the organization I was currently working for put all of the code on the client side and that the only thing the server did was save the data.

Maybe you believe the same thing? Nothing is ever that cut and dry.

image

Read More

Multi-Threaded JavaScript - Not The Problem You Think

A couple of weeks ago, I posted 7 Reasons Every Programmer Needs to Learn JavaScript.  In the comments, Dean tried to refute my arguments first by claiming that my sources for JavaScript’s popularity were “a problem” because JavaScript is used in combination with other languages.  A point I refute in the comments.  But then he goes on to claim that “JavaScript is poorly suited for client side applications” because JavaScript is “Single Threaded”.  At this point, I just sighed and realized that Dean doesn’t want to learn JavaScript and that there MUST be some reason I’m not seeing for why he is so critical of JavaScript.

But then Brandon jumped in and offered a very clear defense of JavaScript on the server side.  Nearly making this post unnecessary.

And yet, there are things that were not said, and most people will never see the great comments that Brandon supplied.  And so we look at Multi-Threaded JavaScript in depth.

image

Read More