Thursday, August 28, 2008

Creating tabs in SharePoint using Javascript and CSS

I couldn’t find an example of this, but I was determined to make it work. Here is the result.

I wanted a set of tabs where clicking on a tab would change the category but stay on the same page. Also, I must be able to pass in that category through the URL.

For example, I might have a web page http://...describe.aspx. I want to display information from several SharePoint lists. However, if I use the
URL http://...describe.aspx?animal=cat, then I only want the information about cats, and if I use http://...describe.aspx?animal=dog, then I only want the information about dogs.

Data views in SharePoint Designer will be used to display the desired information, using the animal variable. The method for that is not described here.

So I need to somehow read the variable from the URL using JavaScript. Then I need to highlight the tab corresponding to the variable. I found the code for that here: http://www.dynamicdrive.com/forums/archive/index.php/t-11883.html

It doesn’t look that great in the screenshots, but when you put the code into a SharePoint web part, it looks better. Here is the code:


<style type="text/css">



span.class1

{

float: left;

padding: 4px 0px;

font-size: 1em;

font-family: Tahoma, sans-serif;

border-right: 1px solid rgb(123,166,225);

}



.class1 A:link

{

background-color: #ffffff;

padding: 4px 10px;

background-image="url(/sites/_layouts/images/topnavunselected.gif)";

background-repeat:repeat-x;

}

.class1 A:visited

{

background-color: #ffffff;

padding: 4px 10px;

background-image="url(/sites/_layouts/images/topnavunselected.gif)";

background-repeat:repeat-x;

}

.class1 A:hover

{

text-decoration: none;

background-color: #FCE293;

padding: 4px 10px;

background-image="url(/sites/_layouts/images/PortalTabSelected.gif)";

background-repeat:repeat-x;

}

.class1 A:active

{

background-color: #ffffff;

padding: 4px 10px;

background-image="url(/sites/_layouts/images/topnavunselected.gif)";

background-repeat:repeat-x;

}









</style>





<script type="text/JavaScript">



// set the color of the chosen tab

// the tab is chosen by appending ?page=cat to the URL



function change(page)

{

document.getElementById(page).style.backgroundColor = "#7BA6E1";

document.getElementById(page).style.backgroundImage="url(/sites/_layouts/images/topnavselected.gif)";

document.getElementById(page).style.backgroundRepeat= "repeat-x";

document.getElementById(page).style.fontWeight= "bold";



}



// runs a function at page load time



function addLoadEvent(func) {



  var oldonload = window.onload;

  if (typeof window.onload != 'function') {

    window.onload = func;

  } else {

    window.onload = function() {

      if (oldonload) {

        oldonload();

      }

      func();

    }

  }

}



// run this function at page load time



addLoadEvent(function $_GET(key_str) {

if(window.location.search) {

var query = window.location.search.substr(1);

var pairs = query.split(/&|;/);

for(var i = 0; i < pairs.length; i++) {

var pair = pairs[i].split("=");

if(unescape(pair[0]) == key_str)

return unescape(pair[1]);

}

}

change(pair[1]);

}

);



</script>



<span class=class1>

<a href="default.aspx?page=cat" id=cat>cat</a>

</span>



<span class=class1>

<a href="default.aspx?page=dog" id=dog>dog</a>

</span>



<span class=class1>

<a href="default.aspx?page=horse" id=horse>horse</a>

</span>





- schneid

Wednesday, August 06, 2008

The Salesman at Home

I was wondering what life might be like for the salesman at home.

Customer (Billy): cries and screams incoherently.

Salesman (Dad): "OK, I understand. I'm sure we can do that, let me talk to Engineering. No problem."

Later:

Dad: "The customer would like the system to produce chocolate milk. When can we have that implemented?"

Engineering (Mom): "I'm pretty sure that's impossible".

Dad: "3 months then?"

Mom (exasperated): FINE.

Dad: "Also, a stretch goal would be a baby brother, can you squeeze that in? It's a nice to have, but would really help our customer relationship. The customer really wants that."

Mom: "I think we need more time to consider the implications of that. And we're going to need input from sales. It's going to take 9 months, at least."

