X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=static%2Fpackages.js;h=172e6b404409e8ab4d3d1060e00c19584b0e1322;hb=dfab23ce6368b8f6e2f147a135758e1814f4e706;hp=c33e06d73b8382afdd53c7c78eb1dcf662a429ed;hpb=078ddbf7006d957bbef2daa9735ec9a8bf3d8fcd;p=deb%2Fpackages.git diff --git a/static/packages.js b/static/packages.js index c33e06d..172e6b4 100644 --- a/static/packages.js +++ b/static/packages.js @@ -1,13 +1,14 @@ -function init_toggle_elem(id_str,user_str) { - toggle_toggle_elem(id_str,user_str,'hide'); +function init_toggle_elem(id_str,show_user_str,hide_user_str) { + toggle_toggle_elem(id_str,show_user_str,hide_user_str,'hide'); } -function toggle_toggle_elem(id_str,user_str,mode) { +function toggle_toggle_elem(id_str,show_user_str,hide_user_str,mode) { var other_mode = ( mode == "hide" ) ? "show" : "hide"; + var user_str = ( mode == "hide" ) ? show_user_str : hide_user_str; var link = document.createElement("a"); - link.setAttribute("href","javascript:toggle_toggle_elem(\""+id_str+"\",\""+user_str+"\",\""+other_mode+"\")"); - var txt = document.createTextNode("["+other_mode+" "+user_str+"]"); + link.setAttribute("href","javascript:toggle_toggle_elem(\""+id_str+"\",\""+show_user_str+"\",\""+hide_user_str+"\",\""+other_mode+"\")"); + var txt = document.createTextNode("["+user_str+"]"); link.appendChild(txt); if (document.getElementById("js_"+id_str).childNodes.length > 0) { document.getElementById("js_"+id_str).replaceChild(link,document.getElementById("js_"+id_str).firstChild); @@ -23,3 +24,127 @@ function toggleDisplay(obj) { else obj.style.display = "none"; } + +function hide_tab(id) { + var tab = document.getElementById(id); + if (tab) { + tab.style.display = "none"; + } + var item = document.getElementById(id+"link"); + if (item) { + item.style.fontWeight = "normal"; + } +} + +function show_tab(id) { + var tab = document.getElementById(id); + if (tab) { + tab.style.display = ""; + } + var item = document.getElementById(id+"link"); + if (item) { + item.style.fontWeight = "bold"; + } + var item = document.getElementById("palllink"); + if (item) { + item.style.fontWeight = "normal"; + } +} + +function init_tab_list(id) { + hide_tab("pdeps"); + hide_tab("pdownload"); + show_tab("pdesctab"); + show_tab("pbinaries"); + + var tablist = document.getElementById(id); + if (tablist) { + var list = document.createElement("ul"); + if (document.getElementById("pdesctab")) { + var item = document.createElement("li"); + item.setAttribute("id","pdesctablink"); + var link = document.createElement("a"); + link.setAttribute("href","javascript:go_to_tab(\"pdesctab\")"); + var txt = document.createTextNode("[ Description ]"); + link.appendChild(txt); + item.appendChild(link); + list.appendChild(item); + } + if (document.getElementById("pbinaries")) { + var item = document.createElement("li"); + item.setAttribute("id","pbinarieslink"); + var link = document.createElement("a"); + link.setAttribute("href","javascript:go_to_tab(\"pbinaries\")"); + var txt = document.createTextNode("[ Description ]"); + link.appendChild(txt); + item.appendChild(link); + list.appendChild(item); + } + if (document.getElementById("pdeps")) { + var item = document.createElement("li"); + item.setAttribute("id","pdepslink"); + var link = document.createElement("a"); + link.setAttribute("href","javascript:go_to_tab(\"pdeps\")"); + var txt = document.createTextNode("[ Dependencies ]"); + link.appendChild(txt); + item.appendChild(link); + list.appendChild(item); + } + if (document.getElementById("pdownload")) { + var item = document.createElement("li"); + item.setAttribute("id","pdownloadlink"); + var link = document.createElement("a"); + link.setAttribute("href","javascript:go_to_tab(\"pdownload\")"); + var txt = document.createTextNode("[ Download ]"); + link.appendChild(txt); + item.appendChild(link); + list.appendChild(item); + } + if (list.childNodes.length > 0) { + var item = document.createElement("li"); + item.setAttribute("id","palllink"); + var link = document.createElement("a"); + link.setAttribute("href","javascript:show_all_tabs()"); + var txt = document.createTextNode("[ All ]"); + link.appendChild(txt); + item.appendChild(link); + list.appendChild(item); + + } + tablist.appendChild(list); + } + show_tab("pdesctab"); + show_tab("pbinaries"); +} + +function go_to_tab(id) { + if (id == "pdeps") { + hide_tab("pdesctab"); + hide_tab("pbinaries"); + hide_tab("pdownload"); + show_tab("pdeps"); + } + if (id == "pdesctab" || id == "pbinaries") { + hide_tab("pdeps"); + hide_tab("pdownload"); + show_tab("pdesctab"); + show_tab("pbinaries"); + } + if (id == "pdownload") { + hide_tab("pdesctab"); + hide_tab("pbinaries"); + hide_tab("pdeps"); + show_tab("pdownload"); + } +} + +function show_all_tabs() { + show_tab("pdesctab"); + show_tab("pbinaries"); + show_tab("pdeps"); + show_tab("pdownload"); + var item = document.getElementById("palllink"); + if (item) { + item.style.fontWeight = "bold"; + } +}