Ok. Super cool. Getting this working bit by bit. Decided to go against using a pop-up window as it would get blocked by browsers, and instead created a layer that gets shown if the user has logged in last before the question has been posted.
The problem now is that everytime the page loads during this session the user sees the layer. I want to set the last_visit_date to the current time so that if the user comes to the page again they won't see the layer.
How do I set the last_visit_time of the user? Oh I guess I also need to understand how to post the response to the article...
Btw code is below for fun:
<script type="text/javascript">
function toggleLayer( whichLayer )
{
var elem, vis;
if( document.getElementById ) // this is the way the standards work
elem = document.getElementById( whichLayer );
else if( document.all ) // this is the way old msie versions work
elem = document.all[whichLayer];
else if( document.layers ) // this is the way nn4 works
elem = document.layers[whichLayer];
vis = elem.style;
// if the style.display value is blank we try to figure it out here
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
</script>
<style>
div#box {
border:solid;
-moz-border-radius: 10px; -webkit-border-radius: 10px;
border-color:#333;
-moz-border-radius: 15px;
padding: 10px;
/* Firefox 4+ */
-moz-animation-name: fade;
-moz-animation-timing-function: linear;
-moz-animation-duration: 3s;
/* Webkit */
-webkit-animation-name: fade;
-webkit-animation-timing-function: linear;
-webkit-animation-duration: 3s;
}
@-moz-keyframes fade {
0% { opacity: 0; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
@-webkit-keyframes fade {
0% { opacity: 0; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
</style>
<!-- Find the current date and convert to milliseconds -->
<#assign date_now_number = datesupport.now.millisecondsAsString?number />
<!-- Figure out the current User ID number -->
<#assign my_userid = user.id />
<!-- Figure out the last visit date of the current user -->
<#assign date_visit = rest("/users/id/" + my_userid + "/last_visit_time").value?datetime("yyyy-MM-dd'T'HH:mm:ss") />
<!-- Convert last visit date to milliseconds -->
<#assign date_visit_number = datesupport.setDate(date_visit).millisecondsAsString?number />
<!-- Find the URL of the featured article in the specific board -->
<#assign latest_topics = rest("/boards/id/tipsandtricks/threads/featured").threads />
<#list latest_topics.thread as thread>
<#assign topic = thread.messages.topic />
<#assign my_url = topic.@view_href />
<!-- Find the post time of the featured article -->
<#assign my_topic_posttime = topic.post_time?datetime("yyyy-MM-dd'T'HH:mm:ss") />
<#assign post_time = datesupport.setDate(my_topic_posttime).millisecondsAsString?number />
<!-- Figure out the date to compare -->
<#assign my_lastlogin = user.lastVisitTime />
<!-- For show variable for troubleshooting
now is: ${date_now_number} <br />
post_time = ${post_time}<br />
date_visit_number = ${date_visit_number} <br />
date_visit = ${date_visit} <br />
my_topic_posttime = ${my_topic_posttime}
-->
<#if post_time lt date_visit_number>
Now date_visit_number = ${date_visit_number} <br />
<div id="page">
<br /><br /><br />
<div id="box">
<div style="float:right">
<input type="reset" name="reset" value="Close Window"
onclick="javascript:toggleLayer('page');" /></div>
<p>
Code to grab subject from featured article.
Code to post comment to article.
</p>
<p> </p>
</div>
<br /><br /><br /></div>
</#if>
</#list>