Dad: "Can't you work harder and move some things around? We really need this or we might lose the customer. And we need it in 3 months."

Mom (giving up): "Sure."

- schneid

Thursday, July 17, 2008

Anticipating the Great Taste of the Midwest 2008

I love beer festivals. Granted, I haven't been to many, but when it's love, you just KNOW it, you know? The Great Taste is a terrific beer festival for so many reasons. It's really well-organized and reasonably priced at $35. They only sell 5000 tickets, so it's not overcrowded. It's held at a nice park on the lake in Madison. The people are friendly and the food is good. Best of all, every good brewery in the Midwest is serving beer. You can sample some rare beers that are almost impossible to get, such as barrel aged Dark Lord and barrel aged Darkness.

I can't wait for August 9!

- schneid

Wednesday, July 16, 2008

Why did the caribou cross the road?

...because their habitat was destroyed by profit-mongering US oil companies! Gosh, that's not very funny.

Yes, the price of gas is very high right now. That sucks. Most everyone would agree with that. But will drilling for oil in Alaska’s Arctic National Wildlife Reserve solve that problem? No.

Here's the premise: we need to drill for oil in Alaska to lower gas prices!

And here are the reasons that will not work:
  • It will take years to get any oil from ANWR, so why would that help oil prices now?
  • The total oil coming from ANWR will be about 1% of the world oil supply. Why should we think that will affect oil prices by more than 1%?
  • OPEC controls the world's oil prices, so if we actually manage to produce more oil, they will just produce less, keeping the prices the same.
  • Even if somehow we could put a dent in the oil supply, why would Big Oil give us a break on the price??? They could do that RIGHT NOW! But do they? NO! They continue to make record profits while we all suffer the consequences.
Congress could force oil companies to charge less money for gas. But they won't do it, because they get big campaign contributions from Big Oil!

Big Oil could charge less for gas, and maybe just for one quarter they could have just average billion dollar profits, rather than record multi-billion dollar profits. But they won't do it, because then where would the CEos get all the 100 dollar bills to light their cigars?

Good potential solutions may be:
  • alternative energy sources
  • drive less
  • more fuel efficient cars
  • take public transportation
  • 4 day work week
Unfortunately, those things won't happen soon enough, because Americans like to drive their gas guzzlers. And this problem hurts the lower class the most. After all, $400 per month for gas hurts a lot more if your gross income is $2000 per month than if it is $6000 per month. So politicians don't give a crap because they all make tons of money. The US auto industry is reacting too slowly and they will soon be gone because of it.

Didn't we encounter the very same problem in the 1970s? Everyone was going crazy about solar power and other alternative energy sources. Then we were all fat and happy in the 80s and 90s and forgot all about it. Maybe if we spent billions of dollars on research instead of war, we would already have an answer.

Maybe McCain will follow Bush's lead and send everyone an extra tax refund - an economic incentive. Unfortunately, that's just giving you back your own money.

- schneid

Sunday, July 13, 2008

Poker tourney cash

I finally managed to win a little money in a poker tournament.

I was disappointed with my results at Friday's tournament with our weekly group. I would be remiss to not mention my first bustout (it was a rebuy tourney) to Marc with my KK vs his 99 where, of course, he rivered a 9. Anyway, I finished 7th out of 10.

On Saturday night, I found some cool tournaments on PokerStars. There are $12 sit-n-gos for 180 players. The only ones that ever fill are turbos, which I'm not crazy about. It's amazing how fast these go - 2/3 of the players are eliminated in under an hour. It pays 18 places, but you don't get much unless you are top 5. I won a 9 player $16 sit-n-go for $67.50 but didn't cash in the 180-player.

On Sunday night, I played in 6 simultaneous 180-player sit-n-gos. They fill up every 10 minutes or so. I at least doubled my stack in four of them. And finally, in one of them, I made it to the final 3. The overwhelming chip leader surprisingly offered to make a deal. He suggested a very good deal and we agreed. I was third in chips with about 26,000, and the other players had about 54,000 and 190,000. My cut was $350, which was almost second place money.

