Archive

Monthly Archives: February 2010

If you have a lot of work like me, then it would be much better and easy just to split all amount of work into queue of tasks.
Each task should have estimation about 20-30 minutes.
Not more. If it takes more then you need to split the task into several sub-tasks or do it in some other principally different way.

You can do some task or several, then you can read/write some posts/comments, or spend next 20-30 minutes for research.

Besides, every even small task done may be used as additional motivation factor for further work.

Happy coding!

Advertisements

There is one more interesting issue.
ASPX page has 3 select boxes to enter user’s date of birth:
Months, Days, Years

The problem is that we need dynamically correct options of Days select box.
It depends on values currently selected in other select boxes Months and Years.

jQuery(function() {
var dMonthID = ‘<%=dMonth.ClientID%>’;
var dDayID = ‘<%=dDay.ClientID%>’;
var dYearID = ‘<%=dYear.ClientID%>’;
var cal_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

var safeToInt = function(n) {
try {
n = parseInt(n);
} catch (e) { n = 0; }
return n;
}
var updateDays = function() {
var nDays = 31;
var nMonth = safeToInt(jQuery(‘#’ + dMonthID).val());
if (nMonth > 0)
nDays = cal_days_in_month[nMonth – 1];
if (nMonth == 2) {
var nYear = safeToInt(jQuery(‘#’ + dYearID).val());
if ((nYear % 4 == 0 && nYear % 100 != 0) || nYear % 400 == 0)
nDays = 29;
}
var days = jQuery(‘#’ + dDayID);
var current = days.val();
var sDays = ‘<option value=”-1″>-Day-</option>’;
for (var i = 1; i <= nDays; ++i)
sDays += ‘<option value=”‘ + i + ‘”>’ + i + ‘</option>’;
days.html(sDays);
days.val(current);
}
jQuery(‘#’ + dMonthID).change(function() { updateDays(); });
jQuery(‘#’ + dYearID).change(function() { updateDays(); });
updateDays();
});
//–></script>

// Track and send to the server the time page was opened.
// It support focus/blur.
// It doesn’t work in Opera.

<script type=”text/javascript”><!–
var startTime = null;
var timeOnPage = 0; // in milliseconds
var startTrack = function()
{
var d = new Date();
if (null != startTime)
timeOnPage += d.getTime() – startTime;
startTime = d.getTime();
}
var stopTrack = function()
{
var d = new Date();
if (null != startTime)
timeOnPage += d.getTime() – startTime;
startTime = null;
}
window.onfocus = function(){ startTrack(); };
window.onblur = function(){ stopTrack(); };
window.onbeforeunload = function()
{
stopTrack();
var i = new Image();
i.src = ‘/tracking?time=’ + timeOnPage;
}
startTrack();
//–></script>

If you deploy source files to some production server,
it would be nice to have $Id$ mark in our sources.

Just place for example:

<?php
/**
* @version $Id$
*/

So, it will be:

<?php
/**
* @version $Id: some_file.php 548 2010-02-14 11:48:28 user1 $
*/

Also, set the svn:keywords property on the command line:
    svn propset svn:keywords “Id” some-file.php

If you need that for several (or even all) files you need to do that propset for each one.

We are jumping from static .html site to new ASP.MVC version.
There are several legacy .html urls that we need to route to new controller’s methods.
Besides, we need to support new pure .html pages places in the project tree.

1. To provide legacy URL redirects (301-Permanent redirect) by URL Routing,
we mapped .html to Aspnet_isapi.dll in IIS settings of the web application.

2. Add routing for legacy URLs like:

routes.Add(new LegacyRoute(“{action}.html”, “Products”, new LegacyRouteHandler())
{
Constraints = new RouteValueDictionary { { “action”, “arena|gallery|construct” } }
});
routes.Add(new LegacyRoute(“advergames.html”, “Products”, new LegacyRouteHandler())
{
Defaults = new RouteValueDictionary { { “action”, “arena” } }
});
routes.Add(new LegacyRoute(“news2003.html”, “Company-Info-news”, new LegacyRouteHandler())
{
Defaults = new RouteValueDictionary { { “action”, “news” }, { “year”, “2003” } }
});
routes.Add(new LegacyRoute(“{game}.html”, “Games-Game”, new LegacyRouteHandler())
{
Defaults = new RouteValueDictionary { { “category”, “arcade” } }
,
Constraints = new RouteValueDictionary { { “game”, “alien-attack|alus-revenge|arcade-football” } }
});
routes.Add(new LegacyRoute(“{category}-games.html”, “Games-Category”, new LegacyRouteHandler())
{
Constraints = new RouteValueDictionary { { “category”, “arcade|card|casino” } }
});
routes.Add(new LegacyRoute(“games.html”, “Games-AllGames”, new LegacyRouteHandler()));
routes.Add(new LegacyRoute(“index.html”, “Root”, new LegacyRouteHandler()));

3. Process all other .html as regular pages

routes.Add(new Route(“*.html”, new StopRoutingHandler()));

4. Add Page-Not-Found routing

routes.MapRoute(
“404-PageNotFound”,
“{*url}”,
new { controller = “home”, action = “PageNotFound” }
);

5. For IIS-6 provide IHttpHandler for .html as we should process it in our ASPX application

<httphandlers>
<add path=”*.html” verb=”*” type=”System.Web.StaticFileHandler”></add>