Monday, December 03, 2012

jQuery plugin: showKeyPressed

jQuery plugin: showKeyPressed

This plugin allows you to show the user the characters typed (temporarily) in a password field. The following would run on any password fields with the secure class.

Usage: $(":password.secure").showKeyPressed();

____________________

(function($){
    var ShowKeyPressedLib = {
        show: function (e, refNum, source)
        {
            e = e || window.event;
            var refId = "KP__" + refNum;
            var keycode = e.which;
            if (keycode == 32 ||
                keycode >= 41 && keycode <= 44 ||
                keycode >= 47 && keycode <= 111 ||
                keycode >= 146)
            {
                $(".keypressed").remove(); // Remove all previously shown first
                var coords = $(source).offset();
                var addPixels = 6 * source.value.length;
                $("<div></div>").attr("id", refId)
                                .css({ top: (coords.top - 20) + 'px', left: (coords.left + addPixels) + 'px' })
                                .addClass("keypressed")
                                .html(String.fromCharCode(keycode))
                                .appendTo("body");
            }
        },
        hide: function (refNum)
        {
            $("#KP__" + refNum).remove();
        },
        counter: 0
    }

    $.fn.showKeyPressed = function(){
     return $(this).bind('keypress', function(e){
            var refNum = ShowKeyPressedLib.counter++;
            ShowKeyPressedLib.show(e, refNum, this);
            setTimeout(function(){ ShowKeyPressedLib.hide(refNum) }, 999);
        });
    };
})(jQuery);

Thursday, June 28, 2012

Display the results of any query in Classic ASP

Display the results of any query in Classic ASP:

    If rs.EOF Then
        %>No record found<%
    Else
        Response.Write "
"
        Response.Write ""
        For i = 0 to rs.Fields.Count -1
            Response.Write ""
            Response.Write ""
            Response.Write ""
            Response.Write ""
        Next
        Response.Write "
Login Info
" & GetFieldName( rs.Fields(i).Name, fGeekMode ) & "" & rs.Fields(i).Value & " 
"

        %>
       

        Note: "Minutes Logged In" is not accurate if the session is not active, or if the session is inactive,

        and the user didn't logout (i.e., they closed their browswer instead of clicking Logout).

       

       

        Click Here to Kill This Login Session

            You would want to kill a session if the user is getting Read-Only access, and does

            not want to wait for their current session to time-out. Beware, this will log out the user if

            they are still using this session.
        <%
    End If

PRE
    If rs.EOF Then
        %>No record found<%
    Else
        Response.Write ""
        Response.Write ""
        For i = 0 to rs.Fields.Count -1
            Response.Write ""
            Response.Write ""
            Response.Write ""
            Response.Write ""
        Next
        Response.Write "
Login Info
" & GetFieldName( rs.Fields(i).Name, fGeekMode ) & "" & rs.Fields(i).Value & " 
" %>
Note: "Minutes Logged In" is not accurate if the session is not active, or if the session is inactive,
and the user didn't logout (i.e., they closed their browswer instead of clicking Logout).
 
 
Click Here to Kill This Login Session
    You would want to kill a session if the user is getting Read-Only access, and does
    not want to wait for their current session to time-out. Beware, this will log out the user if
    they are still using this session. <% End If
End

Thursday, February 16, 2012

My HTML is not updating during multiple AJAX calls

http://amolnw.wordpress.com/2009/10/08/ie6-offsettop-issue-and-solution/
http://stackoverflow.com/questions/1397478/forcing-a-dom-refresh-in-internet-explorer-after-javascript-dom-manipulation
function flushThis(id){
   var msie = 'Microsoft Internet Explorer';
   var tmp = 0;
   var elementOnShow = document.getElementById(id);
   if (navigator.appName == msie){
      tmp = elementOnShow.parentNode.offsetTop  +  'px';
   }else{
      tmp = elementOnShow.offsetTop;
   }
}


Element.addMethods({
  redraw: function(element){
    element = $(element);
    var n = document.createTextNode(' ');
    element.appendChild(n);
    (function(){n.parentNode.removeChild(n)}).defer();
    return element;
  }
});

You may also use some kind of addClass/removeClass combo. That would result into the same effect but without creating unused DOM elements. We use this method in qooxdoo and it works well.

Tuesday, January 24, 2012

Non-8dot3 format of a Windows path

I was trying to find out to get the non-8dot3 format of a Windows path to a file, and found this blog post that said at the bottom of the page:

1. start -> run: cmd
2. go to desired folder, i.e. cd "C:\Documents and Settings\All Users\Start Menu\Applications"
3. type command.com you'll get command prompt like C:\DOCUME~1\ALLUSE~1\STARTM~1\APPLIC~1>

Runner up: dir /x