Thursday, April 10, 2008

SharePoint 2003 Sample Codes

Learned a few tricks last year while customizing SharePoint 2003 with javascript, FrontPage and Data View Webpart...

Format as Rich Text

<tr style="display:{$GroupStyle}">
<td width="100%" colspan="2" class="ms-vb">
<xsl:value-of select="@Summary" disable-output-escaping="yes"/>
</td>
</tr>

Bypass IE 7 Prompt for Window Close Confirmation

window.open('','_parent','');
window.close();

Redirect to Other URL after "Save and Close"


Locate this line:

</WebPartPages:WebPartZone>

Add this after:
<INPUT type=hidden name="NextUsing" id="NextUsing" value="http://xxx.htm">

Close Current Window/Tab and Go to Other URL after "Save and Close"

<script language='javascript'>

function ClickOnce()
{
SetAction();
if(!g_MSclicked)
{
if(frm.ValidateAndSubmit(true))
g_MSclicked = true;
}
else
{
if(confirm(L_ClickOnce1_text ))
frm.ValidateAndSubmit(true);
}

window.open('','_parent','');
window.close();

window.open("http://xxx.htm","_blank");
}

</script>

Pass URL Parameters into a Form


URL: http://xxx.aspx?RID=123&Ter=Asia
Pass "123" and "Asia" to fields "Reference" and "Territory" in a form

<script language="javascript" for="window" event="onload">

var elems = document.getElementsByTagName("INPUT");
var elems2 = document.getElementsByTagName("INPUT");
var RID="";
var Ter="";
var queryString = document.location.search.split("&");

for (var i=0;i<queryString.length;i++)
{
if ((queryString[i].split("=")[0]=="RID") || (queryString[i].split("=")[0]=="?RID"))
RID=queryString[i].split("=")[1];
}

for (var i=0;i<elems.length;i++)
{
if (elems[i].title=="Reference")
elems[i].value=RID;
}

for (var i=0;i<queryString.length;i++)
{
if ((queryString[i].split("=")[0]=="Ter") || (queryString[i].split("=")[0]=="&Ter"))
Ter=queryString[i].split("=")[1];
}

for (var i=0;i<elems2.length;i++)
{
if (elems2[i].title=="Territory")
elems2[i].value=Ter;
}

</script>

Thursday, April 03, 2008

Mind Mapping

Pleasant Surprise...

It's really quite handy to create mind maps with free open source software... easier than I thought...

I was trying out some products (Personal Brain, XMind and FreeMind)... so far I am using Freemind with the maximum joy.

So, instead of dropping notes and thoughts on recycle paper (in "Kowloon King - Tsang Tsou-Choi" style), I can now enjoy brainstorming with a nice UI and not worrying about any conversion
problem :) (paper -> pic by digital camera -> ocr)

I love technology! (and Java... both the language and the beans)

Tuesday, April 01, 2008

Funny Story

As quoted from "bonanova" at BrainDen.com:

A Freshman physics student prized his freedom of approach when he solved problems. So when his final exam asked him to find the height of a building using only a barometer, his answer was to throw the barometer from the roof of the building and time the sound of its hitting the pavement. From the speed of sound and the acceleration due to gravity [ignoring air resistance] he could compute the building's height.

When the prof gave him a failing grade, he appealed. Upon being given a 2nd chance, he said he would tie the barometer to a long string and measure the period of the pendulum that made - again, from the building's roof - and compute the length of the pendulum. Anticipating another failing grade, he gave an additional answer: measuring the length of the barometer, the length of the shadow it cast on the ground and the length of the shadow cast on the ground by the building would give the answer using proportions. He got another failing grade.

He finally appealed to the Dean of the school. In a meeting among the three principals, the Dean gave the student one more shot at giving the "right" answer: measuring the barometric pressure on the sidewalk and on the roof and converting the difference in pressure to inches of air. A really stupid way to use a barometer and one that would require unimaginable precision. Nevertheless that was the answer the prof wanted.

The student would have none of it. He approached the Dean and gave his final solution:

"I would take the barometer to the basement of the building and knock on the superintendent's door. When he answered, I would say to him: 'Sir, I have this beautiful barometer, which I will give to you if you will tell me the height of this building.'"

The Dean gave the student an A.