/uicore.js
JavaScript | 7673 lines | 7012 code | 160 blank | 501 comment | 1687 complexity | 1f0bb185a9c9979085d4493dc3b31445 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- /*
- uicore implementation in javascript
- primarily used for maprooms */
- /* uicoreConfig ( -- ) possible parameters and settings. Can be set
- in different files, so a bit careful in coding.
- */
- var uicoreConfig = uicoreConfig || {};
- /* resolutionQueryServers ( -- ) server used to resolve resolution
- queries for a particular uri -- normally starts empty */
- if(!uicoreConfig.resolutionQueryServers){
- uicoreConfig.resolutionQueryServers = {};
- }
- /* to change the GoogleAnalyticsId, redefine this after uicore.js */
- /* uicoreConfig.GoogleAnalyticsId='UA-xxxxx-xx'; */
- /* to set the help e-mail, redefine this after uicore.js
- uicoreConfig.helpemail='help@iri.columbia.edu'; */
- uicoreConfig.helpemail='';
- /* DL site name */
- uicoreConfig.SiteName="Data Library";
- /* to add a server for a new resolution, run something like the following */
- uicoreConfig.resolutionQueryServers["irids:SOURCES:Ethiopia:Features:Forecast:kiremt_2013:ds"] = "http://www.ethiometmaprooms.gov.et:8082/";
- /* additional default uicoreConfig settings */
- uicoreConfig.resolutionQueryServers["default"]= "https://iridl.ldeo.columbia.edu/";
- uicoreConfig.resolutionQueryServers["irids:SOURCES:TMA:Features:Forecast:vuli_2013:ds"]= "http://maproom.meteo.go.tz/";
- /* to change json used for setting preferred language on multi-language pages, reset this */
- uicoreConfig.languageSettingDocument="/uicore/toolinfo/buttoninfo.json";
- /*
- Multiple File Load (.js and .css)
- This is the basic check that all the needed js files are loaded
- asynchrously before executing.
- jsAllLoading() is run at the end if all the files are loaded,
- otherwise it waits for the missing files.
- $.ready runs a function at DOMContentLoaded if possible, otherwise onload
- runs immediately if already loaded. It is invoked at the end of this file.
- */
- window.$ = {};
- $.ready = function(fn) {
- if (jsAllLoaded()){
- return fn();
- }
- jsAllLoadedFn = fn;
- if (!(document.readyState == "complete" )){
- if (window.addEventListener) {
- window.addEventListener("DOMContentLoaded", jsAllLoadedRun, false);
- window.addEventListener("load", jsAllLoadedRun, false);
- }
- else if (window.attachEvent){
- window.attachEvent("onload", jsAllLoadedRun);
- }
- else{
- window.onload = jsAllLoadedRun;
- }
- }
- if (jsAllLoaded()){
- return fn();
- }
- }
- var FBloaded=false;
- var jsDependsOnList = new Array();
- var jsAllLoadedFn = null;
- jsDependsOnList.push(document);
- /*
- jsDependsOn ( srcfile -- ) adds to the list of files that must be
- loaded before execution.
- */
- function jsDependsOn(srcfile){
- var s=document.getElementsByTagName('script')[0];
- var po = document.createElement('script');
- po.type = 'text/javascript';
- if(typeof srcfile == "object"){
- for(var key in srcfile){
- po.setAttribute(key,srcfile[key]);
- }
- }
- else {
- po.src = srcfile;
- }
- po.onload = jsLoaded;
- po.onreadystatechange = jsLoaded;
- po.myevtfn = jsLoaded;
- if(! po.readyState) po.readyState = "loadingScript";
- jsDependsOnList.push(po);
- s.parentNode.insertBefore(po,s);
- }
- /* jsAllLoaded ( -- boolean ) returns true if all files have been
- loaded.
- */
- function jsAllLoaded() {
- var ans = true;
- for (var i=0; i<jsDependsOnList.length; i++){
- if(jsDependsOnList[i].readyState && (!(jsDependsOnList[i].readyState === 'interactive' && !!document.getElementsByTagName('body')[0])) && jsDependsOnList[i].readyState != 'loaded' && jsDependsOnList[i].readyState != 'complete'){ans=false;}
- }
- return ans;
- }
- function jsLoaded (evt) {
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- if(it && it.readyState == 'loadingScript'){
- it.readyState="complete";
- }
- jsAllLoadedRun();
- }
- var jsAllLoadedNotRun = true;
- function jsAllLoadedRun(){
- if(jsAllLoadedNotRun && jsAllLoaded()){
- if(!!jsAllLoadedFn){
- jsAllLoadedNotRun = false;
- jsAllLoadedFn();
- }
- }
- }
- /*
- To simplify writing maproom documents, and accessing them locally,
- from test locations, and from the server, urls that start /maproom/
- are prepending with the document root, as long as the urls are processed
- by the maproom javascript code.
- maproomroot: holds the document root
- localHrefOf: converts a /maproom/ reference to be relative to the current document
- */
- var IE8=(navigator.appVersion.indexOf('MSIE 8')>=0);
- var slist=document.getElementsByTagName('script');
- var scriptsrc='';
- for (var i=0; i<slist.length; i++){
- var shref=slist[i].src;
- if(shref.substr(shref.length-9,9) == 'uicore.js'){
- scriptsrc=shref;
- break;
- }
- }
- var scriptroot;
- if(scriptsrc){
- scriptroot = scriptsrc.substr(0,scriptsrc.indexOf('uicore.js'));
- }
- /* google api (gdrive) */
- jsDependsOn({"src": "https://apis.google.com/js/platform.js",
- "async": "",
- "defer": ""});
- /* loads pure javascript */
- var puredir = scriptroot.substr(0,scriptroot.length-7) + 'pure/libs/';
- jsDependsOn(puredir + 'pure.js');
- jsDependsOn(puredir + 'jquery.js');
- /* loads jsonld javascript */
- jsDependsOn(scriptroot.substr(0,scriptroot.length-7) + 'jsonld/jsonld.js');
- var ifmaproomroot = document.location.href.lastIndexOf('/maproom/');
- var maproomroot = document.location.href.substr(0,document.location.href.lastIndexOf('/maproom/')+9);
- function localHrefOf(ghref){
- var lhref;
- var ifmap=-1;
- var ifscript=-1;
- if(ghref){
- ifmap = ghref.lastIndexOf('/maproom/');
- ifscript = ghref.lastIndexOf('/uicore/');
- }
- if(ifmaproomroot > -1 && ifmap > -1){
- var maproomurl = ghref.substr(0,ifmap+9);
- lhref = maproomroot + ghref.substr(maproomurl.length);
- }
- else if(ifscript > -1){
- var scripturl = ghref.substr(0,ifscript+8);
- lhref = scriptroot + ghref.substr(scripturl.length);
- }
- else {
- lhref= ghref;
- }
- if(lhref && lhref.substr(0,1) == '/'){
- lhref = location.protocol + '//' + location.host + lhref;
- }
- return lhref;
- }
- /* some javascript functions might be missing */
- /* replacement for getElementsByClassName when missing */
- if (typeof document.getElementsByClassName!='function') {
- document.getElementsByClassName = function() {
- var elms = this.getElementsByTagName('*');
- var ei = new Array();
- for (i=0;i<elms.length;i++) {
- if (elms[i].getAttribute('class')) {
- ecl = elms[i].getAttribute('class').split(' ');
- for (j=0;j<ecl.length;j++) {
- if (ecl[j].toLowerCase() == arguments[0].toLowerCase()) {
- ei.push(elms[i]);
- }
- }
- } else if (elms[i].className) {
- ecl = elms[i].className.split(' ');
- for (j=0;j<ecl.length;j++) {
- if (ecl[j].toLowerCase() == arguments[0].toLowerCase()) {
- ei.push(elms[i]);
- }
- }
- }
- }
- return ei;
- }
- Element.prototype.getElementsByClassName=document.getElementsByClassName;
- }
- /* IE 8 is missing hasOwnProperty for Elements */
- if(!Element.prototype.hasOwnProperty){
- Element.prototype.hasOwnProperty=Object.prototype.hasOwnProperty;
- }
- if(typeof [].indexOf != 'function'){
- Array.prototype.indexOf = function(obj, start) {
- for (var i = (start || 0), j = this.length; i < j; i++) {
- if (this[i] === obj) { return i; }
- }
- return -1;
- }
- }
- // Add ECMA262-5 Array methods if not supported natively
- //
- if (!('indexOf' in Array.prototype)) {
- Array.prototype.indexOf= function(find, i /*opt*/) {
- if (i===undefined) i= 0;
- if (i<0) i+= this.length;
- if (i<0) i= 0;
- for (var n= this.length; i<n; i++)
- if (i in this && this[i]===find)
- return i;
- return -1;
- };
- }
- if (!('lastIndexOf' in Array.prototype)) {
- Array.prototype.lastIndexOf= function(find, i /*opt*/) {
- if (i===undefined) i= this.length-1;
- if (i<0) i+= this.length;
- if (i>this.length-1) i= this.length-1;
- for (i++; i-->0;) /* i++ because from-argument is sadly inclusive */
- if (i in this && this[i]===find)
- return i;
- return -1;
- };
- }
- if (!('forEach' in Array.prototype)) {
- Array.prototype.forEach= function(action, that /*opt*/) {
- for (var i= 0, n= this.length; i<n; i++)
- if (i in this)
- action.call(that, this[i], i, this);
- };
- }
- if (!('map' in Array.prototype)) {
- Array.prototype.map= function(mapper, that /*opt*/) {
- var other= new Array(this.length);
- for (var i= 0, n= this.length; i<n; i++)
- if (i in this)
- other[i]= mapper.call(that, this[i], i, this);
- return other;
- };
- }
- if (!('filter' in Array.prototype)) {
- Array.prototype.filter= function(filter, that /*opt*/) {
- var other= [], v;
- for (var i=0, n= this.length; i<n; i++)
- if (i in this && filter.call(that, v= this[i], i, this))
- other.push(v);
- return other;
- };
- }
- if (!('every' in Array.prototype)) {
- Array.prototype.every= function(tester, that /*opt*/) {
- for (var i= 0, n= this.length; i<n; i++)
- if (i in this && !tester.call(that, this[i], i, this))
- return false;
- return true;
- };
- }
- if (!('some' in Array.prototype)) {
- Array.prototype.some= function(tester, that /*opt*/) {
- for (var i= 0, n= this.length; i<n; i++)
- if (i in this && tester.call(that, this[i], i, this))
- return true;
- return false;
- };
- }
- /* dohomesel ( evt -- ) event function to handle home menu select.*/
- function dohomesel(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var opt=it.options[it.selectedIndex];
- var fullpathname = document.location.href;
- var optvalue = opt.value;
- var optpath = optvalue.replace(/\?.*/,'');
- if(optpath == location.pathname){
- var optclass = "share carryLanguage";
- }
- else {
- var optclass = "carryup carryLanguage";
- }
- if(optvalue){
- /* _gaq.push(['_trackSocial', 'HomeMenu', opt.innerHTML]); */
- ga('send','social', 'HomeMenu', opt.innerHTML,location.href);
- var url = appendPageForm(optvalue,optclass,false,true);
- document.location.href=url;
- }
- }
- /* dosectionsel ( -- ) function to handle mapselect menu */
- function dosectionsel(){
- it=document.getElementById('mapselect');
- if(it.options[it.selectedIndex].parentNode.label){
- it.parentNode.getElementsByTagName('legend')[0].innerHTML=it.options[it.selectedIndex].parentNode.label;}
- it.previousSibling.innerHTML=it.options[it.selectedIndex].innerHTML;
- var opt=it.options[it.selectedIndex];
- var fullpathname = document.location.href;
- var optvalue = opt.value;
- var optclass="carry";
- if(optvalue.indexOf('@')>0){
- optclass = optvalue.split('@')[1];
- optvalue = optvalue.split('@')[0];
- }
- if(optvalue.substring(0,5)!='http:'){
- if(fullpathname.indexOf("?")>= 0){
- fullpathname = fullpathname.substring(0,fullpathname.indexOf("?"));
- }
- if(fullpathname.indexOf("#")>= 0){
- fullpathname = fullpathname.substring(0,fullpathname.indexOf("#"));
- }
- if (it.hrefroot + optvalue != fullpathname){
- submitPageForm(it.hrefroot + optvalue,optclass);
- }
- } else {
- submitPageForm(optvalue,optclass);
- }
- }
- /* functions for handling events needed for the grid controls */
- /* limitclickevent ( evt -- ) handles first/last limit click for grid
- controls. */
- function limitclickevent(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var myinput = it.parentNode.getElementsByTagName('input')[0];
- var last = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'].length-1;
- myinput.value=it.innerHTML;
- var c0 = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'].indexOf(myinput.value);
- if(c0 == 0){
- myinput.guessvalue=it.parentNode.info['iridl:gridvalues']['iridl:valuelist'][1];
- }
- if(c0 == last){
- myinput.guessvalue=it.parentNode.info['iridl:gridvalues']['iridl:valuelist'][last-1];
- }
- if(!evt.currentTarget){
- evt.currentTarget=this;
- }
- imageinputvaluechange(evt);
- }
- /* stepupclickevent ( evt -- ) handles step up click for grid
- controls. */
- function stepupclickevent(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var myinput = it.parentNode.getElementsByTagName('input')[0];
- var cin = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'].indexOf(myinput.value);
- if(cin > -1 && cin < it.parentNode.info['iridl:gridvalues']['iridl:valuelist'].length-1) {
- myinput.value = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'][cin+1];
- if(cin < it.parentNode.info['iridl:gridvalues']['iridl:valuelist'].length-2) {
- myinput.guessvalue = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'][cin+2];
- }
- if(!evt.currentTarget){
- evt.currentTarget=this;
- }
- imageinputvaluechange(evt);
- }
- }
- /* stepdownclickevent ( evt -- ) handles step down click for grid
- controls. */
- function stepdownclickevent(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var myinput = it.parentNode.getElementsByTagName('input')[0];
- var cin = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'].indexOf(myinput.value);
- if(cin >0) {
- myinput.value = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'][cin-1];
- if(cin > 1) {
- myinput.guessvalue = it.parentNode.info['iridl:gridvalues']['iridl:valuelist'][cin-2];
- }
- if(!evt.currentTarget){
- evt.currentTarget=this;
- }
- imageinputvaluechange(evt);
- }
- }
- /* imageimputvaluechange ( evt -- ) handles explicit value change for grid
- controls. */
- function imageinputvaluechange(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var myinput = it.parentNode.getElementsByTagName('input')[0];
- var myimage = it.parentNode.mylink.figureimage;
- // copy value(s) to page form and get url
- var pform=document.getElementById('pageform');
- var guess='';
- if(myinput.guessvalue){
- pform.elements[myinput.name].value = myinput.guessvalue;
- // guess = appendPageForm(myimage.src,myimage.className);
- guess = myinput.guessvalue;
- myinput.guessvalue='';
- }
- updatePageForm(pform.elements[myinput.name],myinput.value,guess);
- // pform.elements[myinput.name].value = myinput.value;
- // myimage.src = appendPageForm(myimage.src,myimage.className);
- // if(guess){
- // preload(guess);
- // }
- }
- /* tab events */
- /* tabclickevent ( evt -- ) click on tab (select tab) and shift click
- on tab (multiple active tabs if screen is large) . */
- function tabclickevent(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- if (!it) {it = evt.srcElement.parentNode;}
- if(evt.shiftKey){
- toggleClass(it,'toggle');
- if(it.children[0] && it.children[0].hash){
- if(it.className.indexOf('toggle')<0){
- var tlists = decodeURIComponent(getCookie('toggletabs'));
- var tlist = tlists.split(' ');
- tlists='';
- var delim='';
- for(var i=0; i<tlist.length; i++){
- if(tlist[i] != it.children[0].hash){
- tlists = tlists + delim + tlist[i];
- delim=' ';
- }
- }
- document.cookie='toggletabs' + '=' + encodeURIComponent(tlists) + "; path=/";
- }
- else {
- var tlist = decodeURIComponent(getCookie('toggletabs'));
- tlist = tlist + ' ' + it.children[0].hash;
- document.cookie='toggletabs' + '=' + encodeURIComponent(tlist) + "; path=/";
- }
- }
- }
- if(makeTabActive(it,true)){
- if(history && history.pushState && it.children[0].pathname == location.pathname){
- var url = it.children[0].hash;
- if(it.className.indexOf("ui-state-active") < 0){
- var mylist=it.parentNode.getElementsByClassName("ui-state-active");
- if(mylist.length > 0){
- url = mylist[0].children[0].hash;
- }
- }
- if(url){
- var mylabel = it.children[0].innerText;
- var mytitle = document.title;
- if(mylabel){
- mytitle=addTabToTitle(mylabel);
- }
- else {
- mylabel = url.substr(1);
- }
- history.pushState(url,mytitle,url);
- document.title=mytitle;
- ga('send','social', 'Tabs', mylabel, window.location.href);
- }
- }
- refreshConnectedGraphs();
- }
- return false;
- }
- function makeSubTabActive(tab,ifclick){
- var iftoggle=ifclick && ($(tab).css('float') == 'right');
- var ifchange=iftoggle || (tab.className.indexOf("ui-state-active") <0);
- if(iftoggle){
- var sid="";
- if(tab.children[0].pathname==location.pathname && tab.children[0].hash){
- sid = tab.children[0].hash.substr(1);
- }
- else {
- location.href = tab.children[0].href;
- }
- if(tab.className.indexOf("ui-state-active") >=0){
- changeClass(tab,"ui-state-active","ui-state-default");
- if(sid && document.getElementById(sid)){
- document.getElementById(sid).className="ui-tabs-panel-hidden";
- }
- }
- else {
- changeClass(tab,"ui-state-default","ui-state-active");
- if(sid && document.getElementById(sid)){
- document.getElementById(sid).className="ui-tabs-panel-float";
- var mypanel = document.getElementById(sid);
- var myset = mypanel.parentNode;
- var togglelist = tab.parentNode.getElementsByClassName("toggle");
- var insertAfter=myset.firstElementChild;
- for(var j=0; j<togglelist.length ; j++){
- var tsid = togglelist[j].firstElementChild.hash.substr(1);
- var tpanel = document.getElementById(tsid);
- if(tpanel){
- myset.insertBefore(tpanel,insertAfter.nextElementSibling);
- insertAfter=tpanel;
- }
- }
- }
- }
- }
- else {
- var mylist=tab.parentNode.getElementsByClassName("ui-state-active");
- for (var i= 0; i<mylist.length; i++){
- var sid;
- if(!(ifclick && $(mylist[i]).css('float') == 'right')){
- if(mylist[i].children[0].hash){
- sid = mylist[i].children[0].hash.substr(1);
- }
- if(sid && document.getElementById(sid)){
- document.getElementById(sid).className="ui-tabs-panel-hidden";
- }
- changeClass(mylist[i],"ui-state-active","ui-state-default");
- }
- }
- changeClass(tab,"ui-state-default","ui-state-active");
- var sid="";
- if(tab.children[0].pathname==location.pathname && tab.children[0].hash){
- sid = tab.children[0].hash.substr(1);
- }
- if(sid && document.getElementById(sid)){
- document.getElementById(sid).className="ui-tabs-panel";
- }
- else {
- location.href= tab.children[0].href;
- }
- if(document.width < 750){
- location.href= tab.children[0].href;
- }
- }
- return ifchange;
- }
- function makeTabActive(tab,ifclick){
- var ifchange=makeSubTabActive(tab,ifclick);
- makeTabParentActive(tab.parentNode);
- return ifchange;
- };
- function addTabToTitle(myadd){
- var newtitle = document.title.replace(/:.*$/,"") + ": " + myadd;
- return(newtitle);
- }
- function makeTabParentActive(tabnode){
- if(tabnode.className=="ui-tabs-panel-hidden"){
- var myid = tabnode.id;
- if(myid){
- var myhash = '#' + myid;
- makeTabActiveFromHash(myhash,true);
- }
- }
- else {
- if(tabnode.parentNode){
- makeTabParentActive(tabnode.parentNode);
- }
- }
- }
- /* getTabParent -- gets first object or parent that is a tab -- starts with the object */
- function getTabParent(tabnode){
- if(tabnode.className=="ui-tabs-panel-hidden" || tabnode.className=="ui-tabs-panel"){
- return(tabnode);
- }
- else {
- if(tabnode.parentNode){
- return(getTabParent(tabnode.parentNode));
- }
- }
- }
- function tabtarget(evt){
- var ret = (document.width < 750);
- evt = (evt) ? evt : ((event) ? event : null );
- if (evt) {
- if(ret){
- if(evt.returnValue){
- evt.returnValue="false";
- }
- }
- }
- return(ret);
- }
- /* tabsSetup ( -- ) set up tabs. */
- function tabsSetup(){
- var mylist=document.getElementsByClassName("ui-tabs");
- var togglelist=decodeURIComponent(getCookie('toggletabs')).split(' ');
- var togglehash={};
- for(var i=0;i<togglelist.length; i++){
- togglehash[togglelist[i]]=true;
- }
- for (var i= 0; i<mylist.length; i++){
- var tabset=mylist[i];
- var tablist;
- if(tabset.getElementsByClassName("ui-tabs-nav")[0]){
- tablist=tabset.getElementsByClassName("ui-tabs-nav")[0].getElementsByTagName("li");
- }
- else {
- tablist=[];
- }
- var activetab=0;
- for (var j=0; j<tablist.length; j++){
- if(tablist[j].className.indexOf('ui-state-active')>=0)activetab=j
- }
- for (var j=0; j<tablist.length; j++){
- var atab=tablist[j];
- if(atab.children[0] && atab.children[0].hash && togglehash[atab.children[0].hash]){
- appendMissingClass(atab,'toggle');
- }
- if(!atab.children[0].onclick) {
- atab.onclick=tabclickevent;
- atab.myonclick=tabclickevent;
- if(j != activetab){
- appendMissingClass(atab,'ui-state-default');
- var sid = atab.children[0].hash.substr(1);
- if(!!sid){
- if(document.getElementById(sid)){
- document.getElementById(sid).className="ui-tabs-panel-hidden";
- }
- }
- }
- else {
- appendMissingClass(atab,'ui-state-active');
- var sid = atab.children[0].hash.substr(1);
- if(!!sid){
- if(document.getElementById(sid))
- {document.getElementById(sid).className="ui-tabs-panel";}
- }
- }
- atab.children[0].onclick=tabtarget;
- }
- }
- }
- if(window.location.hash){
- makeTabActiveFromHash(window.location.hash);
- }
- }
- /* makeTabActiveFromHash ( hash flag -- ) makes tab active using the
- hash from the url */
- function makeTabActiveFromHash (myhash,dontClearChildren){
- var mytab="";
- if(myhash){
- var myid = myhash.substr(1);
- var myobject = document.getElementById(myid);
- if(!dontClearChildren){
- if(myobject){
- clearTabActive(myobject.getElementsByClassName('ui-tabs-nav'));
- }
- }
- if(myobject){
- var mypanel=getTabParent(myobject);
- if(mypanel){
- var myphash = '#' + mypanel.id;
- mytabsets = document.getElementsByClassName('ui-tabs-nav');
- for(var i=mytabsets.length;i--;){
- var mytabset=mytabsets[i];
- var mytabs=mytabset.getElementsByTagName('li');
- for(var j=mytabs.length;j--;){
- if(mytabs[j].children[0].hash == myphash){
- makeTabActive(mytabs[j],true);
- mytab = mytabs[j];
- }
- }
- }
- }
- }
- }
- return(mytab);
- }
- /* clearTabActive ( tabsets -- ) clears active tabs. */
- function clearTabActive (mytabsets){
- if(!mytabsets){
- mytabsets = document.getElementsByClassName('ui-tabs-nav');
- }
- for(var i=mytabsets.length;i--;){
- var mytabset=mytabsets[i];
- var mytabs=mytabset.getElementsByTagName('li');
- if(mytabs.length && mytabs[0].children[0].hash){
- makeSubTabActive(mytabs[0],false);
- }
- }
- }
- /* insertcontactus ( -- ) insert contactus element. */
- function insertcontactus(){
- var s = document.getElementById('contactus');
- if(s){
- var sl = s.getElementsByTagName('legend');
- if(!sl.length){
- var lls=document.createElement('legend');
- appendMissingClass(lls,'langgroup');
- s.insertBefore(lls,s.firstChild);
- ls=document.createElement('span');
- ls.setAttribute('lang','es');
- ls.appendChild(document.createTextNode('Contáctenos'));
- lls.insertBefore(ls,lls.firstChild);
- ls=document.createElement('span');
- ls.setAttribute('lang','fr');
- ls.appendChild(document.createTextNode('Contactez Nous'));
- lls.insertBefore(ls,lls.firstChild);
- ls=document.createElement('span');
- ls.setAttribute('lang','ru');
- ls.appendChild(document.createTextNode('Контактная информация'));
- lls.insertBefore(ls,lls.firstChild);
- ls=document.createElement('span');
- ls.setAttribute('lang','en');
- ls.appendChild(document.createTextNode('Contact Us'));
- lls.insertBefore(ls,lls.firstChild);
- updateLangGroups(s);
- }
- sl = document.getElementById('googleplus');
- if(!sl){
- var tumblr_button;
- if(uicoreConfig.helpemail){
- /* code to add Mail-help buttons */
- gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='helpmailbutton';
- tumblr_button = document.createElement("a");
- tumblr_button.onclick=doHelpMail;
- tumblr_button.setAttribute("title", uicoreConfig.helpemail);
- gb.appendChild(tumblr_button);
- s.appendChild(gb);
- }
- }
- }
- }
- function insertshare(){
- insertcontactus();
- var s = document.getElementById('share');
- if(s){
- var sl = s.getElementsByTagName('legend');
- if(!sl.length){
- var ls=document.createElement('legend');
- ls.appendChild(document.createTextNode('Share'));
- s.insertBefore(ls,s.firstChild);
- }
- sl = document.getElementById('googleplus');
- if(!sl){
- var tumblr_button;
- /* twitter */
- gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='custom-tweet-button';
- var gba = document.createElement('a');
- gba.setAttribute("title","Tweet");
- gba.onclick=doTwitter;
- gb.appendChild(gba);
- s.appendChild(gb);
- /* evernote */
- var gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='evernote';
- gba = document.createElement('a');
- gba.setAttribute("title","Save to Evernote with link back");
- gba.onclick=doEvernoteClip;
- gb.appendChild(gba);
- s.appendChild(gb);
- /* Pinterest */
- gb= document.createElement('div');
- gb.className='sharebutton pinterest';
- gb.onclick=doPinterestClip;
- /* s.appendChild(gb); */
- /* tumblr */
- gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='tumblr';
- tumblr_button = document.createElement("a");
- tumblr_button.onclick=doTumblrClip;
- tumblr_button.setAttribute("title", "Share on Tumblr with link back");
- gb.appendChild(tumblr_button);
- s.appendChild(gb);
- /* CSP Forum */
- gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='csp';
- tumblr_button = document.createElement("a");
- tumblr_button.onclick=doIRIFClipElement;
- tumblr_button.setAttribute("title", "Share with Climate Services Partnership Forums");
- gb.appendChild(tumblr_button);
- s.appendChild(gb);
- /* code to add Mail buttons */
- gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='mailbutton';
- tumblr_button = document.createElement("a");
- tumblr_button.onclick=doMail;
- tumblr_button.setAttribute("title", "Share with e-mail");
- gb.appendChild(tumblr_button);
- s.appendChild(gb);
- /* facebook */
- gb=document.createElement('div');
- // FB with url following share variables
- // gb.className="fb-like share";
- // var url = appendPageForm(location.href,'share');
- // FB with parameters stripped from url
- gb.className="fb-like";
- var url = location.href.replace(/[?].*/,'');
- // End of Choice
- url = url.replace(/[?]/,"/QS/");
- gb.setAttribute("data-href",url);
- gb.setAttribute("data-send","false");
- gb.setAttribute("data-layout","button_count");
- gb.setAttribute("data-width","24");
- gb.setAttribute("data-show-faces","true");
- var s = document.getElementById('custom-tweet-button').parentNode;
- /* s.insertBefore(gb,document.getElementById('custom-tweet-button')); */
- s.appendChild(gb);
- loadFB();
- /* code to add GMail buttons
- gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='gmailbutton';
- tumblr_button = document.createElement("a");
- tumblr_button.onclick=doGMail;
- tumblr_button.setAttribute("title", "Share on GMail");
- gb.appendChild(tumblr_button);
- s.appendChild(gb);
- */
- var gb= document.createElement('div');
- gb.className='sharebutton';
- gb.id='googleplusbutton';
- var annote = "inline";
- if(window.innerWidth < 480)annote="bubble";
- gb.innerHTML='<div class="g-plusone" data-annotation="' + annote + '" ></div>';
- s.appendChild(gb);
- }
- // adds scripts to share to activate buttons
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
- po.src = 'https://apis.google.com/js/plusone.js';
- s.appendChild(po);
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = "//static.evernote.com/noteit.js";
- s.appendChild(ga);
- /* var pi = document.createElement('script'); pi.type = 'text/javascript'; pi.async = true;
- pi.src = "//assets.pinterest.com/js/pinit.js";
- s.appendChild(pi);
- */
- }
- }
- function loadFB(){
- var js, id = 'facebook-jssdk', ref = document.getElementsByTagName('script')[0];
- if (document.getElementById(id)) {return;}
- js = document.createElement('div');
- js.id='fb-root';
- var b= document.getElementsByTagName('body')[0];
- b.insertBefore(js, b.firstChild);
- window.fbAsyncInit = function() {
- /* FB.init({
- appId : 'myId', // App ID
- channelUrl : '', // Channel File
- status : true, // check login status
- cookie : true, // enable cookies to allow the server to access the session
- xfbml : true // parse XFBML
- }); */
- FB.Event.subscribe('edge.create', function(targetUrl) {
- /* _gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);*/
- ga('send','social', 'facebook','like', targetUrl);
- });
- };
- js = document.createElement('script'); js.id = id; js.async = true;
- js.onload=finishFB();
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
- ref.parentNode.insertBefore(js, ref);
- }
- function finishFB(){
- /* fb followup FB.XFBML.parse() to rerender */
- FBloaded=true;
- }
- function doTwitter(){
- var url = appendPageForm(location.href,'share');
- var tpar = getElementsByAttribute(document,'*','property','term:title');
- var dpar = getElementsByAttribute(document,'*','property','term:description');
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var twitter_url = "https://twitter.com/share?via=iridl&hashtags=dataviz&url=" + encodeURIComponent(url) + "&text=" + encodeURIComponent(title);
- /* _gaq.push(['_trackSocial', 'twitter', 'tweet', url]);*/
- ga('send','social', 'twitter','tweet', url);
- window.open(twitter_url);
- }
- function doGMail(){
- var url = appendPageForm(location.href,'share');
- var tpar = getElementsByAttribute(document,'*','property','term:title');
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var m='http://mail.google.com/mail/?ui=1&view=cm&fs=1&tf=1&to=&su='+encodeURIComponent(title)+'&body='+encodeURIComponent(url);
- window.open(m);
- }
- function doMail(){
- var url = appendPageForm(location.href,'share');
- var tpar = getElementsByAttribute(document,'*','property','term:title');
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var m='mailto:?subject='+encodeURIComponent(title)+'&body='+encodeURIComponent(url);
- /* _gaq.push(['_trackSocial', 'mail', 'mail', url]);*/
- ga('send','social', 'mail','mail', url);
- window.open(m);
- }
- function doHelpMail(){
- var url = appendPageForm(location.href,'share');
- var tpar = getElementsByAttribute(document,'*','property','term:title');
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var m='mailto:' + uicoreConfig.helpemail +'?subject='+encodeURIComponent(title)+'&body='+encodeURIComponent(url);
- /* _gaq.push(['_trackSocial', 'mail', 'mail', url]);*/
- ga('send','social', 'mail','help', url);
- window.open(m);
- }
- function doTumblrClip(){
- var content = document.getElementById("content");
- var tpar = getElementsByAttribute(document,'h2','property','term:title');
- var dpar = getElementsByAttribute(document,'p','property','term:description');
- var url = appendPageForm(location.href,'share');
- var ttype='';
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var description="";
- if(dpar.length>0){
- description=dpar[0].innerHTML;
- }
- var tumblr_url;
- var tumblr_photo_source = "";
- var tumblr_photo_caption = "";
- if(description){
- tumblr_photo_caption = description;
- }
- else {
- tumblr_photo_caption = title;
- }
- if(content){
- if(content.getElementsByTagName('link').length>0){
- tumblr_photo_source = content.getElementsByTagName('link')[0].figureimage.src;
- }
- }
- else {
- var figimg = getFigureImage(document);
- if(figimg)tumblr_photo_source = figimg.src;
- }
- var tumblr_photo_click_thru = url;
- if(tumblr_photo_source){
- ttype='photo';
- tumblr_url = "//www.tumblr.com/share/photo?source=" + encodeURIComponent(tumblr_photo_source) + "&caption=" + encodeURIComponent(tumblr_photo_caption) + "&clickthru=" + encodeURIComponent(tumblr_photo_click_thru);
- }
- else {
- ttype='link';
- var tumblr_link_url = url;
- var tumblr_link_name = title;
- var tumblr_link_description = description;
- tumblr_url = "//www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description);
- }
- /* _gaq.push(['_trackSocial', 'tumblr', ttype , url]);*/
- ga('send','social', 'tumblr',ttype, url);
- window.open(tumblr_url);
- }
- function doTumblrClipElement(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getFigureImage(it.clipthis);
- var content = document.getElementById("content");
- var tpar = getElementsByAttribute(document,'h2','property','term:title');
- var dpar = getElementsByAttribute(document,'p','property','term:description');
- var url = appendPageForm(location.href,'share');
- var ttype='';
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var description="";
- if(dpar.length>0){
- description=dpar[0].innerHTML;
- }
- var tumblr_url;
- var tumblr_photo_source = "";
- var tumblr_photo_caption = "";
- if(description){
- tumblr_photo_caption = description;
- }
- else {
- tumblr_photo_caption = title;
- }
- if(figimg && figimg.src){
- tumblr_photo_source = figimg.src
- }
- var tumblr_photo_click_thru = url;
- if(tumblr_photo_source){
- ttype='photo';
- tumblr_url = "//www.tumblr.com/share/photo?source=" + encodeURIComponent(tumblr_photo_source) + "&caption=" + encodeURIComponent(tumblr_photo_caption) + "&clickthru=" + encodeURIComponent(tumblr_photo_click_thru);
- }
- else {
- ttype='link';
- var tumblr_link_url = url;
- var tumblr_link_name = title;
- var tumblr_link_description = description;
- tumblr_url = "//www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description);
- }
- /* _gaq.push(['_trackSocial', 'tumblr', ttype , url]);*/
- ga('send','social', 'tumblr',ttype, url);
- window.open(tumblr_url);
- }
- function homelinkclick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var myurl;
- var homelinks=getElementsByAttribute(document,'link','rel','home');
- if(homelinks.length == 1){
- myurl=homelinks[0].href;
- document.location.href=myurl;
- }
- else if(homelinks.length == 0){
- myurl="http://iri.columbia.edu/";
- document.location.href=myurl;
- }
- }
- function doEvernoteClip(){
- var clipargs = {};
- clipargs.contentId = 'content';
- clipargs.url = appendPageForm(location,'share');
- clipargs.filter= function (arg){
- if(!(arg.className == 'imagecontrols' || arg.className.indexOf('dlcontrol')>=0 || arg.style.visibility=='hidden')){
- return arg;
- }
- };
- /* _gaq.push(['_trackSocial', 'evernote', 'clip', clipargs.url]);*/
- ga('send','social', 'evernote','clip', clipargs.url);
- Evernote.doClip(clipargs);
- }
- function doPinterestClip(){
- var tpar = getElementsByAttribute(document,'h2','property','term:title');
- var dpar = getElementsByAttribute(document,'p','property','term:description');
- var url = appendPageForm(location.href,'share');
- var ttype='';
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var description="";
- if(dpar.length>0){
- description=dpar[0].innerHTML;
- }
- /* _gaq.push(['_trackSocial', 'Pinterest', 'clipPage']); */
- ga('send','social', 'Pinterest','clipPage',location.href);
- var pinterest_link_url = url;
- var pinterest_link_description = title + ": " +description;
- pinterest_url = "//pinterest.com/pin/create/button/?url=" + encodeURIComponent(pinterest_link_url) + "&description=" + encodeURIComponent(pinterest_link_description);
- window.open(pinterest_url)
- }
- function doEvernoteClipElement(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var clipargs = {};
- clipargs.content = it.clipthis;
- clipargs.url = appendPageForm(location.href,'share');
- clipargs.filter= function (arg){
- if(!(arg.className == 'imagecontrols' || arg.className.indexOf('dlcontrol')>=0|| arg.style.visibility=='hidden')){
- return arg;
- }
- };
- /* _gaq.push(['_trackSocial', 'evernote', 'clipelement']);*/
- ga('send','social', 'evernote','clipelement',location.href);
- Evernote.doClip(clipargs);
- }
- function doGoogleEarthClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var sfigs=getElementsByAttribute(it.clipthis,'*','rel','iridl:hasFigure');
- if(sfigs.length){
- var kmlurl=sfigs[0].info['iridl:hasKML'];
- var kmlclass = sfigs[0].figureimage.className.split(' ')[0];
- if(kmlurl){
- var linkurl = appendPageForm(location.href,'share');
- var pform=document.getElementById('pageform');
- pform.elements['linkurl'].value=linkurl;
- submitPageForm(kmlurl,kmlclass+' linkurl','POST');
- /* _gaq.push(['_trackSocial', 'googleearth', 'asKML']);*/
- ga('send','social', 'googleearth','asKML',location.href);
- }
- }
- }
- function doWMSClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var sfigs=getElementsByAttribute(it.clipthis,'*','rel','iridl:hasFigure');
- if(sfigs.length){
- var kmlurl=sfigs[0].info['iridl:hasWMS'];
- var kmlclass = sfigs[0].figureimage.className.split(' ')[0];
- if(kmlurl){
- var myurl = appendPageForm(kmlurl,kmlclass);
- var msga=it.parentNode.parentNode.getElementsByClassName('messagearea');
- if(msga.length>0){
- msga[0].innerHTML="<p>To open using WMS, enter this URL for the WMSserver</p><textarea style='width:100%;' rows=20>" + myurl + '</textarea>';
- toggleClass(msga[0],'show');
- }
- else {
- alert(myurl);
- }
- /* location.href=myurl; */
- /* _gaq.push(['_trackSocial', 'WMS', 'asWMS']);*/
- ga('send','social', 'WMS','asWMS',location.href);
- }
- }
- }
- function doGeoTiffClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var sfigs=getElementsByAttribute(it.clipthis,'*','rel','iridl:hasFigure');
- if(sfigs.length){
- var kmlurl=sfigs[0].info['iridl:hasGeoTiff'];
- var kmlclass = sfigs[0].figureimage.className.split(' ')[0];
- if(kmlurl){
- var myurl = appendPageForm(kmlurl,kmlclass);
- location.href=myurl;
- /* _gaq.push(['_trackSocial', 'DataDownload', 'asGeoTiff']);*/
- ga('send','social', 'DataDownload','asGeoTiff',location.href);
- }
- }
- }
- function doGeoTiffPCClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var sfigs=getElementsByAttribute(it.clipthis,'*','rel','iridl:hasFigure');
- if(sfigs.length){
- var kmlurl=sfigs[0].info['iridl:hasGeoTiffPaletteColor'];
- var kmlclass = sfigs[0].figureimage.className.split(' ')[0];
- if(kmlurl){
- var myurl = appendPageForm(kmlurl,kmlclass);
- location.href=myurl;
- /* _gaq.push(['_trackSocial', 'DataDownload', 'asGeoTiffPC']);*/
- ga('send','social', 'DataDownload','asGeoTiffPC',location.href);
- }
- }
- }
- function getFigureImage(clipthis){
- var figimg;
- if(!clipthis){
- clipthis = document.getElementById("content");
- }
- if(!clipthis){
- clipthis=document;
- }
- var sfigimgs=getElementsByAttribute(clipthis,'*','rel','iridl:hasFigureImage');
- var sfigs=getElementsByAttribute(clipthis,'*','rel','iridl:hasFigure');
- if(sfigimgs.length){
- figimg=sfigimgs[0];
- for(var i=sfigimgs.length;i--;){
- if(sfigimgs[i].className.indexOf("selectedImage") >= 0){
- figimg=sfigimgs[i];
- }
- }
- }
- else if(sfigs.length){
- figimg=sfigs[0].figureimage;
- }
- else {
- var sfigimgs = clipthis.getElementsByTagName('img');
- var maxsize = 0;
- var imax = -1;
- for(var i=sfigimgs.length;i--;){
- var isize = sfigimgs[i].width * sfigimgs[i].height;
- if( isize >= imax){
- imax = isize;
- imax = i;
- }
- }
- if(imax >= 0){
- figimg = sfigimgs[imax];
- }
- }
- return(figimg);
- }
- function getOnlyFigureImage(clipthis){
- var figimg;
- if(!clipthis){
- clipthis = document.getElementById("content");
- }
- if(!clipthis){
- clipthis=document;
- }
- var sfigimgs=getElementsByAttribute(clipthis,'*','rel','iridl:hasFigureImage');
- var sfigs=getElementsByAttribute(clipthis,'*','rel','iridl:hasFigure');
- if(sfigimgs.length){
- figimg=sfigimgs[0];
- for(var i=sfigimgs.length;i--;){
- if(sfigimgs[i].className.indexOf("selectedImage") >= 0){
- figimg=sfigimgs[i];
- }
- }
- }
- else if(sfigs.length){
- figimg=sfigs[0].figureimage;
- }
- return(figimg);
- }
- function getPDFImage(clipthis){
- var sfigimgs=getElementsByAttribute(clipthis,'*','rel','iridl:hasPDFImage');
- var figimg;
- if(sfigimgs.length){
- figimg=sfigimgs[0];
- for(var i=sfigimgs.length;i--;){
- if(sfigimgs[i].className.indexOf("selectedImage") >= 0){
- figimg=sfigimgs[i];
- }
- }
- }
- return(figimg);
- }
- function getPNGImage(clipthis){
- var sfigimgs=getElementsByAttribute(clipthis,'*','rel','iridl:hasPNGImage');
- var figimg;
- if(sfigimgs.length){
- figimg=sfigimgs[0];
- for(var i=sfigimgs.length;i--;){
- if(sfigimgs[i].className.indexOf("selectedImage") >= 0){
- figimg=sfigimgs[i];
- }
- }
- }
- return(figimg);
- }
- function getTable(clipthis){
- var sfigimgs=getElementsByAttribute(clipthis,'*','rel','iridl:hasTable');
- var figimg;
- if(sfigimgs.length){
- figimg=sfigimgs[0];
- for(var i=sfigimgs.length;i--;){
- if(sfigimgs[i].parentNode.getElementsByClassName("selectedImage").length > 0){
- figimg=sfigimgs[i];
- }
- }
- }
- return(figimg);
- }
- function doTSVClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getTable(it.clipthis);
-
- if(figimg && figimg.href){
- var pdfurl=figimg.href;
- var pdfclass=figimg.className;
- pdfurl = pdfurl.replace(/[?].*/,'') + '.tsv';
- submitPageForm(pdfurl,pdfclass,'GET');
- /* _gaq.push(['_trackSocial', 'DataDownload', 'asTSV']);*/
- ga('send','social', 'DataDownload','asTSV',location.href);
- }
- }
- function doHTMLClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getTable(it.clipthis);
-
- if(figimg && figimg.href){
- var pdfurl=figimg.href;
- var pdfclass=figimg.className;
- pdfurl = pdfurl.replace(/[?].*/,'') + '.html';
- submitPageForm(pdfurl,pdfclass,'GET');
- /* _gaq.push(['_trackSocial', 'DataDownload', 'asHTML']);*/
- ga('send','social', 'DataDownload','asHTML',location.href);
- }
- }
- function doPDFClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getFigureImage(it.clipthis);
-
- if(figimg && figimg.src){
- var pdfurl=figimg.src;
- var pdfclass=figimg.className;
- pdfurl = pdfurl.replace(/\.(gif|png|jpg)/,'.pdf');
- var linkurl = appendPageForm(location.href,'share');
- var pform=document.getElementById('pageform');
- pform.elements['linkurl'].value=linkurl;
- submitPageForm(pdfurl,pdfclass+' linkurl','POST');
- ga('send','social', 'ImageDownload','asPDF',location.href);
- }
- }
- function doPDFClickGET(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getFigureImage(it.clipthis);
-
- if(figimg && figimg.src){
- var pdfurl=figimg.src;
- var pdfclass=figimg.className;
- pdfurl = pdfurl.replace(/\.(gif|png|jpg)/,'.pdf');
- var linkurl = appendPageForm(location.href,'share');
- var pform=document.getElementById('pageform');
- pform.elements['linkurl'].value=linkurl;
- submitPageForm(pdfurl,pdfclass+' linkurl','GET');
- }
- }
- function doPDFgDriveClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getFigureImage(it.clipthis);
- if(figimg && figimg.src){
- var pdfurl=figimg.src;
- var pdfclass=figimg.className;
- pdfurl = pdfurl.replace(/\.(gif|png|jpg)/,'.pdf');
- var linkurl = appendPageForm(location.pathname,'share');
- var pform=document.getElementById('pageform');
- pform.elements['linkurl'].value=linkurl;
- /* gapi.savetodrive.render */
- var urlxml=appendPageForm(pdfurl,pdfclass+' linkurl');
- gapi.savetodrive.render(it,{"src": urlxml,
- "filename":document.title,
- "sitename": uicoreConfig.SiteName});
- }
- }
- function doPDFgDriveRender(it){
- var figimg = getFigureImage(it.clipthis) || getTable(it.clipthis);
- if(figimg && figimg.src){
- var pdfurl=figimg.src;
- var pdfclass=figimg.className;
- pdfurl = pdfurl.replace(/\.(gif|png|jpg)/,'.pdf');
- var linkurl = appendPageForm(location.pathname,'share');
- var pform=document.getElementById('pageform');
- pform.elements['linkurl'].value=linkurl;
- /* gapi.savetodrive.render */
- var urlxml=appendPageForm(pdfurl,pdfclass+' linkurl');
- /* remove protocol */
- /* urlxml=urlxml.replace(/^(https?:\/\/)/,'//'); */
- var gDriveBlist=it.getElementsByClassName('gDriveSubButton');
- var ucheck=false;
- if (gDriveBlist.length){
- for (var idrive=gDriveBlist.length; idrive--;){
- if(gDriveBlist[idrive].getAttribute("rUrl",urlxml) == urlxml)
- {ucheck=true;
- gDriveBlist[idrive].setAttribute("gDriveUrl","active");
- }
- else
- {gDriveBlist[idrive].setAttribute("gDriveUrl","standby");
- }
- }
- }
- if(!ucheck){
- var gdrivespan=document.createElement('span');
- gdrivespan.className="gDriveSubButton";
- it.appendChild(gdrivespan);
- gdrivespan.renderedUrl=urlxml;
- gdrivespan.filename=document.title;
- gdrivespan.sitename=uicoreConfig.SiteName;
- gdrivespan.setAttribute("rUrl",urlxml);
- gdrivespan.setAttribute("gDriveUrl","active");
- gdrivespan.setAttribute("rendered",false);
- /* gapi.savetodrive.render(gdrivespan,{"src": urlxml,
- "filename":document.title,
- "sitename": uicoreConfig.SiteName});
- */ }
- }
- }
- function doPDFImageClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getPDFImage(it.clipthis);
- if(figimg && figimg.href){
- var pdfurl=figimg.href;
- var pdfclass=figimg.className;
- var pform=document.getElementById('pageform');
- submitPageForm(pdfurl,pdfclass,'GET');
- ga('send','social', 'ImageDownload','asPDF',location.href);
- }
- }
- function doPSImageClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getPSImage(it.clipthis);
- if(figimg && figimg.href){
- var pdfurl=figimg.href;
- var pdfclass=figimg.className;
- var pform=document.getElementById('pageform');
- submitPageForm(pdfurl,pdfclass,'GET');
- ga('send','social', 'ImageDownload','asPS',location.href);
- }
- }
- function doPNGImageClick(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getPNGImage(it.clipthis);
- if(figimg && figimg.href){
- var pdfurl=figimg.href;
- var pdfclass=figimg.className;
- var pform=document.getElementById('pageform');
- submitPageForm(pdfurl,pdfclass,'GET');
- ga('send','social', 'ImageDownload','asPNG',location.href);
- }
- }
- function doPinterestClipElement(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var figimg = getFigureImage(it.clipthis);
-
- if(figimg && figimg.src){
- var pinurl=figimg.src;
- var pinclass=figimg.className;
- var linkurl = appendPageForm(location.href,'share');
- pinrul = pinurl.replace(/[/]expert[/]/,'/');
- pinurl = pinurl.substr(0,8) + pinurl.substring(8).replace(/[/][/]([^/+]+)/g,function(match){
- return '(' + match.substring(2,match.length) + ')cvn';
- });
- var tpar = getElementsByAttribute(document,'h2','property','term:title');
- var dpar = getElementsByAttribute(document,'p','property','term:description')
- var title="";
- if(tpar.length>0){
- title=tpar[0].innerHTML;
- }
- if(!title)title=document.title;
- var description="";
- if(dpar.length>0){
- description=dpar[0].innerHTML;
- }
- var pinterest_link_description = title + ": " +description;
- /* _gaq.push(['_trackSocial', 'Pinterest', 'clipelement']);*/
- ga('send','social', 'Pinterest','clipelement',location.href);
- pinterest_url = "//pinterest.com/pin/create/button/?url=" + encodeURIComponent(linkurl) + "&media=" + encodeURIComponent(pinurl) + "&description=" + encodeURIComponent(pinterest_link_description);
- window.open(pinterest_url);
- }
- }
- function doIRIFClipElement(evt){
- var evt = (evt) ? evt : ((event) ? event : null );
- var it = (evt.currentTarget) ? evt.currentTarget : this;
- var …
Large files files are truncated, but you can click here to view the full file