var CURRENT_ADD_AREA = null;
var CURRENT_ADD_AREA_NODEID = null;
var CURRENT_ADD_AREA_NODE = null;
var CURRENT_ADD_AREA_HAS_UP = null
var CHAT_LOADED_ARRAY = {};
var CHAT_TIMER = null;
var DEBATE_TREE_SMALL = true;
var DEBATE_LOADED_ARRAY = {};
var DEBATE_TIMER = null;
function toggleDebateMode() {
if ($('toggleDebateButton').innerHTML == "(View wider knowledge trees)") {
DEBATE_TREE_SMALL = false;
$('toggleDebateButton').innerHTML = "(View narrower knowledge trees)";
$('toggleDebateButton').title = "See only the immediate knowledge trees that the current item is a part of";
drawDebates(false, "");
} else {
DEBATE_TREE_SMALL = true;
$('toggleDebateButton').innerHTML = "(View wider knowledge trees)";
$('toggleDebateButton').title = "See the full and wider knowledge trees that the current item is a part of. This can take a while to load.";
drawDebates(false, "");
}
}
function getExploreViz(viz) {
if (viz == "" ||
(viz != "linear" && viz != "widget" && viz != "net")) {
viz = DEFAULT_VIZ;
var allcookies = document.cookie;
if (allcookies != null) {
var cookiearray = allcookies.split(';');
for(var i=0; i"+title+" "+name);
}
var nodetype = nodeObj.role.name;
var title=getNodeTitleAntecedence(nodetype);
var type = '';
if (nodetype == 'Challenge') {
type = 'challenge';
} else if (nodetype == 'Issue') {
type = 'issue';
} else if (nodetype == 'Claim') {
type = 'claim';
} else if (nodetype == 'Solution') {
type = 'solution';
} else if (nodetype == 'Organization') {
type = 'org';
} else if (nodetype == 'Project') {
type = 'project';
} else if (nodetype == "Theme") {
type = 'theme'
} else if (EVIDENCE_TYPES_STR.indexOf(type) != -1) {
type = 'evidence';
} else if (RESOURCE_TYPES_STR.indexOf(type) != -1) {
type = 'web';
} else if (nodetype == "News") {
type = 'news';
}
if (type != 'news') {
buildExploreToolbar($('headertoolbar'), title+name, type, nodeObj, from);
}
}
function buildSearchTitle(type, query, tagsonly) {
//var name = search;
var widgetHeaderLabel = $('exploreheaderlabel');
if (widgetHeaderLabel) {
if (type == 'tree') {
if (tagsonly == true) {
widgetHeaderLabel.insert('Knowledge Trees for Tag search results on: '+query);
} else {
widgetHeaderLabel.insert('Knowledge Trees for Search results on: '+query);
}
} else if (type == 'net') {
if (tagsonly == true) {
widgetHeaderLabel.insert('Networks for Tag search results on: '+query);
} else {
widgetHeaderLabel.insert('Networks for Search results on: '+query);
}
}
}
}
function buildExploreToolbar(container, name, type, node, from) {
var nodeid = node.nodeid;
// parent list button
if (type == 'issue') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#issue-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the Requirements / Issues List'});
homelink.insert(homebutton);
container.insert(homelink);
} else if (type == 'challenge') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#challenge-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the Key Challenges List'});
homelink.insert(homebutton);
container.insert(homelink);
} else if (type == 'claim') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#claim-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the Research Claims List'});
homelink.insert(homebutton);
container.insert(homelink);
} else if (type == 'solution') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#solution-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the Technological Capabilities List'});
homelink.insert(homebutton);
container.insert(homelink);
} else if (type == 'org') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#org-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the People/Organizations List'});
homelink.insert(homebutton);
container.insert(homelink);
} else if (type == 'project') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#project-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the Projects List'});
homelink.insert(homebutton);
container.insert(homelink);
} else if (type == 'evidence') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#evidence-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the Evidence List'});
homelink.insert(homebutton);
container.insert(homelink);
} else if (type == 'web') {
var homelink = new Element('a',{'class':'exploreToolbarIcon'});
homelink.href="https://big.evidence-hub.net/index.php?#web-list";
var homebutton = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/list.png', 'title':'Click to go to the Resources List'});
homelink.insert(homebutton);
container.insert(homelink);
}
// print button
var print = new Element("img",
{'src': 'https://big.evidence-hub.net/images/printer.png',
'alt': 'Print this item',
'title': 'Print this item',
'class': 'active exploreToolbarIcon'});
container.insert(print);
Event.observe(print,'click',function(){
if (from == 'trees') {
printKnowledgeTreeExplore(NODE_ARGS, name, nodeid, node.name);
} else {
printNodeExplore(NODE_ARGS, name, nodeid);
}
});
// Add spam icon
var spaming = new Element('img', {'class':'exploreToolbarIcon'});
if (node.status == 1) {
spaming.setAttribute('alt', 'Reported as Spam');
spaming.setAttribute('title', 'This has been reported as Spam / Inappropriate content');
spaming.setAttribute('src', 'https://big.evidence-hub.net/images/spam-reported.png');
} else if (node.status == 0) {
if(USER != ""){
spaming.setAttribute('alt', 'Report as Spam');
spaming.setAttribute('title', 'Report this as Spam / Inappropriate content');
spaming.setAttribute('src', 'https://big.evidence-hub.net/images/spam.png');
Event.observe(spaming,'click',function (){ reportNodeSpamAlert(this, type, node); } );
} else {
spaming.setAttribute('alt', 'Sign In to Report as Spam');
spaming.setAttribute('title', 'Sign In to Report this as Spam / Inappropriate content');
spaming.setAttribute('src', 'https://big.evidence-hub.net/images/spam-disabled.png');
Event.observe(spaming,'click',function (){ $('loginsubmit').click(); return true; } );
}
}
container.insert(spaming);
// edit button
if (USER != "") {
var userid = node.users[0].userid;
if (userid == USER) {
var otheruserconnections = node.otheruserconnections;
if (type == 'issue') {
var edit = new Element('img',{'class':'exploreToolbarIcon','alt':'Edit', 'title': 'Edit this Requirement / Issue', 'src': 'https://big.evidence-hub.net/images/edit.png'});
Event.observe(edit,'click',function (){loadDialog('editissue',URL_ROOT+"ui/popups/issueedit.php?nodeid="+nodeid, 770,500)});
container.appendChild(edit);
} if (type == 'challenge') {
var edit = new Element('img',{'class':'exploreToolbarIcon','alt':'Edit', 'title': 'Edit this Key Challenge', 'src': 'https://big.evidence-hub.net/images/edit.png'});
Event.observe(edit,'click',function (){loadDialog('editchallenge',URL_ROOT+"ui/popups/challengeedit.php?nodeid="+nodeid, 770,500)});
container.appendChild(edit);
} else if (type == 'claim') {
var edit = new Element('img',{'class':'exploreToolbarIcon','alt':'Edit', 'title': 'Edit this Research Claim', 'src': 'https://big.evidence-hub.net/images/edit.png'});
Event.observe(edit,'click',function (){loadDialog('editclaim',URL_ROOT+"ui/popups/claimedit.php?nodeid="+nodeid, 770,500)});
container.appendChild(edit);
} else if (type == 'solution') {
var edit = new Element('img',{'class':'exploreToolbarIcon','alt':'Edit', 'title': 'Edit this Technological Capability', 'src': 'https://big.evidence-hub.net/images/edit.png'});
Event.observe(edit,'click',function (){loadDialog('editsolution',URL_ROOT+"ui/popups/solutionedit.php?nodeid="+nodeid, 770,500)});
container.appendChild(edit);
} else if (type == 'org' || type == 'project') {
var edit = new Element('img',{'class':'exploreToolbarIcon','alt':'Edit', 'title': 'Edit this item', 'src': 'https://big.evidence-hub.net/images/edit.png'});
Event.observe(edit,'click',function (){loadDialog('editorg',URL_ROOT+"ui/popups/organizationedit.php?nodeid="+nodeid, 770,500)});
container.appendChild(edit);
} else if (type == 'evidence') {
var edit = new Element('img',{'class':'exploreToolbarIcon','alt':'Edit', 'title': 'Edit this Evidence', 'src': 'https://big.evidence-hub.net/images/edit.png'});
Event.observe(edit,'click',function (){loadDialog('editevidence',URL_ROOT+"ui/popups/evidenceedit.php?nodeid="+nodeid, 770,500)});
container.appendChild(edit);
} else if (type == 'web') {
var edit = new Element('img',{'class':'exploreToolbarIcon','alt':'Edit', 'title': 'Edit this Resource', 'src': 'https://big.evidence-hub.net/images/edit.png'});
Event.observe(edit,'click',function (){loadDialog('editresource',URL_ROOT+"ui/popups/resourceedit.php?nodeid="+nodeid, 770,500)});
container.appendChild(edit);
}
if (otheruserconnections == 0) {
var del = new Element('img',{'class':'exploreToolbarIcon','alt':'Delete', 'src': 'https://big.evidence-hub.net/images/delete.png'});
Event.observe(del,'click',function (){
deleteNode(node.nodeid, node.name, node.role.name, 'gotoHomeList', type);
});
container.appendChild(del);
} else {
var del = new Element('img',{'alt':'Delete unavailable', 'title': 'You cannot delete this item. Someone else has connected to it', 'class':'exploreToolbarIcon', 'src': 'https://big.evidence-hub.net/images/delete-off.png'});
container.appendChild(del);
}
}
}
// follow button
if (USER != "") {
var followbutton = new Element('img', {'class':'exploreToolbarIcon'});
followbutton.setAttribute('src', 'https://big.evidence-hub.net/images/follow.png');
followbutton.setAttribute('alt', 'Follow');
followbutton.setAttribute('id','follow'+nodeid);
followbutton.nodeid = nodeid;
container.insert(followbutton);
if (node.userfollow && node.userfollow == "Y") {
Event.observe(followbutton,'click',function (){ unfollowNode(node, this, "refreshWidgetFollowers()") } );
followbutton.setAttribute('src', 'https://big.evidence-hub.net/images/follow.png');
followbutton.setAttribute('title', 'Unfollow this item...');
} else {
Event.observe(followbutton,'click',function (){ followNode(node, this, "refreshWidgetFollowers()") } );
followbutton.setAttribute('src', 'https://big.evidence-hub.net/images/follow.png');
followbutton.setAttribute('title', 'Follow this item...');
}
} else {
container.insert("");
}
// add explore button on all non explore views
if (from != 'explore') {
var explore = new Element('a',{'class':'exploreToolbarIcon'});
explore.href="https://big.evidence-hub.net/explore.php?id="+nodeid;
var image = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/explore.png', 'alt':'Go to full information on this item.'});
explore.insert(image);
explore.title = 'Go to full information on this item.';
container.appendChild(explore);
}
// Add Chat view button
var chat = new Element('a',{'class':'exploreToolbarIcon'});
if (from == 'explore') {
chat.style.marginLeft ='20px';
}
chat.href="https://big.evidence-hub.net/chats.php?id="+nodeid;
var image = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/chat.png', 'alt':'Click to view any Chats on this item'});
chat.insert(image);
chat.title = 'Click to view any Chats on this item';
container.appendChild(chat);
if (from == 'chat') {
image.style.border = "1px dashed blue";
}
// Add Linear/tree view button
if (type != 'org' && type != 'project') {
var tree = new Element('a',{'class':'exploreToolbarIcon'});
tree.href="https://big.evidence-hub.net/knowledgetrees.php?id="+nodeid;
var image = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/knowledge-tree2.png', 'alt':'Click to view any Knowledge Trees for this item'});
tree.insert(image);
tree.title = 'Click to view any Knowledge Trees for this item';
container.appendChild(tree);
if (from == 'trees') {
image.style.border = "1px dashed blue";
}
}
// Add Network view button
var net = new Element('a',{'class':'exploreToolbarIcon'});
net.href="https://big.evidence-hub.net/networkgraph.php?id="+nodeid;
var image = new Element('img',{'class':'active','src': 'https://big.evidence-hub.net/images/network-graph.png', 'alt':'Click to view the Network Graph for this item'});
net.insert(image);
net.title = 'Click to view the Network Graph for this item';
container.appendChild(net);
if (from == 'network') {
image.style.border = "1px dashed blue";
}
// Add Debate View button only on Issues
}
function buildChatHeader() {
var keyDiv = new Element("div");
keyDiv.className = 'plainborder col-auto recentReply';
keyDiv.insert('Most Recent Reply');
if (USER != "") {
var toolbar = new Element("div", {'id':'commenttoolbar', 'class':'widgetheaderinner widgetheaderinnerChat row'});
var link = new Element("a", {'title':"Start a new Chat about the current focal item", 'class':'col-auto'});
link.insert(' Start a New Chat');
Event.observe(link,"click", function(){
$('commenthidden').style.display = 'block';
$('commenttoolbar').style.display = 'none';
$('comment').focus();
});
toolbar.insert(link);
toolbar.insert(keyDiv);
$('chattoolbar').update(toolbar);
var hidden = new Element("div", {'class':'widgetheaderinner', 'id':'commenthidden','class':'commentdiv', 'style':'display:none;'});
$('chattoolbar').insert(hidden);
var box = new Element("textarea", {'value':'', 'id':'comment', 'class':'form-control', 'aria-label':'enter comment'});
hidden.insert(box);
var button = new Element("input", {'value':'Add', 'type':'button', 'class':'btn btn-primary m-2 ms-0'});
Event.observe(button,"click", function(){
var comment = $('comment').value;
$('comment').value = "";
$("chatarea").style.display = 'block';
$('commenthidden').style.display = 'none';
$('commenttoolbar').style.display = 'block';
if (comment != "") {
var type = "Comment";
var reqUrl = SERVICE_ROOT + "&method=connectnodetocomment&nodetypename="+type+"&nodeid="+chatnodeid+"&comment="+encodeURIComponent(comment);
new Ajax.Request(reqUrl, { method:'get',
onSuccess: function(transport){
var json = transport.responseText.evalJSON();
if(json.error){
alert(json.error[0].message);
} else {
getAllChatConnections();
}
}
});
}
});
hidden.insert(button);
var button = new Element("input", {'value':'Close', 'type':'button', 'class':'btn btn-secondary m-2'});
Event.observe(button,"click", function(){
$('comment').value = "";
$('chatarea').style.display = 'block';
$('commenthidden').style.display = 'none';
$('commenttoolbar').style.display = 'block';
});
hidden.insert(button);
} else {
var toolbar = new Element("div", {'id':'commenttoolbar', 'class':'widgetheaderinner '});
let spancontent = ' Start a New Chat';
toolbar.insert(spancontent);
toolbar.insert(keyDiv);
$('chattoolbar').insert(toolbar);
}
}
function checkWiderDebateStillLoading(nodetofocusid) {
if (!DEBATE_TREE_SMALL) {
var stillLoading = false;
for(var ind in DEBATE_LOADED_ARRAY){
var next = DEBATE_LOADED_ARRAY[ind];
if (next == false) {
stillLoading = true;
break;
}
}
if (!stillLoading) {
clearTimeout(DEBATE_TIMER);
$('lineardebateheading').innerHTML = "";
checkDebateHasNode(nodetofocusid);
} else {
DEBATE_TIMER = setTimeout("checkWiderDebateStillLoading('"+nodetofocusid+"')", 350);
}
} else {
// should never get here, but just in case;
clearTimeout(DEBATE_TIMER);
}
}
function checkChatStillLoading(nodetofocusid) {
var stillLoading = false;
for(var ind in CHAT_LOADED_ARRAY){
var next = CHAT_LOADED_ARRAY[ind];
if (next == false) {
stillLoading = true;
break;
}
}
if (!stillLoading) {
clearTimeout(CHAT_TIMER);
$('chatloading').update("");
checkChatHasNode();
} else {
CHAT_TIMER = setTimeout("checkChatStillLoading('"+nodetofocusid+"')", 350);
}
}
/**
* Log a known user opeing a chat page
* @param nodeid the id of the node
*/
function logChatUserArrive(nodeid) {
var args = {};
args["nodeid"] = nodeid;
var reqUrl = SERVICE_ROOT + "&method=logchatuserarrive&" + Object.toQueryString(args);
new Ajax.Request(reqUrl, { method:'get',
onSuccess: function(transport){
var json = transport.responseText.evalJSON();
if(json.error){
alert(json.error[0].message);
return;
} else {
//console.log("arrive:"+transport.responseText);
updateCurrentChatUsers(nodeid);
}
}
});
return;
}
/**
* Log a known user closing a chat page
* @param nodeid the id of the node
*/
function logChatUserLeave(nodeid) {
var args = {};
args["nodeid"] = nodeid;
var reqUrl = SERVICE_ROOT + "&method=logchatuserleave&" + Object.toQueryString(args);
new Ajax.Request(reqUrl, { method:'get',
onSuccess: function(transport){
var json = transport.responseText.evalJSON();
if(json.error){
alert(json.error[0].message);
return;
} else {
//console.log("leave:"+transport.responseText);
}
}
});
return;
}
/**
* Get the Chat user presence for the given node
* @param nodeid the id of the node
*/
function updateCurrentChatUsers(nodeid) {
var args = {};
args["nodeid"] = nodeid;
var reqUrl = SERVICE_ROOT + "&method=getchatpresence&" + Object.toQueryString(args);
new Ajax.Request(reqUrl, { method:'get',
onSuccess: function(transport){
var json = transport.responseText.evalJSON();
if(json.error){
alert(json.error[0].message);
return;
} else {
var users = json.userset[0].users;
$('current-chat-users').update("");
displayChatUsers($('current-chat-users'),users,0);
}
}
});
return;
}