var NODE_CONTEXT = 'node';var USER_CONTEXT = 'user';var GLOBAL_CONTEXT = 'global';var EVIDENCE_TYPES = new Array("Anecdote","Interview","Panel","Paper/Publication","Report/White Paper","Talk","Other");var EVIDENCE_TYPES_STR = 'Anecdote,Interview,Panel,Paper/Publication,Report/White Paper,Talk,Other';var EVIDENCE_TYPE_NAMES = new Array("Anecdote","Interview","Panel","Paper/Publication","Report/White Paper","Talk","Other");var EVIDENCE_TYPE_NAMES_SHORT = new Array("Anecdote","Interview","Panel","Paper/Publication","Report/White Paper","Talk","Other");var COMMENT_TYPES = 'Comment';var BASE_TYPES = new Array("Challenge","Issue","Solution","Claim","Organization","Project","Theme");var BASE_TYPES_STR = 'Challenge,Issue,Solution,Claim,Organization,Project,Theme';var RESOURCE_TYPES = new Array("Audio","Video","Slides","Social Networking","Publication","Other Web Resource");var RESOURCE_TYPES_STR = 'Audio,Video,Slides,Social Networking,Publication,Other Web Resource';var RESOURCE_TYPE_NAMES = new Array("Audio","Video","Slides","Social Networking","Publication","Other Web Resource");var RESOURCE_TYPE_NAMES_SHORT = new Array("Audio","Video","Slides","Social Networking","Publication","Other Web Resource");var THEMES = new Array("Data Acquisition","Data Analysis","Data Curation","Data Storage","Data Usage","Energy","Entertainment","Finance","Health","Insurance","Manufacturing","Media","Public Sector","Retail","Telco","Transport");var orgGeoLat=17.383;var orgGeoLong=11.183;var orgGeoZoom=2;var userGeoLat=17.383;var userGeoLong=11.183;var userGeoZoom=2;var userNodeGeoLat=17.383;var userNodeGeoLong=11.183;var userNodeGeoZoom=2;var challengebackpale = '#6FCBF5';var issuebackpale = '#C6ECFE';var solutionbackpale = '#FCD7BE';var claimbackpale = '#F0B288';var orgbackpale = '#A4AED4';var projectbackpale = '#DEE2F0';var peoplebackpale = '#EAECF5';var evidencebackpale = '#DFC7EB';var resourcebackpale = '#E1F1C9';var themebackpale = '#FAB8DA';var plainbackpale = '#D0D0D0';var hasClaim = true;var hasSolution = true;var hasChallenge = true;var hasOpenComment = false;var chatPollingInterval = 60000; /** * Variables */ var URL_ROOT = "https://big.evidence-hub.net/"; var SERVICE_ROOT = URL_ROOT + "api/service.php?format=json"; var USER = ""; var IS_USER_ADMIN = ""; var BUILD_FROM_PERMISSIONS = 'all'; var DATE_FORMAT = 'd/m/yy'; var DATE_FORMAT_PROJECT = 'd mmm yyyy'; var TIME_FORMAT = 'd/m/yy - H:MM'; var SELECTED_LINKTYES = ""; var SELECTED_NODETYPES = ""; var SELECTED_USERS = ""; var IE = 0; var IE5 = 0; var NS = 0; var GECKO = 0; var openpopups = new Array(); /** Store some variables about the browser being used.*/ if (document.all) { // Internet Explorer Detected OS = navigator.platform; VER = new String(navigator.appVersion); VER = VER.substr(VER.indexOf("MSIE")+5, VER.indexOf(" ")); if ((VER <= 5) && (OS == "Win32")) { IE5 = true; } else { IE = true; } } else if (document.layers) { // Netscape Navigator Detected NS = true; } else if (document.getElementById) { // Netscape 6 Detected GECKO = true; } String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } /** * Check to see if the enter key was pressed then fire the onlcik of that item. */ function enterKeyPressed(evt) { var event = evt || window.event; var thing = event.target || event.srcElement; var characterCode = document.all? window.event.keyCode:event.which; if(characterCode == 13) { thing.onclick(); } } /** * Check to see if the enter key was pressed. */ function checkKeyPressed(evt) { var event = evt || window.event; var thing = event.target || event.srcElement; var characterCode = document.all? window.event.keyCode:event.which; if(characterCode == 13) { return true; } else { return false; } } /** * get the anchor (#) value from the url */ function getAnchorVal(defVal){ var url = document.location; var strippedUrl = url.toString().split("#"); if(strippedUrl.length > 1 && strippedUrl[1] != ""){ return strippedUrl[1]; } else { return defVal; } } /** * Update the address parameters for a change in state. */ function updateAddressParameters(args) { if (typeof window.history.replaceState == 'function') { var newUrl = createNewURL(window.location.href, args); //const state = {} //const title = ''; //const url = newUrl; //window.history.pushState(state, title, url); window.history.replaceState("string", "Title", newUrl); } } /** * create a new url based on the current one but with new arguments. */ function createNewURL(url, args, view){ var newURL = ""; // Strip empty parameters to declutter query string var newargs = {}; for(var index in args) { var value = args[index]; // check for an empty value or the title parameter - which does not need displaying in address if (value && value != "" && index != "title") { newargs[index] = value; } } // check for ? otherwise split on # var strippedUrl = url.toString().split("?"); if (strippedUrl.length > 1) { newURL = strippedUrl[0]; } else { newURL = (url.toString().split("#"))[0]; } // if the view is not passed, reappend the original hash // we are just chaning the parameters if (view === undefined) { var bits = url.toString().split("#"); if (bits.length > 1) { view = bits[1]; } } // if the questionmark gets added before the # it casues a page refresh when adding to history if (Object.keys(newargs).length > 0) { newURL += "?"+Object.toQueryString(newargs); } newURL += "#"+view; return newURL; } /** * Open a page in the dialog window */ function loadDialog(windowName, url, width, height){ if (width == null){ width = 570; } if (height == null){ height = 510; } var left = parseInt((screen.availWidth/2) - (width/2)); var top = parseInt((screen.availHeight/2) - (height/2)); var props = "width="+width+",height="+height+",left="+left+",top="+top+",menubar=no,toolbar=no,scrollbars=yes,location=no,status=no,resizable=yes"; //var props = "width="+width+",height="+height+",left="+left+",top="+top+",menubar=no,toolbar=no,scrollbars=yes,location=no,status=yes,resizable=yes"; try { var newWin = window.open(url, windowName, props); if(newWin == null){ alert("You appear to have blocked popup windows.\n\n Please alter your browser settings to allow This Evidence Hub to open popup windows."); } else { newWin.focus(); } } catch(err) { //IE error alert(err.description); } } /** * When closing a child window, reload the page or change the page as required. */ function closeDialog(gotopage){ if(gotopage === undefined){ gotopage="issue-list"; } // try to refresh the parent page try { if (gotopage == "current") { window.opener.location.reload(true); } else if (gotopage == "conn-neighbour" || gotopage == "conn-net") { window.opener.location.reload(true); } else { var wohl = window.opener.location.href; if (wohl) var newurl = URL_ROOT + "user.php#" + gotopage; if(wohl == newurl){ window.opener.location.reload(true); } else { window.opener.location.href = newurl; } } } catch(err) { //do nothing } window.close(); } /** * Set display to 'block' for the item with the given pid */ function showPopup(pid){ $(pid).setStyle({'display':'block'}); } /** * Set display to 'none' for the item with the given pid */ function hidePopup(pid){ $(pid).setStyle({'display':'none'}); } /** * Toggle the given div between display 'block' and 'none' */ function toggleDiv(div) { var div = document.getElementById(div); if (div.style.display == "none") { div.style.display = "block"; } else { div.style.display = "none"; } } function toggleArrowDiv(div, arrow) { if ( $(div).style.display == "block") { $(div).style.display = "none"; $(arrow).src='https://big.evidence-hub.net/images/arrow-down-blue.png'; } else { $(div).style.display = "block"; $(arrow).src='https://big.evidence-hub.net/images/arrow-up-blue.png'; } } /** * Return the height of the current browser page. * Defaults to 500. */ function getWindowHeight(){ var viewportHeight = 500; if (self.innerHeight) { // all except Explorer viewportHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode viewportHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers viewportHeight = document.body.clientHeight; } return viewportHeight; } /** * Return the width of the current browser page. * Defaults to 500. */ function getWindowWidth(){ var viewportWidth = 500; if (self.innerHeight) { // all except Explorer viewportWidth = self.innerWidth; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode viewportWidth = document.documentElement.clientWidth; } else if (document.body) { // other Explorers viewportWidth = document.body.clientWidth; } return viewportWidth; } function getPageOffsetX() { var x = 0; if (typeof(window.pageXOffset) == 'number') { x = window.pageXOffset; } else { if (document.body && document.body.scrollLeft) { x = document.body.scrollLeft; } else if (document.documentElement && document.documentElement.scrollLeft) { x = document.documentElement.scrollLeft; } } return x; } function getPageOffsetY() { var y = 0; if (typeof(window.pageYOffset) == 'number') { y = window.pageYOffset; } else { if (document.body && document.body.scrollTop) { y = document.body.scrollTop; } else if (document.documentElement && document.documentElement.scrollTop) { y = document.documentElement.scrollTop; } } return y; } /** * Return the position of the given element in an x/y array. */ function getPosition(element) { var xPosition = 0; var yPosition = 0; while(element && element != null) { xPosition += element.offsetLeft; xPosition -= element.scrollLeft; xPosition += element.clientLeft; yPosition += element.offsetTop; yPosition += element.clientTop; // Messes up menu positions in Chrome if this is included. // Works fine on all main browsers and Chrome if it is not. // yPosition -= element.scrollTop; //alert(element.id+" :"+"element.offsetTop: "+element.offsetTop+" element.scrollTop :"+element.scrollTop+" element.clientTop :"+element.clientTop); //alert(element.id+" :"+xPosition+":"+yPosition); // if the element is a table, get the parentElement as offsetParent is wrong if (element.nodeName == 'TABLE') { var prevelement = element; var nextelement = element.parentNode; //find a div with any scroll set. while(nextelement != prevelement.offsetParent) { yPosition -= nextelement.scrollTop; xPosition -= nextelement.scrollLeft; nextelement = nextelement.parentNode; } } element = element.offsetParent; } return { x: xPosition, y: yPosition }; } /** * Display the home page text for the nav bar. */ function showHomeNavText(event, type) { var messgeArea = ""; if ($('globalMessage')) { messgeArea = $('globalMessage') } else if ($('resourceMessage')) { messgeArea = $('resourceMessage') } messgeArea.innerHTML=""; var text = ""; if (type == "ChallengesHome") { text += '

Key Challenges connect to Requirements / Issues. This connection explains the Key Challenge has one or more sub problems it can be mapped into (the Requirements / Issues).

'; } else if (type == "IssuesHome") { text += '

Requirements / Issues can be connected to: Key Challenges (left hand connection) and to Technological Capabilities and Research Claims (right hand connection).

The left hand connection explains what higher-level problem the Requirement / Issue is related to.

The right connection to a Technological Capability explains what practical solution has been proposed to address the Requirement / Issue.

The right connection to a Research Claim explains what knowledge statements can be made to address the Requirement / Issue.

'; } else if (type == "EvidenceHome") { text += '

Evidence can be connected to Technological Capabilities/Research Claims (left hand connection) and to Resources (right hand connection).

The left hand connection explains what Technological Capability/Research Claim the Evidence is either supporting or challenging.

The right hand connection explains what Resources (either Web Resources or Research Publications) can be pointed out to endorse the Evidence.

'; } else if (type == "ResourcesHome") { text = '

Resource can be connected to Evidence. This connection explains what Evidence can be distilled from or endorsed by this Resource.

'; } else if (type == "ClaimsHome") { text += '

Research Claims can be connected to Requirements / Issues (left hand connection) and to Evidence (right hand connection).

The left hand connection explains what Requirement / Issue a Research Claim addresses.

The right hand connection explains what Evidence is there that a Research Claim is sound.

'; } else if (type == "SolutionsHome") { text += '

Technological Capabilities can be connected to Requirements / Issues (left hand connection) and to Evidence (right hand connection).

The left hand connection explains what Requirement / Issue a Technological Capability addresses.

The right hand connection explains what Evidence is there that a Technological Capability is working.

'; } else if (type == "OrganisationsHome") { text += '

People/Organizations can be connected to any of the Knowledge categories on the left. People/Organizations can manage one or more Projects and be partnered with other People/Organizations and Projects

'; } else if (type == "ProjectsHome") { text += '

Projects can be connected to any of the Knowledge categories on the left. Projects can be managed by one or more People/Organizations and partnered with other Projects and People/Organizations

'; } if (text != "") { messgeArea.insert(text); showHint(event, 'hgrhint', 10, -10); } } /** * Display the home page text for the given type. */ function showHomeButtonText(evt, type) { var event = evt || window.event; var target = event.target || event.srcElement; if (target.id == 'issueaddhomelink' || target.id == 'solutionaddhomelink' || target.id == 'claimaddhomelink' || target.id == 'evidenceaddhomelink' || target.id == 'signinhome' || target.id == 'signuphome') { return false; } if ($('homebuttonmessagediv').style.display == "block" && type == $('homebuttonmessagelasttype').value) { $('homebuttonmessagediv').style.display = "none"; } else { $('homebuttonmessage').innerHTML=""; $('homebuttonmessagediv').className="plainborder curvedBorder"; var text = ""; if (type == "issue") { $('solutionhomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('evidencehomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('homebuttonmessagediv').className="issueborder curvedBorder"; text += '

Requirements / Issues describe key problems the community has directly added to the Evidence Hub and brought into debate.

An Requirement / Issue should be ideally phrased as question and should be ideally connected to one or more of the Key Challenges the community is trying to address.

Each member of the community can either add a new Requirement / Issue to the Evidence Hub or collaboratively improve an existing Requirement / Issue by adding:

The list of key Requirements / Issues added by the community so far can be explored by clicking on the Requirement / Issue tab.

Within the Requirements / Issues list, Requirements / Issues can also be promoted or demoted, so that the community can express how important they consider each Requirement / Issue to be compared to the other Requirements / Issues the community has raised. Up-green/down-red arrows can be used to promote/demote Requirements / Issues in the list.

'; } else if (type == "solution") { $('issuehomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('evidencehomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('homebuttonmessagediv').className="solutionborder curvedBorder"; text += '

Technological Capabilities and Research Claims are used to answer specific Requirements / Issues and they can be supported or challenged by specific Evidence.

A Technological Capability describes a solution that practitioners within the community have tried out and can report on.
A Research Claim describes specific knowledge statements that people within the community have made or can report on.

Technological Capabilities and Research Claims should be ideally connected to one or more existing Requirements / Issues that have been added to the Evidence Hub.

Each member of the community can add a new Technological Capability or Research Claim to the Evidence Hub or collaboratively improve an existing Technological Capability or Research Claim by adding:

Technological Capabilities and Research Claims have a key role within the Evidence Hub since they frame the topics of the community debate.
The main objective of the Evidence Hub is to promote a community debate around Technological Capabilities and Research Claims. To contribute to this debate each member of the community can add Evidence in favour (Supporting Evidence) or Evidence against (Counter Evidence) to each Technological Capability or Research Claim that has been added to the Evidence Hub.

The list of Technological Capabilities added by the community so far can be explored by clicking on the Technological Capabilities tab.

The list of Research Claims added by the community so far can be explored by clicking on the Research Claims tab.

Within the list of Technological Capabilities and Research Claims, these can also be promoted or demoted, so that the community can express how important they consider each Technological Capability or Research Claim to be compared to the other Technological Capabilities and Research Claims the community has raised. Up-green/down-red arrows can be used to promote/demote Technological Capabilities and Research Claims in the list.

'; } else if (type == "evidence") { $('issuehomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('solutionhomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('homebuttonmessagediv').className="evidenceborder curvedBorder"; text += '

Evidence represents the distillation of the community effort to map what works and what does not work within the community as suggested by practice or by research. As such Evidence are the heart to the Evidence Hub.

Evidence can be one of the following: Anecdote,Interview,Panel,Paper/Publication,Report/White Paper,Talk,Other, that the community has added to the Website.

Ideally Evidence will either support or challenge at least one existing Technological Capability or Research Claim

Each member of the community can either add some new Evidence to the Evidence Hub or collaboratively improve an existing Evidence by adding:

The list of Evidence added by the community so far can be explored by clicking on the Evidence tab.

Within the Evidence List, Evidence can also be promoted or demoted, so that the community can express how important they consider each Evidence to be compared to the other Evidence the community has raised. Up-green/down-red arrows can be used to promote/demote Evidence in the list.

'; } if (text != "") { $('homebuttonmessage').insert(text); $('homebuttonmessagediv').style.display = "block"; } else { alert('** text not found **'); } } $('homebuttonmessagelasttype').value = type; } /** * Display the home page text for the given type. */ function showHomeButtonText2(evt, type) { var event = evt || window.event; var target = event.target || event.srcElement; if (target.id == 'resourceaddhomelink' || target.id == 'orgaddhomelink' || target.id == 'projectaddhomelink' || target.id == 'pstoryaddhomelink' || target.id == 'rstoryaddhomelink' || target.id == 'signinhome' || target.id == 'signuphome') { return false; } if ($('homebuttonmessagediv2').style.display == "block" && type == $('homebuttonmessagelasttype2').value) { $('homebuttonmessagediv2').style.display = "none"; } else { $('homebuttonmessage2').innerHTML=""; $('homebuttonmessagediv2').className="plainborder curvedBorder"; var text = ""; if (type == "resource") { $('orghomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('storyhomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('homebuttonmessagediv2').className="resourceborder curvedBorder"; text += '

Resources are the Publications (URL pointing at Research Papers) or Web Resources (URLs pointing at any other relevant Website) that have been added to the Evidence Hub.

Resources can be used in two main ways:


Each member of the community can either add a new Resource to the Evidence Hub or collaboratively improve an existing Resource by adding:

The list of Resources added by the community so far can be explored by clicking on the Resources tab.

'; } else if (type == "org") { $('resourcehomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('storyhomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('homebuttonmessagediv2').className="orgborder curvedBorder"; text += '

People/Organizations and Projects can be added to the Evidence Hub to map the organizational ecosystem of the community.
The list of People/Organizations/Projects added by the community so far can be explored by clicking on the Person/Organization/Project tab.
Projects and People/Organizations can also be explored by geo-location.

Each member of the community can either add a new Person/Organization or Project to the Evidence Hub, or they can collaboratively improve an existing Person/Organization/Project by adding:
'; } else if (type == "story") { $('resourcehomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('orghomebutton').className="plainbackgradient plainborder curvedBorder homebutton1"; $('homebuttonmessagediv2').className="themeborder curvedBorder"; text += '

Whether you are new to the site, or you want to add a lot of content in one go, or if you are a member of the community and you want to add knowledge on your recent work, then the best way to add content to the Evidence Hub is by adding a \"Practitioner Story\" or a \"Researcher Story\".

A Practitioner/Researcher Story is built by providing answers to the following questions:

Users can add a Story by clicking on Add a Practitioner Story or Add a Reseacher Story.

'; } if (text != "") { $('homebuttonmessage2').insert(text); $('homebuttonmessagediv2').style.display = "block"; } else { alert('** text not found **'); } } $('homebuttonmessagelasttype2').value = type; } /** * Display the home page text for the given type. */ function showHomeButtonText3(evt, type) { if ($('homebuttonmessagediv3').style.display == "block" && type == $('homebuttonmessagelasttype3').value) { $('homebuttonmessagediv3').style.display = "none"; } else { $('homebuttonmessage3').innerHTML=""; $('homebuttonmessagediv3').className="plainborder curvedBorder"; var text = ""; if (type == "challenge") { $('homebuttonmessagediv3').className="challengeborder curvedBorder"; text += '

The community can use Key Challenges as common umbrella questions to cluster the issues they add to the Evidence Hub.

Key Challenges can also be used to cluster projects and organizations under common umbrella problems they tackle.

Finally the community can also contribute to the general description of a Key Challenge by adding Web resources to it.

Key Challenges are identified by the core FP7 BIG Project Evidence Hub team, through analysis of data in the Evidence Hub and in consultation with leading researchers and practitioners in the community. They can be explored under the Key Challenges tab. (hyperlink to the tab)

Key Challenges form a good starting point for exploring the Evidence in the hub.

Key Challenges can be explored by clicking on the Key Challenges tab.

Within the Key Challenges list, Key Challenges can also be promoted or demoted, so that the community can express how important they consider each Key Challenge to be compared to the other Key Challenges the community has raised. Up-green/down-red arrows can be used to promote/demote Key Challenges in the list.

'; } if (text != "") { $('homebuttonmessage3').insert(text); $('homebuttonmessagediv3').style.display = "block"; } else { alert('** text not found **'); } } $('homebuttonmessagelasttype3').value = type; } /** * Display the index page hint for the given type. */ function showGlobalHint(type,evt,panelName) { $(panelName).style.width="400px"; var event = evt || window.event; var messgeArea = ""; if ($('globalMessage')) { messgeArea = $('globalMessage') } else if ($('resourceMessage')) { messgeArea = $('resourceMessage') } messgeArea.innerHTML=""; if (type == "ChallengesTab") { var text = ''; messgeArea.insert(text); } else if (type == "IssuesTab") { var text = ''; messgeArea.insert(text); } else if (type == "SolutionsTab") { var text = ''; messgeArea.insert(text); } else if (type == "ClaimsTab") { var text = ''; messgeArea.insert(text); } else if (type == "EvidenceTab") { var text = ''; messgeArea.insert(text); } else if (type == "ResourcesTab") { var text = ''; messgeArea.insert(text); } else if (type == "OrganizationsTab") { var text = ''; messgeArea.insert(text); } else if (type == "ProjectsTab") { var text = ''; messgeArea.insert(text); }else if (type == "PeopleTab") { var text = '

The Evidence Hub is a community-led, collective intelligence - raise your own questions, propose solutions, add evidence to really benefit from this resource!

To start contributing please create an account

'; messgeArea.insert(text); } else if (type == "MainSearch") { var text = '
The default search will separate words using the spaces and perform an OR search, e.g. \'school system\' will search for the words \'school\' OR \'system\' in either the item title, item description, item tags or any associated web clip texts.

Use a \'+\' between words is you wish to perform an AND search, e.g. \'school+system\' will search for both the words \'school\' and \'system\' somewhere in either the item title, item description, item tags or any associated web clip texts.

Use double quotes around the search string to perform a phrase search, e.g. \"school system\" will search for the exact phrase \'school system\' in either the item title, item description, item tags or any associated web clip texts.
'; messgeArea.insert(text); } showHint(event, panelName, 10, -10); } /** * Display the eplore page hint for the given field type. */ function showExploreHint(type,evt,panelName) { $(panelName).style.width="400px"; var event = evt || window.event; var messgeArea = ""; if ($('globalMessage')) { messgeArea = $('globalMessage') } else if ($('resourceMessage')) { messgeArea = $('resourceMessage') } messgeArea.innerHTML=""; if (type == "Challenges") { var text = ''; messgeArea.insert(text); } else if (type == "Issues") { var text = ''; messgeArea.insert(text); } else if (type == "Solutions") { var text = ''; messgeArea.insert(text); } else if (type == "Claims") { var text = ''; messgeArea.insert(text); } else if (type == "Evidence") { var text = ''; messgeArea.insert(text); } else if (type == "Resources") { var text = ''; messgeArea.insert(text); } else if (type == "Organizations") { var text = ''; messgeArea.insert(text); } else if (type == "Projects") { var text = ''; messgeArea.insert(text); } else if (type == "Themes") { var text = ''; messgeArea.insert(text); } showHint(event, panelName, 10, -10); } function showHintText(evt, text) { var event = evt || window.event; var messgeArea = ""; if ($('globalMessage')) { messgeArea = $('globalMessage') } else if ($('resourceMessage')) { messgeArea = $('resourceMessage') } messgeArea.innerHTML=""; messgeArea.insert(text); $('hgrhint').style.width="220px"; showHint(event, 'hgrhint', 10, -10); } /** * Show a rollover hint popup div (when multiple lines needed). */ function showHint(evt, popupName, extraX, extraY) { hideHints(); var event = evt || window.event; var thing = event.target || event.srcElement; var viewportHeight = getWindowHeight(); var viewportWidth = getWindowWidth(); var panel = document.getElementById(popupName); if (GECKO) { //adjust for it going off the screen right or bottom. var x = event.clientX; var y = event.clientY; if ( (x+panel.offsetWidth+30) > viewportWidth) { x = x-(panel.offsetWidth+30); } else { x = x+10; } if ( (y+panel.offsetHeight) > viewportHeight) { y = y-50; } else { y = y-5; } if (panel) { panel.style.left = x+extraX+window.pageXOffset+"px"; panel.style.top = y+extraY+window.pageYOffset+"px"; panel.style.background = "#FFFED9"; panel.style.visibility = "visible"; openpopups.push(popupName); } } else if (NS) { //adjust for it going off the screen right or bottom. var x = event.pageX; var y = event.pageY; if ( (x+panel.offsetWidth+30) > viewportWidth) { x = x-(panel.offsetWidth+30); } else { x = x+10; } if ( (y+panel.offsetHeight) > viewportHeight) { y = y-50; } else { y = y-5; } document.layers[popupName].moveTo(x+extraX+window.pageXOffset+"px", y+extraY+window.pageYOffset+"px"); document.layers[popupName].bgColor = "#FFFED9"; document.layers[popupName].visibility = "show"; openpopups.push(popupName); } else if (IE || IE5) { //adjust for it going off the screen right or bottom. var x = event.x; var y = event.clientY; if ( (x+panel.offsetWidth+30) > viewportWidth) { x = x-(panel.offsetWidth+30); } else { x = x+10; } if ( (y+panel.offsetHeight) > viewportHeight) { y = y-50; } else { y = y-5; } window.event.cancelBubble = true; document.all[popupName].style.left = x+extraX+ document.documentElement.scrollLeft+"px"; document.all[popupName].style.top = y+extraY+ document.documentElement.scrollTop+"px"; document.all[popupName].style.visibility = "visible"; openpopups[openpopups.length] = popupName; } return false; } function hideHints() { var popupname; for (var i = 0; i < openpopups.length; i++) { popupname = new String (openpopups[i]); if (popupname) { var popup = document.getElementById(popupname); if (popup) { popup.style.visibility = "hidden"; } } } openpopups = new Array(); return; } var popupTimerHandleArray = new Array(); var popupArray = new Array(); function showBox(div) { hideBoxes(); if (popupTimerHandleArray[div] != null) { clearTimeout(popupTimerHandleArray[div]); popupTimerHandleArray[div] = null; } var divObj = document.getElementById(div); divObj.style.display = 'block'; popupArray.push(div); } function hideBox(div) { var popupTimerHandle = setTimeout("reallyHideBox('" + div + "');", 250); popupTimerHandleArray[div] = popupTimerHandle; } function reallyHideBox(div) { var divObj = document.getElementById(div); divObj.style.display = 'none'; } function hideBoxes() { var popupname; for (var i = 0; i < popupArray.length; i++) { popupname = new String (popupArray[i]); var popup = document.getElementById(popupname); if (popup) { popup.style.display = "none"; } } popupArray = new Array(); return; } function radioEvidencePrompt(focalnodeid, filternodetypes, focalnodeend, handler, key, nodetofocusid, promptlabel, selectedOption, refresher) { $('prompttext').innerHTML=""; $('prompttext').style.width = "380px"; $('prompttext').style.height = "140px"; var viewportHeight = getWindowHeight(); var viewportWidth = getWindowWidth(); var x = (viewportWidth-380)/2; var y = (viewportHeight-140)/2; $('prompttext').style.left = x+getPageOffsetX()+"px"; $('prompttext').style.top = y+getPageOffsetY()+"px"; var choicehidden = new Element('input', {'name':'radiopromptchoice','id':'radiopromptchoice','type':'hidden', 'value':'supports'}); $('prompttext').insert(choicehidden); var labelobj = new Element('label', {'style':'padding-bottom:5px;font-weight:bold;font-size:12pt; color:black;'}); labelobj.insert(promptlabel); $('prompttext').insert(labelobj); $('prompttext').insert("
"); $('prompttext').insert("
"); var radio = new Element('input', {'style':'vertical-align:bottom','type':'radio','name':'radioPrompt','value':'supports'}); radio.checked = "checked"; Event.observe(radio,'click', function() { if (this.checked) { $('radiopromptchoice').value = this.value; } }); $('prompttext').insert(radio); $('prompttext').insert('+ Supporting'); $('prompttext').insert("
"); var radio2 = new Element('input', {'style':'vertical-align:bottom','type':'radio','name':'radioPrompt','value':'challenges'}); Event.observe(radio2,'click', function() { if (this.checked) { $('radiopromptchoice').value = this.value; } }); $('prompttext').insert(radio2); $('prompttext').insert('- Countering'); $('prompttext').insert("
"); $('prompttext').insert("
"); var buttonOK = new Element('input', { 'style':'clear: both;margin-top: 5px; font-size: 8pt', 'type':'button', 'value':'Continue'}); Event.observe(buttonOK,'click', function() { var valuechosen = $('radiopromptchoice').value; eval( refresher + '("'+focalnodeid+'","'+filternodetypes+'","'+focalnodeend+'","'+handler+'","'+key+'","'+nodetofocusid+'","'+valuechosen+'")' ); textAreaCancel(); }); var buttonCancel = new Element('input', { 'style':'margin-left: 5px; margin-top: 5px; font-size: 8pt', 'type':'button', 'value':'Cancel'}); Event.observe(buttonCancel,'click', textAreaCancel); $('prompttext').insert(buttonOK); $('prompttext').insert(buttonCancel); $('prompttext').style.display = "block"; } function textAreaCancel() { $('prompttext').style.display = "none"; $('prompttext').update(""); } function textAreaPrompt(messageStr, text, connid, handler, refresher) { $('prompttext').innerHTML=""; $('prompttext').style.width = "400px"; $('prompttext').style.height = "200px"; var viewportHeight = getWindowHeight(); var viewportWidth = getWindowWidth(); var x = (viewportWidth-400)/2; var y = (viewportHeight-200)/2; $('prompttext').style.left = x+getPageOffsetX()+"px"; $('prompttext').style.top = y+getPageOffsetY()+"px"; var textarea1 = new Element('textarea', {'id':'messagetextarea','rows':'10','style':'color: black; width:390px; border: 1px solid gray; padding: 3px; overflow:hidden'}); textarea1.value=text; var buttonOK = new Element('input', { 'style':'clear: both;margin-top: 5px; font-size: 8pt', 'type':'button', 'value':'Publish'}); Event.observe(buttonOK,'click', function() { eval( refresher + '("'+connid+'","'+textarea1.value+'","'+handler+'")' ); textAreaCancel(); }); var buttonCancel = new Element('input', { 'style':'margin-left: 5px; margin-top: 5px; font-size: 8pt', 'type':'button', 'value':'Cancel'}); Event.observe(buttonCancel,'click', textAreaCancel); $('prompttext').insert(textarea1); $('prompttext').insert(buttonOK); $('prompttext').insert(buttonCancel); $('prompttext').style.display = "block"; } function fadeMessage(messageStr) { var viewportHeight = getWindowHeight(); var viewportWidth = getWindowWidth(); var x = (viewportWidth-300)/2; var y = (viewportHeight-100)/2; $('message').style.left = x+getPageOffsetX()+"px"; $('message').style.top = y+getPageOffsetY()+"px"; $('message').update(""); $('message').update(messageStr); $('message').style.display = "block"; fadein(); var fade=setTimeout("fadeout()",2500); } function fadein(){ var element = document.getElementById("message"); element.style.opacity = 0.0; fadeinloop(); } function fadeinloop(){ var element = document.getElementById("message"); element.style.opacity += 0.1; if(element.style.opacity > 1.0) { element.style.opacity = 1.0; } else { setTimeout("fadeinloop()", 100); } } function fadeout(){ var element = document.getElementById("message"); element.style.opacity = 1.0; fadeoutloop(); } function fadeoutloop(){ var element = document.getElementById("message"); element.style.opacity -= 0.1; if(element.style.opacity < 0.0) { element.style.opacity = 0.0; } else { setTimeout("fadeoutloop()", 100); } } function getLoading(infoText){ var loadDiv = new Element("div",{'class':'loading'}); loadDiv.insert("loading"); loadDiv.insert("
"+infoText); return loadDiv; } function getLoadingLine(infoText){ var loadDiv = new Element("div",{'class':'loading'}); loadDiv.insert("loading"); loadDiv.insert(" "+infoText); return loadDiv; } function nl2br (dataStr) { return dataStr.replace(/(\r\n|\r|\n)/g, "
"); } /** * http://www.456bereastreet.com/archive/201105/validate_url_syntax_with_javascript/ * MB: I modified the original as I could not get it to work as it was. */ function isValidURI(uri) { if (!uri) uri = ""; //SERVER SIDE URL VALIDATION //at some point the two should match! //'protocol' => '((http|https|ftp|mailto)://)', //'access' => '(([a-z0-9_]+):([a-z0-9-_]*)@)?', //'sub_domain' => '(([a-z0-9_-]+\.)*)', //'domain' => '(([a-z0-9-]{2,})\.)', //'tld' =>'([a-z0-9_]+)', //'port'=>'(:(\d+))?', //'path'=>'((/[a-z0-9-_.%~]*)*)?', //'query'=>'(\?[^? ]*)?' var schemeRE = /^([-a-z0-9]|%[0-9a-f]{2})*$/i; var authorityRE = /^([-a-z0-9.]|%[0-9a-f]{2})*$/i; var pathRE = /^([-a-z0-9._~:@!$&'()*+,;=\//#]|%[0-9a-f]{2})*$/i; var qqRE = /^([-a-z0-9._~:@!$&'\[\]()*+,;=?\/]|%[0-9a-f]{2})*$/i; var qfRE = /^([-a-z0-9._~:@!$&#'\[\]()*+,;=?\/]|%[0-9a-f]{2})*$/i; var parser = /^(?:([^:\/?]+):)?(?:\/\/([^\/?]*))?([^?]*)(?:\?([^\#]*))?(?:(.*))?/; var result = uri.match(parser); var scheme = result[1] || null; var authority = result[2] || null; var path = result[3] || null; var query = result[4] || null; var fragment = result[5] || null; //alert("scheme="+scheme); //alert("authority="+authority); //alert("path="+path); //alert("query="+query); //alert("fragment="+fragment); if (!scheme || !scheme.match(schemeRE)) { //alert('scheme failed'); return false; } if (!authority || !authority.match(authorityRE)) { //alert('authority failed'); return false; } if (path != null && !path.match(pathRE)) { //alert('path failed'); return false; } if (query && !query.match(qqRE)) { //alert('query failed'); return false; } if (fragment && !fragment.match(qfRE)) { //alert('fragment failed'); return false; } return true; } /** * http://www.wohill.com/javascript-regular-expression-for-url-check/ */ function urlCheck(str) { var v = new RegExp(); v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); if (!v.test(str)) { return false; } return true; } /** * Display explore page in a popup (called by applets). */ function viewNodeDetails(nodeid, nodetype, width, height) { loadDialog('details', URL_ROOT+"explore.php?id="+nodeid, width,height); } /** * Add the given connection object to the given map. * @param c the connection to add (json of connection returned from server). * @param map the name of the map applet to add the data to */ function addConnectionToNetworkMap(c, map) { var fN = c.from[0].cnode; var tN = c.to[0].cnode; var fnRole = c.fromrole[0].role; var fNNodeImage = ""; if (fN.imagethumbnail != null && fN.imagethumbnail != "") { fNNodeImage = URL_ROOT + fN.imagethumbnail; } else if (fN.role[0].role.image != null && fN.role[0].role.image != "") { fNNodeImage = URL_ROOT + fN.role[0].role.image; } var tnRole = c.torole[0].role; var tNNodeImage = ""; if (tN.imagethumbnail != null && tN.imagethumbnail != "") { tNNodeImage = URL_ROOT + tN.imagethumbnail; } else if (tN.role[0].role.image != null && tN.role[0].role.image != "") { tNNodeImage = URL_ROOT + tN.role[0].role.image; } var fromRole = fN.role[0].role.name; var toRole = tN.role[0].role.name; var fromDesc = ""; if (fN.description) { fromDesc = fN.description; } var toDesc = ""; if (tN.description) { toDesc = tN.description; } var fromName = fN.name; var toName = tN.name; // Get HEX for From Role var fromHEX = ""; if (fromRole == 'Challenge') { fromHEX = challengebackpale; } else if (fromRole == 'Issue') { fromHEX = issuebackpale; } else if (fromRole == 'Claim') { fromHEX = claimbackpale; } else if (fromRole == 'Solution') { fromHEX = solutionbackpale; } else if (EVIDENCE_TYPES_STR.indexOf(fromRole) != -1) { fromHEX = evidencebackpale; } else if (fromRole == 'Project') { fromHEX = projectbackpale; } else if (fromRole == 'Organization') { fromHEX = orgbackpale; } else if (fromRole == 'Theme') { fromHEX = themebackpale; } else if (RESOURCE_TYPES_STR.indexOf(fromRole) != -1) { fromHEX = resourcebackpale; } else { fromHEX = plainbackpale; } // Get HEX for To Role var toHEX = ""; if (toRole == 'Challenge') { toHEX = challengebackpale; } else if (toRole == 'Issue') { toHEX = issuebackpale; } else if (toRole == 'Claim') { toHEX = claimbackpale; } else if (toRole == 'Solution') { toHEX = solutionbackpale; } else if (EVIDENCE_TYPES_STR.indexOf(toRole) != -1) { toHEX = evidencebackpale; } else if (toRole == 'Project') { toHEX = projectbackpale; } else if (toRole == 'Organization') { toHEX = orgbackpale; } else if (toRole == 'Theme') { toHEX = themebackpale; } else if (RESOURCE_TYPES_STR.indexOf(toRole) != -1) { toHEX = resourcebackpale; } else { toHEX = plainbackpale; } if (RESOURCE_TYPES_STR.indexOf(fromRole) != -1) { if (fromDesc != "") { var tempName = fromName; fromName = fromDesc; fromDesc = tempName; } } if (RESOURCE_TYPES_STR.indexOf(toRole) != -1) { if (toDesc != "") { var tempName = toName; toName = toDesc; toDesc = tempName; } } fromRole = getNodeTitleAntecedence(fromRole, false); toRole = getNodeTitleAntecedence(toRole, false); //create from & to nodes $(map).addNode(fN.nodeid, fromRole+": "+fromName, fromDesc, fN.users[0].user.userid, fN.creationdate, fN.otheruserconnections, fNNodeImage, fN.users[0].user.thumb, fN.users[0].user.name, fromRole, fromHEX); $(map).addNode(tN.nodeid, toRole+": "+toName, toDesc, tN.users[0].user.userid, tN.creationdate, tN.otheruserconnections, tNNodeImage, tN.users[0].user.thumb, tN.users[0].user.name, toRole, toHEX); // add edge/conn var fromRoleName = fromRole; if (c.fromrole[0].role) { fromRoleName = c.fromrole[0].role.name; } var toRoleName = toRole; if (c.torole[0].role) { toRoleName = c.torole[0].role.name; } var linklabelname = c.linktype[0].linktype.label; linklabelname = getLinkLabelName(fN.role[0].role.name, tN.role[0].role.name, linklabelname); $(map).addEdge(c.connid, fN.nodeid, tN.nodeid, c.linktype[0].linktype.grouplabel, linklabelname, c.creationdate, c.userid, c.users[0].user.name, fromRoleName, toRoleName); } /** * Get the language version of the link label that should be displayed to the users. * Allows for local varients and internationalization. */ function getLinkLabelName(fromNodeTypeName, toNodeTypeName, linkName) { if (RESOURCE_TYPES.indexOf(fromNodeTypeName) != -1 && linkName == 'is related to') { return 'is related to'; } else if (fromNodeTypeName == 'Issue' && toNodeTypeName == 'Challenge') { return 'is related to'; } else if (fromNodeTypeName == 'Claim' && toNodeTypeName == 'Issue') { return 'responds to'; } else if (fromNodeTypeName == 'Solution' && toNodeTypeName == 'Issue') { return 'addresses'; } else if ((fromNodeTypeName == 'Organization' || fromNodeTypeName == 'Project') && toNodeTypeName == 'Issue') { return 'addresses'; } else if ((fromNodeTypeName == 'Organization' || fromNodeTypeName == 'Project') && toNodeTypeName == 'Challenge') { return 'addresses'; } else if ((fromNodeTypeName == 'Organization' || fromNodeTypeName == 'Project') && toNodeTypeName == 'Claim') { return 'claims'; } else if ((fromNodeTypeName == 'Organization' || fromNodeTypeName == 'Project') && toNodeTypeName == 'Solution') { return 'specifies'; } else if ((fromNodeTypeName == 'Organization' || fromNodeTypeName == 'Project') && EVIDENCE_TYPES.indexOf(toNodeTypeName) != -1) { return 'specifies'; } else if (fromNodeTypeName == 'Organization' && toNodeTypeName == 'Project') { return 'manages'; } else if ((fromNodeTypeName == 'Organization' || fromNodeTypeName == 'Project') && (toNodeTypeName == 'Organization' || toNodeTypeName == 'Project') ) { return 'associated with'; } else if (COMMENT_TYPES.indexOf(fromNodeTypeName) != -1) { return 'is related to'; } else if (toNodeTypeName == "Theme" && 'has main theme') { return 'associated with theme'; } else if (EVIDENCE_TYPES.indexOf(fromNodeTypeName) != -1 && (toNodeTypeName == 'Claim' || toNodeTypeName == 'Solution')) { if (linkName == 'supports') { return 'supports'; } else if (linkName == 'challenges') { return 'challenges'; } } else if (linkName == 'see also') { return 'see also'; } return linkName; } /** * Return the node type text to be placed before the node title * @param nodetype the node type for node to return the text for * @param withColon true if you want a colon adding after the node type name, else false. */ function getNodeTitleAntecedence(nodetype, withColon) { if (withColon == undefined) { withColon = true; } var title=""; if (nodetype == 'Challenge') { title = "Key Challenge"; } else if (nodetype == 'Issue') { title = "Requirement / Issue"; } else if (nodetype == 'Claim') { title = "Research Claim"; } else if (nodetype == 'Solution') { title = "Technological Capability"; } else if (nodetype == 'Organization') { title = "Person/Organization"; } else if (nodetype == 'Project') { title = "Project"; } else if (EVIDENCE_TYPES_STR.indexOf(nodetype) != -1) { //EVIDENCE title = "Evidence ("+EVIDENCE_TYPE_NAMES_SHORT[EVIDENCE_TYPES.indexOf(nodetype)]+")"; } else if (RESOURCE_TYPES_STR.indexOf(nodetype) != -1) { //RESOURCES title = "Resource ("+RESOURCE_TYPE_NAMES_SHORT[RESOURCE_TYPES.indexOf(nodetype)]+")"; } else if (nodetype == 'Theme') { title = "Theme"; } else if (nodetype == 'Comment') { title = "Chat"; } else if (nodetype == 'Idea') { title = "Open Comment"; } else if (nodetype == 'News') { title = "News article"; } if (withColon) { title += ": "; } return title; } function createCommentFilter(context, args) { var sbTool = new Element("div", {'class':'mb-3 row'}); sbTool.insert(''); var selectWrap = new Element("div", {'class':'col-sm-5'}); var filterMenu= new Element("select", {'class':'form-select'}); var links = args['filterlist']; var includeunconnected = args['includeunconnected']; var option = new Element("option", {'value':'all'}); if (links == 'built from' && includeunconnected == 'true') { option.selected = true; } option.insert('All Comment'); filterMenu.insert(option); var option = new Element("option", {'value':'used'}); if (links == 'built from' && includeunconnected == 'false') { option.selected = true; } option.insert("Used Comment"); filterMenu.insert(option); var option = new Element("option", {'value':'notbuiltfrom'}); if (links == '' && includeunconnected == 'true') { option.selected = true; } option.insert("Unused Comment"); filterMenu.insert(option); Event.observe(filterMenu,"change", function(){ var type = this.value; if (type == 'notbuiltfrom' && (links != '' || includeunconnected != 'true')) { args['filterlist'] = ""; args['includeunconnected'] = 'true'; refreshComments(context, args); } else if (type == 'used' && (links != 'built from' || includeunconnected != 'false')) { args['filterlist'] = 'built from'; args['includeunconnected'] = 'false'; refreshComments(context, args); } else if (type == 'all' && (links != 'built from' || includeunconnected != 'true')) { args['filterlist'] = 'built from'; args['includeunconnected'] = 'true'; refreshComments(context, args); } }); selectWrap.insert(filterMenu); sbTool.insert(selectWrap); return sbTool; } function gotoHomeList(type) { var reqUrl = 'https://big.evidence-hub.net/index.php?#'+type+'-list'; window.location.href = reqUrl; if (CONTEXT == 'global') { window.location.reload(true); } } function alphanodesort(a, b) { var nameA=a.cnode.name.toLowerCase(); var nameB=b.cnode.name.toLowerCase(); if (nameA < nameB) { return -1; } if (nameA > nameB) { return 1; } return 0 ; } function creationdatenodesortasc(a, b) { var nameA=a.cnode.modificationdate; var nameB=b.cnode.modificationdate; if (nameA < nameB) { return -1; } if (nameA > nameB) { return 1; } return 0 ; } function modedatenodesortasc(a, b) { var nameA=a.cnode.modificationdate; var nameB=b.cnode.modificationdate; if (nameA < nameB) { return -1; } if (nameA > nameB) { return 1; } return 0 ; } function modedatenodesortdesc(a, b) { var nameA=a.cnode.modificationdate; var nameB=b.cnode.modificationdate; if (nameA > nameB) { return -1; } if (nameA < nameB) { return 1; } return 0 ; } /** * Sort by node type in reverse alphabetical order by connections node type. * So we get Solutions then Claims and Pro then Con nodes, Web Resource then Publication */ function connectiontypenodesort(a, b) { var typeA = a.cnode.role[0].role.name.toLowerCase(); var connA = a.cnode.connection; if (connA) { if (a.cnode.nodeid == connA.from[0].cnode.nodeid) { typeA = connA.fromrole[0].role.name.toLowerCase(); } else { typeA = connA.torole[0].role.name.toLowerCase(); } } var typeB = b.cnode.role[0].role.name.toLowerCase(); var connB = b.cnode.connection; if (connB) { if (b.cnode.nodeid == connB.from[0].cnode.nodeid) { typeB = connB.fromrole[0].role.name.toLowerCase(); } else { typeB = connB.torole[0].role.name.toLowerCase(); } } if (typeA > typeB) { return -1; } if (typeA < typeB) { return 1; } return 0; } /** * Sort by node name after a sort by connection node type has been done. * @see connectiontypenodesort */ function connectiontypealphanodesort(a, b) { var nameA=a.cnode.name.toLowerCase(); var nameB=b.cnode.name.toLowerCase(); var typeA = a.cnode.role[0].role.name.toLowerCase(); var connA = a.cnode.connection; if (connA) { if (a.cnode.nodeid == connA.from[0].cnode.nodeid) { typeA = connA.fromrole[0].role.name.toLowerCase(); } else { typeA = connA.torole[0].role.name.toLowerCase(); } } var typeB = b.cnode.role[0].role.name.toLowerCase(); var connB = b.cnode.connection; if (connB) { if (b.cnode.nodeid == connB.from[0].cnode.nodeid) { typeB = connB.fromrole[0].role.name.toLowerCase(); } else { typeB = connB.torole[0].role.name.toLowerCase(); } } if (typeA == typeB) { if (nameA < nameB) { return -1; } else if (nameA > nameB) { return 1; } } return 0; } function removeHTMLTags(htmlString) { var cleanString = ""; if(htmlString){ var mydiv = document.createElement("div"); mydiv.innerHTML = htmlString; if (document.all) { cleanString = mydiv.innerText; } else { cleanString = mydiv.textContent; } } return cleanString.trim(); } /** * Used to switch a textarea between plain text and full HTML editor box. */ function switchCKEditorMode(link, divname, editorname) { if ($(divname).style.clear == 'none') { CKEDITOR.replace(editorname, { on : { instanceReady : function( ev ) { this.focus(); } } } ); $(divname).style.clear = 'both'; link.innerHTML = 'Plain text' link.title = 'Switch to a plain text. Formatting will be lost.'; } else { var ans = confirm("Are you sure you want to switch to plain text? Warning: All Formatting will be lost."); if (ans == true) { if (CKEDITOR.instances[editorname]) { CKEDITOR.instances[editorname].destroy(); } $(divname).style.clear = 'none'; link.innerHTML = 'Formatting'; link.title = 'Show formatting toolbar.'; $(editorname).value = removeHTMLTags($(editorname).value); } } } function htmlspecialchars_decode (string, quote_style) { // http://kevin.vanzonneveld.net // + original by: Mirek Slugen // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfixed by: Mateusz "loonquawl" Zalega // + input by: ReverseSyntax // + input by: Slawomir Kaniecki // + input by: Scott Cariss // + input by: Francois // + bugfixed by: Onno Marsman // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfixed by: Brett Zamir (http://brett-zamir.me) // + input by: Ratheous // + input by: Mailfaker (http://www.weedem.fr/) // + reimplemented by: Brett Zamir (http://brett-zamir.me) // + bugfixed by: Brett Zamir (http://brett-zamir.me) // * example 1: htmlspecialchars_decode("

this -> "

", 'ENT_NOQUOTES'); // * returns 1: '

this -> "

' // * example 2: htmlspecialchars_decode("&quot;"); // * returns 2: '"' var optTemp = 0, i = 0, noquotes = false; if (typeof quote_style === 'undefined') { quote_style = 2; } string = string.toString().replace(/</g, '<').replace(/>/g, '>'); var OPTS = { 'ENT_NOQUOTES': 0, 'ENT_HTML_QUOTE_SINGLE': 1, 'ENT_HTML_QUOTE_DOUBLE': 2, 'ENT_COMPAT': 2, 'ENT_QUOTES': 3, 'ENT_IGNORE': 4 }; if (quote_style === 0) { noquotes = true; } if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags quote_style = [].concat(quote_style); for (i = 0; i < quote_style.length; i++) { // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4 if (OPTS[quote_style[i]] === 0) { noquotes = true; } else if (OPTS[quote_style[i]]) { optTemp = optTemp | OPTS[quote_style[i]]; } } quote_style = optTemp; } if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) { string = string.replace(/�*39;/g, "'"); // PHP does not currently escape if more than one 0, but it should // string = string.replace(/'|�*27;/g, "'"); // This would also be useful here, but not a part of PHP } if (!noquotes) { string = string.replace(/"/g, '"'); } // Put this in last place to avoid escape being double-decoded string = string.replace(/&/g, '&'); return string; } /** * Replacing function from Scriptaculous. Can now be done with css. * Highlight an element transitioning between two highlight colours and finally restore it to a given colour. * @param item, the item to tranition the background colour on. * @param options, the options to use - object containing 'startcolor', 'endcolor', 'restorecolor', 'duration' */ function highlightElement(item, options) { // Prevent executing on elements not in the layout flow if (item.style.display == 'none') { return; } if (!options.restorecolor) options.restorecolor = item.style.backgroundColor; item.style.backgroundColor = options['startcolor']; item.style.webkitTransform = 'background-color '+options.duration+'s linear'; item.style.MozTransform = 'background-color '+options.duration+'s linear'; item.style.msTransform = 'background-color '+options.duration+'s linear'; item.style.OTransform = 'background-color '+options.duration+'s linear'; item.style.transition = 'background-color '+options.duration+'s linear'; // Needed so that initial color and transition are applied before the transition is later triggered. setTimeout(function() { highlightElementComplete(item, options); }, 100); } function highlightElementComplete(item, options) { // trigger transition item.style.backgroundColor = options['endcolor']; // Put it all back to normal about when transition should end plus a bit. var totalwait = parseInt((options.duration+1) * 1000); //convert seconds to milliseconds setTimeout(function() { item.style.transition = 'none'; item.style.webkitTransform = 'none'; item.style.MozTransform = 'none'; item.style.msTransform = 'none'; item.style.OTransform = 'none'; item.style.backgroundColor = options['restorecolor']; },totalwait); } /** * Add new new Script tag to the current HTML page dynamically to load a local javascript file on demand. * * @param url The url to add as the src on the new script tag * @param id If given set as the id of the new script tag */ function addScriptDynamically(url, id) { // only allow the import of local code; if (url.indexOf(URL_ROOT) == 0) { var headarea = document.getElementsByTagName("head").item(0); var scriptobj = document.createElement("script"); scriptobj.setAttribute("type", "text/javascript"); scriptobj.setAttribute("src", url); if (id) { scriptobj.setAttribute("id", id); } headarea.appendChild(scriptobj); } }