Register | Forgot password
This little project is based on a blog post by Aza Raskin. I'm not going to repeat what he wrote, but this thing basically works by creating a hidden link to my LinkedIn profile and than using JavaScript to read the color of this link. Because the webbrowser displays links to already visited sites in a different color than new or unknown URLs, this is a perfect way to find out this information. All I did was connecting this piece of JavaScript to the WebManager personalization module:
There is only one problem: WebManager personalizations are XSLT expressions that are evaluated on the server. However, the server cannot execute the JavaScript that is involved in this excersice, so I had to find a way around this. I must make sure my XSLT is valid, otherwise the entire site might break, and it must still include the URL of the page I want to check. I managed to do this by creating a specific XSLT expression, that will always evaluate to true, but contains some important information that can be used by a presentation JSP:
Next I modify the pagepart/content.jspf file. By default, there is a loop that will render any element on the element holder (like a page or media item). I place an additional div around the wm:render tag and append the required JavaScript that will either hide or display the element:
<%-- Let's see whether this element is dependent on a site visit --%>
<c:set var="personalization" value="${element.personalization}" />
<c:set var="siteOff"><xsl:when test="0=0 or '' = </c:set>
<c:set var="siteOn"><xsl:when test="1=1 or '' = </c:set>
<c:set var="elementDivClose" />
<c:if test="${not empty personalization}">
<c:set var="xsl" value="${personalization.xslTemplate}" />
<c:choose>
<c:when test="${fn:contains(xsl, siteOff)}">
<c:set var="testUrl" value="${fn:substringAfter(xsl, siteOff)}" />
<c:set var="testUrl" value="${fn:substringBefore(testUrl, '"')}" />
<c:set var="display0" value="none" />
<c:set var="display1" value="inline" />
</c:when>
<c:when test="${fn:contains(xsl, siteOn)}">
<c:set var="testUrl" value="${fn:substringAfter(xsl, siteOn)}" />
<c:set var="testUrl" value="${fn:substringBefore(testUrl, '"')}" />
<c:set var="display0" value="inline" />
<c:set var="display1" value="none" />
</c:when>
<c:otherwise>
<c:set var="testUrl" />
</c:otherwise>
</c:choose>
<c:if test="${not empty testUrl}">
<div id="element${element.id}">
<c:set var="elementDivClose">
</div>
<script>
document.getElementById('element${element.id}').style.display =
SocialHistory({'mycheck': ${testUrl}}).doesVisit('mycheck')
? '${display0}' : '${display1}';
</script>
</c:set>
</c:if>
</c:if>
<%-- Now render the element --%>
<wm:render object="${element}" />
${elementDivClose}
Now I can add two elements: an image that displays a LinkedIn image to everybody that hasn't visited my LinkedIn profile yet and a paragraph that thanks the blessed soul that already reached that end of the net:
-- this script is currently disabled --
Mark is software engineer with a special interest in Security and Digital WebTV. Mark writes about daily engineering with GX WebManager
Other blog entries: