Mailing List


Mar 2nd 2012
JavaScript Dates
Posted: 2 months ago
Actions: View - Comments - Reblog

JavaScript gives you a lot of flexibility when it comes to date functionality. You can easily pull out any segment individually with just a simple function call. However if you want to format a date, you’ll either need to use the built-in format function, or do a long string concatenation which makes your code look messy.

In my spare time, I made a Server Side JavaScript function for Classic ASP. The source and an example is posted on my personal blog. This function allows you to format dates similar to how PHP’s Date function works. I decided it would be amazing if I could just go ahead and tweak this to work with JavaScript on the client side, so I went ahead and modified my current script to extend the JavaScript date object. Here is a quick peak at how to use this.

console.log(new Date(2012, 1, 25, 10).formatDate('Y-m-d H:i:s'));
// 2012-02-25 10:00:00
console.log(new Date().formatDate('l, F jS, Y'));
// Monday, February 27th, 2012
console.log(new Date().formatDate('r'));
// Mon, 27 Feb 2012 14:03:40 -0600

Download formatDate.js

(Source: Skynet Solutions)

By Blaine Schmeisser

(Source: blog.skynet-solutions.net )


Feb 17th 2012
Should you worry about Non-JavaScript Users?
Posted: 3 months ago
Actions: View - Comments - Reblog

This is a very common question, and the answer varies upon what you are doing. For instance, what is the site’s intention? Who is your target audience? How far can a user without JavaScript get into your website? These are a few of the questions you should consider before building a website.

Less than 2% of users disable JavaScript or don’t have support. This number is rather low, but does that mean they aren’t worth considering? I’ll try and put that into perspective. Let’s assume you have an eCommerce website and sell $10,000/month of product. If you decide to make users have JavaScript in order to check out, you could be losing $200/month or $2,400/year!

I’m not saying you should always make your website plain and boring with no fade in effects or fancy JavaScript rollovers, because users love things like that. However, crucial parts like registering for the website, checking out, emailing support, and other crucial items should all still work without JavaScript.

Yes, you can still make the contact box fade in when they click “contact,” but make sure there is a fallback for users without JavaScript, so they can still contact you. This is easy to accomplish by making the default link go to the real contact page, but use JavaScript to attach a click event to the link. You can still have fancy JavaScript form validation, but make sure you validate on the server and display appropriate error messages as well.

(Source: Skynet Solutions)

By Blaine Schmeisser

(Source: blog.skynet-solutions.net )


Jan 23rd 2012
“getS” Code Snippet
Posted: 4 months ago
Actions: View - Comments - Reblog

Formatting dates is something everybody likes to do, and everybody has their favorite way of formatting it. ASP has a few built in functions to enable us to output it in almost any format we like. However, something I’ve always wanted from Classic ASP was the ability to get the day suffix. Such as turning “January 1, 2012” to “January 1st, 2012”. It’s easier to read and looks a lot nicer. Classic ASP has no support for this so here is a small snippet giving an example of how this can be accomplished and a few examples.

Example (pastebin):

<%
    currDate = NOW()
    Response.write("Today is the " & DAY(currDate) & getS(DAY(currDate)) & "<br />")
        ' Today is the 11th
        '
    currDate = DateAdd("d", 1, currDate)
    Response.write("Tomorrow is the " & DAY(currDate) & getS(DAY(currDate)) & "<br />")
        ' Tomorrow is the 12th
%>

Source (pastebin):

<%
''
' A basic copy of PHP's version of date('S')
' "English ordinal suffix for the day of the month, 2 characters"
' @param int day The day suffix you are looking for.
' @return st ring This is the suffix you were looking for.
''
Function getS(fn_day)

    If fn_day = "" Then
        fn_day = CStr(DAY(NOW()))
    Else
        fn_day = CStr(CInt(fn_day))
    End If
    
    fnll = Mid(fn_day, len(fn_day), 1)
    If len(fn_day) = 1 Then
        fndl = -1
    Else
        fndl = Mid(fn_day, len(fn_day)-1, 2)
    End If
    
    If fndl >= 11 AND fndl <= 13 Then
        getS = "th"
        Exit Function
    ElseIf fnll = 1 Then
        getS = "st"
        Exit Function
    ElseIf fnll = 2 Then
        getS = "nd"
        Exit Function
    ElseIf fnll = 3 Then
        getS = "rd"
        Exit Function
    Else
        getS = "th"
        Exit Function
    End If
End Function
%>

(Source: Skynet Solutions)

By Blaine Schmeisser

(Source: blog.skynet-solutions.net )


Dec 23rd 2011
Making the web Bot Friendly
Posted: 5 months ago
Actions: View - Comments - Reblog

Why should you help out web bots trying to scrape your data? Most users try to make their websites easy for search engines to crawl, but search engines usually only care about words and cache the entire page. There are other bots that look for specific data based on patterns it can find. Most of these bots get a bad reputation since you mainly hear about them when one gets in trouble for stealing email addresses that users leave openly on their website. Some users can get crazy and lock up all sorts of information bots would love, (including Google), such as user pages that hold information like post counts, game scores, or other statistics that can be used.

Making your HTML readable for web bots is generally easy. Most times you already iterate the data and put it in a way web bots can traverse it. We should always use plenty of “ID” attributes to clearly identify parts of the web page. This is especially important if you are not iterating data, like a user page, where you do a query at the top and place all the data appropriately. If none of the user profile has an id or another distinguishable feature, it might be difficult for web bots to find appropriate data. Also, make sure items are separate from their labels. Putting them next to each other can make it difficult to parse; a separate tag and the same parent is ideal.

Web APIs are also a great way for bots to use your data. Most sites already have RSS feeds for bots and users to use freely. Some sites even allow bots to freely use their site search engine, others ban it due to possible abuse. Since APIs like this are easy for bots to parse and less data is sent out, it can help both the website and the bot. If you make some sort of API, make sure all important information can be obtained from it.

(Source: Skynet Solutions)

By Blaine Schmeisser

(Source: blog.skynet-solutions.net )