Category: Uncategorized

  • Using CSS and JavaScript to Randomize Background Images

    Using CSS and JavaScript to Randomize Background Images

    I was working on a website and wanted to add a fun bit of flair by having the background rotate through a batch of images. So every time the website loaded it would have a different image. I did a little research, but none of the solutions were all that great. So I coded up my solution. I needed to be able to:

    • Randomize the images on page load
    • Set the random image on the body
    • Set the image on a pseudo-element ::backdrop

    Solution 1 – JS sets the style

    This was the first solution I ran across. I merged the original problem, with the solution to save time. What I dislike about this solution is the separation of concerns, and it uses “var” still.

    <head>
    <style>...</style>
    <script type="text/javascript">
            var totalCount = 8;
            function ChangeIt() {
                var num = Math.ceil(Math.random() * totalCount);
                document.body.style.background = "url('assets/bgImages/" + num + ".jpg') repeat";
    
            }
        </script>
    </head>
    <body>...</body>
    
    </html>
    <script type="text/javascript">
        ChangeIt();
    </script>
    

    Stackoverflow solution 1

    Solution 2 – JS inserts a stylesheet

    This was the second solution I ran across. I started looking for this because I needed to add the random background to a pseudo-element – “::backdrop” for a dialog I was working on. Because you can’t directly access this pseudo-object from JS (at least I couldn’t see how) I tried to insert the stylesheet method. It was messy, and now I had two functions doing the “same thing”.

    document.styleSheets[0].insertRule('#elid:hover { background-color: red; }', 0);
    document.styleSheets[0].cssRules[0].style.backgroundColor= 'red';
    
    //IE solution...
    document.styleSheets[0].addRule('#elid:hover', 'background-color: red', 0);
    document.styleSheets[0].rules[0].style.backgroundColor= 'red';

    Stackoverflow Solution 2https://stackoverflow.com/a/311437

    One commenter pointed out security issues, and I hated how messy this was. SO MUCH CSS in JS… ?

    My solution – Set a class

    To keep the CSS and styling out of the JS, don’t cross the streams, I let JS change the classes and left the styling in CSS.

    This was a more elegant solution and allowed me to never edit the JS code if I wanted to switch images. This is a complete example with some “fixer” js to clear the classes off for the demo. Click around and have some fun.

    • Random <body> background-image
    • Random <div> background-image
    • Random <dialog> ::backdrop background-image

    With this code and some css animations, you can create some really fun effects for your site.

    See the Pen Random Background via class by Joel Cory (@Joel-Cory) on CodePen.

  • Our Browsers Lie

    Our Browsers Lie

    Our Problem

    As UI Designers, UX Designers, and Web Developers our main goal is to provide the best experience possible to the users of our products. Sadly our first means of determining who this user is is their browser. Browsers lie and omit. Let us count the ways:

    1. They tell us through the user agent that they are someone else
    2. Our phones tell us they are desktops because they don’t use the mobile media type, even though we are all walking around with them in our pockets
    3. Our desktops now support touch events, even though there is a mouse connected, and the person really likes to use it more than putting greasy fingerprints on their fancy monitor
    4. Our tablets and phones tell us that they are big monitors because they support higher resolutions than our old computers

    Methods of Failure

    So here are the tools we have to solve the problem, and they are terrible tools.

    • User Agent Detection: Massive fail for years now, because of #1, and it gets worse every year (IE11 posing as Mozilla)
    • Media Queries: These fail because of #4 above.
    • JavaScript Feature Detection: These fail because of new browsers merging the touch and click events, as well as #3

    My Proposal

    Here’s what I propose we do about it.

    • Media queries:  Because the screen size information is still valuable, but inadequate for mobile/touch detection
    • JavaScript Feature Detection: Knowing if a device potentially supports touch events is informative, but may lead to false positives
    • A Toggle: Let the user decide. As a user, I know how I use my computer, and even if my computer/browser supports touch I may not use it because I have a mouse connected to my phone/tablet/desktop

    My Wish

    If I could influence the browser and OS developers to make the world a kinder gentler world for us lowly UI/UX Designers/Web developers I would ask them to stop lying to us.

    1. Make the user agent tell us the truth: OS (desktop/mobile, version, bits), Browser (brand, version), Hardware (mouse, touch)
    2. Give us back our mobile media query: My phone has a screen, yes, but it is a mobile screen, not a 19-30″ monitor so don’t tell me it’s the same
  • De-reflector the Aero

    De-reflector the Aero

    I hated the cluttered rear on this bike. So I cleared off the reflectors. I’m going to add lights down the road to increase the visibility. (more…)

  • Thoughts on Adobe …A Parody of Mr. Jobs

    Thoughts on Adobe …A Parody of Mr. Jobs

    This is a direct parody of Steve Jobs letter about Flash.It is intended to be thought provoking, insightful, and inciting.

    Being a Macintosh SE, iPhone, iPad, PowerMac, PowerBook, home built PC, Windows using web, Flash, print developer that has working in the training development, corporate marketing, and software development industries for too long… I couldn’t read Steve’s letter without calling BS. Read this with an open mind and consider the end user, not the corporations. I want Flash, my kids want Flash, why because some developer’s do amazing work on this platform and we should have access to it. Content is king. Enjoy… (more…)

  • IE8 Compatability Mode Strikes My Blog

    IE8 Compatability Mode Strikes My Blog

    I have started working with a new client for some web design work and they were reviewing my site to see my skills… When whammo, my menus are broken and they can’t get into my portfolio. I immediately open IE8 to see what is wrong and I don’t see anything weird.

    That’s when I remember that I installed with compatability mode disabled by default. I turn it on and kablooey! my menus break.

    So if you develop using standards put this meta tag in your document head. Or in the wordpress header file.

    <meta http-equiv=x-ua-compatible content=IE=8>

    Now my menus work again, stupid Microsoft.

  • Sleeping with the enemy – I am running Windows 7

    Sleeping with the enemy – I am running Windows 7

    I never thought I’d see the day when I would upgrade past Windows XP, but it is here. Windows 7 RC is nice; it is almost bug free, fairly well organized, supports Direct X 10, and seems to support most of my hardware. Additionally, I felt no growing pains with my current level of RAM, and system resources. It seems to be the best of XP and Vista put together. But here’s the downside…
    (more…)

  • Where have you been?

    Where have you been?

    Well…to make a long story short I’m a loser. Not in the classical “parental basement dwelling” sense of the word, but in the “I’m neglecting my blog sense”. So here are the updates. I’ve started my new job at a fantastic company Pearson, as the Senior User Interface Designer. I will get to draw on my years of experience with user experience to help push their applications Power Teacher Gradebook, and Power School, to the next level along with a team of talented developers, and product managers. So far its great place to work and great people to work with.

    In other news, and I post this with some reluctance, but I’m not given much choice. My wife’s former employer MusicTalk, Inc. has failed to pay my wife’s salary owed for last year. So far they owe us a total of roughly $20,000. We have heard nothing from their CEO Bobbie Brown, or any representatives of the company’s board of directors. We are awaiting the final judgment from the California State Labor Board, and once that is completed they would have 20 days to appeal. Considering that Bobbie didn’t show up to either the conference or the hearing at the Labor Commission I don’t expect that there will be any appeal, or any word from Bobbie Brown or MusicTalk. We will be looking into what our options are at this point. If anyone has information about this agency, or its business dealings please contact me.

  • No rest for the wicked…or so they say

    No rest for the wicked…or so they say

    Wow what a week. I start a new job this Monday…tomorrow. I’ll be working for Pearson Education in Rancho Cordova. So I won’t be a contractor at HP anymore. I’ll miss my friends there; Greg Willey, Rick “The beer guy” Sellers, and Dave Glass. This position at Pearson should be a great opportunity for me.

    Additionally I went to the BoardWalk in Sacramento on Greenback to support my friend Nate Perkins and his band the Lesdystics! Took a bunch of pictures and they are on my Flickr account. Check em out! This was a lot of fun for me, and I got to test out my Cactus remote triggers and new Vivitar 295 HV flash. What a sweet setup!

    Now I have to get back to work on my contract jobs…Yikes.

  • Cory, Corey, Corry, Correy…

    Cory, Corey, Corry, Correy…

    A few years ago I started researching my ancestry. I’ve been told of our ancestry as being something of a mix of Scottish, Welsh, Irish, French, Prussian, and German to name a few. A bit of a European mutt if you will. So the next logical step was to try and research my last name to see where it leads me. It doesn’t take me long to discover that there a half a dozen variations of my last name: Cory, Corry, Correy, Corey. So I tried looking up a few other names from my ancestry: Hambleton, Doud (I’m actually related to Mamie Doud), Habighorst. Some lead to other information, other lead to more variations. Take Hambleton, Hambelton, Hamletonn, Hamilton, Hambletonne and the list goes on. My first thought was that these were all different families, with similar names. Turns out it even more complex than that. (more…)

  • ‘People-ready business’ or How to market unstable software

    ‘People-ready business’ or How to market unstable software

    It seems that Microsoft’s biggest critics, bloggers, are now being asked to write what ‘People-ready business’ means to them as a way to bolster the phrase and Microsoft’s association with business. This strikes me as a flailing attempt to garner support in people’s minds to think of Microsoft as a business software company. Yes, they own the Office productivity market. Yes, they own the OS market. No they are not ‘People-ready business’. (and no I am not going to link to their site!) (more…)