通过单击 JS Viz 中的 Javascript 元素来导航 Spotfire 中的页面?

问题描述 投票:0回答:1

我使用 Datatables.js 在 Spotfire 中创建了一个 JS Viz 我想通过单击表中的数字导航到另一个页面(每列对应于 Spotfire 中的特定页面/选项卡)

我知道可以通过触发脚本来完成导航,但这通常绑定到具有“Spotfire id”(唯一生成)的操作项。

我完全不知道如何实现这一目标,任何人都可以给我一个工作方向吗?

javascript ironpython spotfire datatables-1.10
1个回答
0
投票

这是一个纯JavaScript的方法 html

<span id="startButton" style="cursor:default">[Start]</span>
<span id="stopButton" style="cursor:pointer">[Stop]</span>

JavaScript

//parameters
var pages = [0, 1, 3];   //◄ Select the pages you want to cycle through. 0 is the first one
var timeout = 10000;      //◄ Select the time in ms to delay between pages. 10000 is 10 seconds

//maintain a registry of interval in case multiple are triggered to stop them all at once with the stop button

window["intervalIds"]??=[];
tmp=[...pages]

function startCycle() {
    (function cycle(){
        page = tmp.shift();
        if(!tmp.length) tmp=[...pages]
        goToPage(page);
        window.intervalIds.push(setTimeout(cycle, timeout));
    })();
}



function stopCycle() {
      console.log("Slideshow Ended")
      window.intervalIds.forEach(clearInterval);
}



function goToPage(x) {
  document.querySelectorAll(".sf-element-page-tab")[x].click();
}



// Hook html buttons to start and stop functions
document.getElementById("startButton").onclick = startCycle;
document.getElementById("stopButton").onclick = stopCycle;
© www.soinside.com 2019 - 2024. All rights reserved.