It was nice to get a decent cash and I'm going to start playing these regularly. The level of the players is awful. When it gets down to about 30 players, the skill level is pretty good. But there isn't much room to maneuver because the antes kick in and the stacks aren't very big, so you pretty much need to push all-in or fold. And then you need to get lucky.

I also played in an insane 0.50/$1 cash game on Saturday night. A guy kept making and calling raises with crap and making huge hands. Here's the first hand he showed down, and lost:

UTG limps, UTG+1 raises to $16 all-in (huge overbet), Maniac calls on BB, UTG calls all-in.

UTG: JJ
UTG+1: AQo
Maniac: 8d3s ???

The board came 6s As 6c 8h 2s and AQo wins with two pair. But the Maniac called a huge $14 to win a $18.50 pot with 83 offsuit! Shortly after, the Maniac triples up.

UTG limps for $1, UTG+2 limps, SB raises to $6, BB (Maniac) raises to $22 all-in, UTG folds, UTG+2 calls all-in, SB calls all-in. The hands?

UTG+2: AcAs
SB: QdQc
Maniac: 43cc

Flop: 3h 2c Tc
Turn: 9c !
River: 2s

And Maniac triples up with his flush. The following hand occurred immediately after that one:

HJ-1 limps, HJ raises to $4, SB (Maniac) calls, BB calls, HJ-1 calls.

Flop: 6c 2d 2h

HJ bets $10, Maniac calls, everyone else folds.

Turn: 9c

HJ bets $21, Maniac raises to $49 all-in, HJ calls.

River: Qc

The HJ had TT. Maniac flopped a boat with 6h2s!

In two hands, the Maniac now has 6x his starting stack.

Now everyone is gunning for the Maniac, calling raises with very little, and hoping to double up. I finally get a decent hand and get into a pot with him.

me: AKo
Maniac: ?

Maniac raises to $5 UTG, CO calls, I call on SB. I wanted to reraise, but I didn't want the CO to think I was trying to isolate the maniac and reraise me.

Flop: 8d Qd Ac

I check to give the Maniac some rope, Maniac bets $10, CO goes all-in for $13, I raise to $25, Maniac calls.

Turn: 9d

I hate that card. I check, Maniac bets $20, I call.

River: 6c

I check, Maniac bets $25, I call.

Maniac shows down 5d3d for a flush! I lost $70 in that pot. I started playing badly, calling raises with bad hands to try to snap off the maniac, but it never happened. Fortunately, I managed to get all-in with someone else with QQ vs TT on a 922 flop to recover my loss and actually finish the table with a slight gain. The Maniac started with $39 and worked it up over $200.

-schneid

Monday, June 23, 2008

Blog Slacker

Sorry that I've been slacking badly on my blog. I need to catch up on Dark Lord Day (April), our Disney trip (April/May), geocaching (June?), my sprained ankle, cub scout stuff including family camp (June), my upcoming trip to my childhood summer camp, Camp Edwards, etc. Now that I'm off World of Warcrack, I might be able to get those blogged.

- schneid

World of Warcrack

In college, I spent a lot of time playing MUDs - Multi-user dimensions, which were a precursor to the massively multiplayer online role-playing games (MMORPG) of today, like World of Warcraft. I eventually became a programmer for some of those MUDs, including the famous HERO MUD. After college, I stopped playing.

Shortly after Ben was born, I borrowed Might and Magic 5 or 6 from a friend. That game is a single player game and isn't even very good, and I played it in all my spare time for a month. I believe Suzette's exact words were "It's us or the game". I gave it back and made my friend promise not to let me borrow it.

A week ago, Suzette gave me a subscription to World of Warcraft for Father's Day.

I am proud to say without any uncertainty and beyond a shadow of a doubt, that I must stop playing this game right now. It's so thoroughly addicting and the hugest time suck. While playing, you check the time and think 30 minutes have gone by, and it's been 3 hours. And I'm not even playing with a group of people, just soloing.

There's a reason they refer to it as World of Warcrack. It's highly addictive. Just like giving samples to kiddies, they give a 10-day free trial, knowing you will get hooked. And I am.

Fortunately, I used the 10-day free trial instead of the subscription, knowing what might happen. I'm going to Target to trade it in for something less addictive like heroin. :) There's a reason that we have never owned an Xbox or other gaming system. Hmm, I wonder if they have those at Target?

