added code to poll for new user's notifications

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/liferay62-plugins/social-dockbar-hook@126673 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-04-01 16:11:14 +00:00
parent c9ac1a8faa
commit d41a092064
1 changed files with 99 additions and 65 deletions

View File

@ -3,12 +3,31 @@
//themeDisplay.getUser().getScreenName(); //themeDisplay.getUser().getScreenName();
String currentVirtualHost = request.getServerName(); String currentVirtualHost = request.getServerName();
String groupName = currentVirtualHost.split("\\.")[0]; String groupName = currentVirtualHost.split("\\.")[0];
String mySiteURL = "/"+groupName; String mySiteURL = "/" + groupName;
%> %>
<script> <script>
jQuery(document).ready(function() { jQuery(document).ready(function() {
//check for notifications on load after 3 seconds
var username = "<%=themeDisplay.getUser().getScreenName()%>";
$.get('/notificationchecker/notificationchecker', {
userid : username
}, function(responseText) {
});
//then repeat every 1.5 minutes
setInterval(function() {
var username = "<%=themeDisplay.getUser().getScreenName()%>";
$.get('/notificationchecker/notificationchecker', {
userid : username
}, function(responseText) {
});
}, 90000);
//search box keyboard handlers //search box keyboard handlers
$('#searchbox').bind("enterKey",function(e){ $('#searchbox').bind("enterKey",function(e){
if ($('#searchbox').val() != "") { if ($('#searchbox').val() != "") {
@ -115,80 +134,95 @@
var base64hashtag = btoa($('#searchbox-phone').val()); var base64hashtag = btoa($('#searchbox-phone').val());
var base64attr = btoa("elasticSearchIdentificationParameter"); var base64attr = btoa("elasticSearchIdentificationParameter");
if (window.location.href.indexOf("<%=mySiteURL%>") >= 0) { if (window.location.href.indexOf("<%=mySiteURL%>") >= 0) {
window.location.href = "/group<%=mySiteURL%>?"+base64attr+"="+ base64hashtag; window.location.href = "/group<%=mySiteURL%>?"
} + base64attr
else { + "="
//this is when you are in a VRE and you want to search in that VRE, count the slashes to get where to point + base64hashtag;
//you always want to point to /group/vrename } else {
var newhref = window.location.href; //this is when you are in a VRE and you want to search in that VRE, count the slashes to get where to point
if (window.location.href.indexOf("?") >= 0) { //you always want to point to /group/vrename
newhref = window.location.href.split("?")[0]; var newhref = window.location.href;
} if (window.location.href
var count = newhref.split("/").length-1; .indexOf("?") >= 0) {
if (count > 4) newhref = window.location.href
window.location.href = newhref + "/../?"+base64attr+"="+ base64hashtag; .split("?")[0];
else }
window.location.href = newhref + "?"+base64attr+"="+ base64hashtag; var count = newhref
} .split("/").length - 1;
} if (count > 4)
window.location.href = newhref
} + "/../?"
}); + base64attr
}); + "="
+ base64hashtag;
else
window.location.href = newhref
+ "?"
+ base64attr
+ "="
+ base64hashtag;
}
}
}
});
});
</script> </script>
<!-- When desktop --> <!-- When desktop -->
<div class="collapse nav-collapse"> <div class="collapse nav-collapse">
<ul class="nav nav-add-controls"> <ul class="nav nav-add-controls">
<li class="dockbar-item"><a class="" <li class="dockbar-item"><a class=""
href="<%="/group/" + groupName%>" id="homeIcon" title= "<%=groupName%> Infrastructure Gateway Home"> href="<%="/group/" + groupName%>" id="homeIcon"
<i class="icon-home" style="font-size: 24px;"></i> title="<%=groupName%> Infrastructure Gateway Home"> <i
</a></li> class="icon-home" style="font-size: 24px;"></i>
<li class="dockbar-item"><a class="" </a></li>
href="<%="/group/" + groupName + "/workspace"%>" id="wsIcon" <li class="dockbar-item"><a class=""
alt='Workspace' title='Virtual Workspace'> <i href="<%="/group/" + groupName + "/workspace"%>" id="wsIcon"
class="icon-folder-open" style="font-size: 24px;"></i> alt='Workspace' title='Virtual Workspace'> <i
</a></li> class="icon-folder-open" style="font-size: 24px;"></i>
<li class="dockbar-item"><a class="" </a></li>
href="<%="/group/" + groupName + "/messages"%>" id="messagesIcon" <li class="dockbar-item"><a class=""
alt='See Messages' title='Messages'> <i class="icon-envelope" href="<%="/group/" + groupName + "/messages"%>" id="messagesIcon"
style="font-size: 24px;"></i> alt='See Messages' title='Messages'> <i class="icon-envelope"
</a></li> style="font-size: 24px;"></i>
</ul> </a></li>
</ul>
</div> </div>
<div class="collapse nav-collapse"> <div class="collapse nav-collapse">
<ul class="nav nav-add-controls"> <ul class="nav nav-add-controls">
<li class="dockbar-item"> <li class="dockbar-item"><input id="searchbox" type="text"
<input id="searchbox" type="text" placeholder="Search News Feed"> placeholder="Search News Feed"></li>
</li> </ul>
</ul>
</div> </div>
<!-- When phone or tablet --> <!-- When phone or tablet -->
<span> <span> <a class="btn btn-navbar"
<a class="btn btn-navbar" href="<%="/group/" + groupName + "/workspace"%>" id="wsIcon" href="<%="/group/" + groupName + "/workspace"%>" id="wsIcon"
alt='Workspace' title='Virtual Workspace'> <i class="icon-folder-open" style="font-size: 24px;"></i> alt='Workspace' title='Virtual Workspace'> <i
</a> class="icon-folder-open" style="font-size: 24px;"></i>
</a>
</span> </span>
<span> <span> <a class="btn btn-navbar"
<a class="btn btn-navbar" href="<%="/group/" + groupName + "/messages"%>" id="messagesIcon" href="<%="/group/" + groupName + "/messages"%>" id="messagesIcon"
alt='See Messages' title='Messages'> <i class="icon-envelope" alt='See Messages' title='Messages'> <i class="icon-envelope"
style="font-size: 24px;"></i> style="font-size: 24px;"></i>
</a> </a>
</span> </span>
<span> <span> <a class="btn btn-navbar"
<a class="btn btn-navbar" href="<%="/group/" + groupName%>" id="homeIcon" title= "<%=groupName%> Infrastructure Gateway Home"> href="<%="/group/" + groupName%>" id="homeIcon"
<i class="icon-home" style="font-size: 24px;"></i> title="<%=groupName%> Infrastructure Gateway Home"> <i
</a> class="icon-home" style="font-size: 24px;"></i>
</a>
</span> </span>
<c:choose> <c:choose>
<c:when test="<%= themeDisplay.isShowControlPanelIcon() %>"> <c:when test="<%=themeDisplay.isShowControlPanelIcon()%>">
<span class="btn btn-navbar"> <span class="btn btn-navbar"> <input id="searchbox-phone"
<input id="searchbox-phone" type="text" style="width: 70px;" placeholder="Search ..."> type="text" style="width: 70px;" placeholder="Search ...">
</span> </span>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<span class="btn btn-navbar"> <span class="btn btn-navbar"> <input id="searchbox-phone"
<input id="searchbox-phone" type="text" placeholder="Search News Feed"> type="text" placeholder="Search News Feed">
</span> </span>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<!-- End When phone or tablet --> <!-- End When phone or tablet -->