diff --git a/lib/exampletask/index.css b/lib/exampletask/index.css new file mode 100644 index 0000000..b5b9328 --- /dev/null +++ b/lib/exampletask/index.css @@ -0,0 +1,3 @@ +.examplecss{ + background-color: coral; +} \ No newline at end of file diff --git a/lib/exampletask/index.js b/lib/exampletask/index.js index eedd205..a85fe10 100644 --- a/lib/exampletask/index.js +++ b/lib/exampletask/index.js @@ -8,6 +8,7 @@ let isActive=false; const tabName="example"; const configName="exampleBDSel"; + const infoUrl='https://github.com/wellenvogel/esp32-nmea2000/tree/master/lib/exampletask'; let boatItemName; let boatItemElement; api.registerListener((id,data)=>{ @@ -21,7 +22,12 @@ //using normal dom manipulation methods //you can use the helper addEl to create elements let page=api.addTabPage(tabName,"Example"); - api.addEl('div','',page,"this is a test tab"); + api.addEl('div','hdg',page,"this is a test tab"); + api.addEl('button','',page,'Info').addEventListener('click',function(ev){ + window.open(infoUrl,'info'); + }) + //add a tab for an external URL + api.addTabPage('exhelp','Info',infoUrl); } } if (isActive){ diff --git a/web/index.css b/web/index.css index f248d97..257b739 100644 --- a/web/index.css +++ b/web/index.css @@ -223,6 +223,7 @@ body { } #tabs { display: flex; + flex-wrap: wrap; border-bottom: 1px solid grey; margin-bottom: 0.5em; } diff --git a/web/index.js b/web/index.js index 3329628..337c21c 100644 --- a/web/index.js +++ b/web/index.js @@ -1944,13 +1944,17 @@ reader.readAsArrayBuffer(slice); }); } - function addTabPage(name,label){ + function addTabPage(name,label,url){ if (label === undefined) label=name; let tab=addEl('div','tab','#tabs',label); - tab.setAttribute('data-page',name); tab.addEventListener('click',function(ev){ handleTab(ev.target); }) + if (url !== undefined){ + tab.setAttribute('data-url',url); + return; + } + tab.setAttribute('data-page',name); let page=addEl('div','tabPage hidden','#tabPages'); page.setAttribute('id',name); return page;