Categories
Professional

Ah, the power of JavaScript

I was asked about creating a javascript that would place an image on a page based on the day of the week. Easy enough right? Well, it took some tinkering, but here it is (http://www.servergoon.com/samples/dow/). For this demonstration I created eight images, each with the number 0 – 7. However, since the javascript Date Object returns 0 – 6, you will never see the 7.

The code for this is relatively simple, as you can see if you look at the source for this file. In the head I’ve preloaded the image, which, from what I can tell is necessary. Second I’ve got all of the files I want and named them the same, with the exception of the digit indicating the Day of the Week. Hence the DOW (stands for Day Of Week) for the name followed by a digit followed by .jpg. This is so I don’t have to write out 8 (or 31 if you were ambitious enough to do this for each Day Of the Month) individual lines (actually it would be more like 16 lines). It also makes the code to replace the image much easier and shorter to write as well.

The JavaScript in the head of the document looks like:

<SCRIPT language="JavaScript">
<!--
if (document.images)
{
	document.pics = new Array();
	for (j=0; j<8; j++) {
		document.pics[j] = new Image;
		var imageName = "DOW" + j + ".jpg";
		document.pics[j].src = imageName;
	}
}

//-->
</SCRIPT>

The code for the image is below, notice the ID tag, this is VERY important.  Notice that there is no source file, so no image is loaded by default

<img id="DayOfWeek" src="" height="50px" width="50px" border="1"/>
<img id="DayOfWeek2" src="" height="50px" width="50px" border="1"/>

And finally, the code to replace the images in the HTML code.

<script type="text/javascript">
   var myDate = new Date();
   var DOW = myDate.getDay();
   document.getElementById('DayOfWeek').src = document.pics[DOW].src;
   document.getElementById('DayOfWeek2').src = document.pics[DOW+1].src;
</script>

One more thing to note is that the JavaScript that changes the image needs to come AFTER the image in HTML code. If not, it doesn’t know about the image and can’t replace it. The other option would be to put the code in the head of the HTML file and trigger it with a function call.

I hope you found this useful, I know I can think of uses for this.  As always your mileage may vary.

Categories
Professional

Pure CSS two column page

I’ve been working on a web page that I want a left hand menu column on with the content being on the right.  Pretty easy right?  Well, yeah, unless you want a background color in the left hand column and you want it to extend all the way down to the footer, especially if the right hand column is longer than the left.  Well I did some web searching and what I came up with was the suggestion of putting an image as a background to create a virtual image… which is great if you want a fixed width column.  So after doing some looking I found a way to do it with CSS.  Now I by no means claim to be the originator, but I didn’t find this solution by searching google.

The results of the code below can be seen here (http://www.servergoon.com/samples/2column.html) , and yes, I purposefully used Red Green and Blue just so the concept would stand out a bit more.  The CSS attached to the html page is minimal to achieve what I wanted, please feel free to take it and use it as you may.  I’ve tested this on Chrome, Safari, Opera, Firefox and IE on a Win7 machine.  As always, your mileage may vary.

The code for the web page is :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="header"> header </div>
<div class="content">
  <div class="contentLeft">
<ul><li>item1</li><li>item2</li><li>item3</li></ul>
 </div>
  <div>
  <p>Est purus in enim amet. In placerat integer in, platea porttitor, pulvinar elit aliquam nunc est, dapibus a aliquam odio amet. Elementum, urna magna sit? Placerat, sociis tristique ac hac! Pid aliquam aenean ac augue? In turpis aliquet amet, nunc massa etiam sit pid dapibus, lundium lectus augue. Sed a arcu et? Enim tortor sagittis? Augue? Sit scelerisque, duis eu, facilisis phasellus nisi elit porttitor, nascetur duis et augue purus tincidunt etiam. Dictumst sit in pulvinar phasellus, turpis, montes est, a ultrices nec tortor, rhoncus quis magnis? Nunc enim ut turpis pulvinar, duis dis non, elementum, augue dictumst in magna dis odio non et enim? Etiam! In purus parturient ridiculus. Nisi integer? Dis pulvinar proin turpis sed a a urna.</p>

<p>Porttitor dapibus purus? Aenean etiam? Turpis urna porta hac? Nunc amet, scelerisque? Vel in, ac? Habitasse pulvinar, natoque diam, ultricies nec scelerisque aliquam, pulvinar turpis, non! Tincidunt. Platea elit, mauris ac porta adipiscing! Nisi dignissim, proin auctor risus nec dapibus porttitor velit cras! Ridiculus? Odio integer lorem diam porttitor odio platea et tortor elementum! A, aliquam cras tincidunt in? Tincidunt duis, ut dapibus lectus et scelerisque, parturient urna, a massa ac, nunc cras turpis, aliquam, mus porttitor? Magna parturient phasellus in ac, est natoque tortor non. Adipiscing! Turpis ultricies, placerat turpis cum turpis adipiscing turpis. Elit turpis in integer? Pulvinar, est, odio aliquam tincidunt! Adipiscing dignissim, dignissim? Magnis auctor, a porta, lorem in mattis! Scelerisque phasellus rhoncus! Lundium tempor.</p>
</div>
</div>
<div> footer </div>
</body>
</html>

The css for the page is :

@charset "utf-8";
/* CSS Document */

.header {
	background-color:#00F;
	width:100%;
}
.content {
	width:100%;
	background-color:#FFF;
	clear:both;
	overflow:hidden;
}

.contentLeft{
	width:25%;
	margin-bottom:-999px;
	padding-bottom:999px;
	border-right:solid #000 1px;
	float:left;
	background-color:#0F0;

}
.contentRight{
	width:74%;
	float:right;
}
.footer{
	background-color:#F00;
	width:100%;
}

I hope you find this useful. It seem the key is the margin-bottom and padding-bottom in conjunction with the overflow:hidden of the containing folder.

–Server Goon

Categories
Interests Professional

Server Consolidation

With the looming server consolidation and subsequent reorganization I’ve decided to ramble a bit and share my thoughts and concerns.

I work in an educational environment with a distributed IT model.  Seems years ago (I wasn’t here, so I’m going on hearsay here) the university had a centralized IT model and the level of service the individual departments received was unacceptable.  So, individual departments hired their own technical staff, set up their own services and continued to serve their clients (faculty, staff and students) as best they could.  The Centralized IT structure provided infrastructure service (email, phone, internet, etc) and some departments chose to go with their own email and/or calendaring solutions.

Well, it seems as if the cycle is to continue and the mode of operation for this university is to go back to a centralized structure.  Now, I’m on the outside of that structure, so I don’t have insider knowledge as to what is going to happen (which is a concern to me and I would think everyone in my situation).  I can see the benefits of a centralized IT providing university wide services; mail, calendaring, web hosting, internet and phone.  I can even see the benefit of a central IT structure setting down rules and guidelines concerning what security standards must be met in order to “stand up” a server on campus.  I’m even fine with meeting those standards, but I’m concerned about the ability of a larger structure, concerned with university wide services, to provide the support and service for those smaller specialized applications used on a departmental basis.  Those concerns aside, I’m still willing to work with the centralized IT, I’m still willing to see what advantages can be provided by a consolidated bargaining unit when it comes to purchasing hardware and software.

When talking about server consolidation — and when talking consolidation let’s not forget the subsequent consolidation (read reduction) of work force — the buzz words seem to be “economies of scale”, and “providing better service by providing specialized expertise”.  I’ll be the first to admit I’m stretched between multiple projects most of the time and I rarely have time to become an “expert” (that may be the subject of another rant) in any one area.  However, when the centralized IT talks about expertise, they are also (once again, this is from my viewpoint from outside the structure) talking about limiting what services are provided.  The focus seems to be on Oracle DB services and MicroSoft server products.  Needless to say, this is a concern to me.  I’m more of a LAMP (Linux Apache MySQL PHP) person myself.  Now we’ve been guaranteed there would be no “reduction in service” but when you have staffing that doesn’t allow you to support what’s running “out in the field” how is that possible?

These are just a few of my concerns, and they’re not to the point of keeping me awake at night… yet.  But as I work on providing a list of servers and the services they provide these concerns come to the forefront.  I have an investment in my area and I have an investment in the services I provide.  I almost feel as if I’m providing a hit list of sorts, betraying my department by providing information that will eventually lead changes, changes that may not be fully welcome.

I see the security concerns, I see the concerns of a CIO that may not fully know what all technology is being used on campus.  But I am also keenly aware of the concerns of my fellow coworkers and department.  I’m aware of the services we provide because that service wasn’t offered centrally.  And most of all, being the selfish being that I am, I’m concerned about what my job will look like in the coming year.

Of course, after writing this, I may not have to worry about that…