- schneid

Monday, June 02, 2008

This was supposed to be the Summer of George!

I haven't blogged in awhile because there's nothing to blog. I sprained my ankle badly on May 9. Plyaing basketball, I made a good cut (unusual for me), got the pass, went up for the shot...and came down hard on someone's foot. I saw the doctor, spent a week on crutches, then hobbled around for a week, but the pain was so bad, I went to see a specialist. He gave me an aircast (the boot) and told me to wear it for 2-3 weeks.

It's a bummer because I was getting back into the groove of running regularly and had lost a few pounds before the injury. I had our bicycles tuned up and was planning on riding to work. We live near the Prairie Path and I can safely ride to work, and it's about 7 miles which is a great short ride. And the summer volleyball season is starting.

This was supposed to be the Summer of George! Do you remember that Seinfeld episode? George discovers that he has a 3 month severance package from the Yankees. He decides to take the summer off, and declares it the "Summer of George". But he gets injured, and the doctor says "Mr. Costanza, your legs have sustained extensive trauma. Apparently your body was in a state of advanced atrophy, due to a period of extreme inactivity. But with a lot of hard work and a little bit of luck, I think there's a good chance you may, one day, walk again." Unmoved by the news, Jerry, Elaine, and Kramer go out for coffee and leave him. He shouts at them as they walk away, "This was supposed to be the Summer of George!"

I plan to wear the boot for a few more days, then start rehabilitating my ankle. I hope to ride my bike pretty soon and play volleyball by the end of June. I had planned to seriously get into shape this summer and drop a lot of weight. Unfortunately, the injury has interfered with the Summer of George but I'll have almost two months left when I'm ready to go.

- schneid

Thursday, April 24, 2008

Here comes Dark Lord Day!

I'm psyched for Dark Lord Day. And also Disney World. :) Suzette took her last quiz a week early, so she is done with her class and earned an A. Friday night, Bob is in town with his family and we are all meeting at Tim's house. Saturday is Dark Lord Day. Last year was the first time I attended Dark Lord Day, and it was awesome. I'm bringing some cool beer to share and trade, and I'll get my ration of Dark Lord. Then on Sunday, we're going to Disney World for a week.

I love vacation!

- schneid

Wednesday, April 16, 2008

Russian Imperial Stout



This is my favorite beer style and I'm assembling a lineup of the best RIS for a tasting with friends. I plan to have about 8 people at the tasting and will have about 12 beers. That might not sound like much, but a Russian Imperial Stout has double to triple the alcohol of your typical beer. We will be sharing 22 oz bombers of each, or two 12 ouncers in some cases.

I've been making beer trades to get the rare ones. For example, a RIS called Sexual Chocolate has only been bottled once, and there were only 500 bottles. Dark Lord may be rare, but they made 5000+ bottles last year. Surly Darkness has only been bottled once and there were only 480 bottles.

Here's the complete lineup. Some of these are not Russian Imperial Stouts, but they are all thick, black, and yummy.
  • Three Floyds Dark Lord
  • Portsmouth Brewing Kate the Great
  • Foothills Brewing Sexual Chocolate
  • Deschutes The Abyss
  • Goose Island Bourbon County Stout
  • Founders Kentucky Breakfast Stout
  • Alesmith Speedway Stout
  • Stone Imperial Russian Stout
  • Smuttynose Imperial Stout
  • Bell's Expedition Stout
  • Great Lakes Blackout Stout
  • America's Brewing Company Bourbon Barrel Signature Imperial Stout
Don't have yet:
  • Peche Mortel
  • Surly Darkness
  • Lost Abbey Older Viscosity
  • Ten Fidy
The Ten Fidy is easy to get, just not around here. The Peche Mortel is harder to get, but not impossible. The Older Viscosity will be hard and the Darkness almost impossible.

Here are some that are easy to get, but might not make the cut:
  • Great Divide Oak Aged Yeti
  • Southern Tier Choklat
  • various Rogue stouts
  • North Coast Old Rasputin
  • Bear Republic Big Bear Black Stout
  • Victory Storm King Stout


- schneid