Искать:



на сайте
в интернете

 

Готовые программы | Командная строка | Чат | Авторам | Наши баннеры
Гостевая книга | Форум | Послать E-mail | Добавить свою работу | JavaScript

 ДРЕВОВИДНОЕ МЕНЮ [TREE VIEW]

Добро пожаловать на сайт
для настоящих программистов!

<HTML>
<HEAD>
<TITLE>Проводник</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var caution = false
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie
else
if (confirm("Cookie exceeds 4KB and will be cut!"))
document.cookie = curCookie
}
function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" + 
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT"
}
}

function fixDate(date) {
var base = new Date(0)
var skew = base.getTime()
if (skew > 0)
date.setTime(date.getTime() - skew)
}

function item(parent, text, depth) {
this.parent = parent // is this item a parent?
this.text = text // text for link (may include HTML)
this.depth = depth // nested depth
}

function makeArray(length) {
this.length = length // length of array (integer)
}

function makeDatabase() {
outline = new makeArray(9) // create global object

outline[0] = new item(true, 'computer companies', 0)
outline[1] = new item(false, '<A HREF="http://www.intel.com">Intel</A>', 1)
outline[2] = new item(true, 'software', 1)
outline[3] = new item(false, '<A HREF="http://www.netscape.com">Netscape</A>', 2)
outline[4] = new item(false, '<A HREF="http://www.microsoft.com">Microsoft</A>', 2)
outline[5] = new item(false, '<A HREF="http://www.netscent.com">Netscent</A>', 1)
outline[6] = new item(true, 'shareware Web sites', 0)
outline[7] = new item(false, '<A HREF="http://www.jumbo.com">Jumbo</A>', 1)
outline[8] = new item(false, '<A HREF="http://www.windows95.com">Windows95.com</A>', 1)

setStates()

setImages()
}

function setStates() {
var storedValue = getCookie("outline")

if (!storedValue) {
for (var i = 0; i < outline.length; ++i) {
if (outline[i].depth == 0)
outline[i].state = true
else
outline[i].state = false
}
} else {
for (var i = 0; i < outline.length; ++i) {
if (storedValue.charAt(i) == '1')
outline[i].state = true
else
outline[i].state = false
}
}
}

function setImages() {
for (var i = 0; i < outline.length; ++i) {
if (outline[i].state)
if (outline[i].parent) // outline[i] is a parent
if (outline[i + 1].state) // outline[i] is exploded
outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="exploded.gif" BORDER=0></A>'
else // outline[i] is collapsed
outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="collapsd.gif" BORDER=0></A>'
else // outline[i] is only a child (not a parent)
outline[i].pic = '<IMG SRC="child.gif" BORDER=0>'
}
}

function toggle(num) {
for (var i = num + 1; i < outline.length && outline[i].depth >= outline[num].depth + 1; ++i) {
if (outline[i].depth == outline[num].depth + 1)
outline[i].state = !outline[i].state // toggle state
}
setStorage()
history.go(0)
}

function setStorage() {
var text = ""
for (var i = 0; i < outline.length; ++i) {
text += (outline[i].state) ? "1" : "0"
}
setCookie("outline", text)
}
makeDatabase()
// -->
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write('<PRE><H4>')
for (var i = 0; i < outline.length; ++i) {
if (outline[i].state) {
for (var j = 0; j < outline[i].depth * 3; ++j) {
document.write(' ')
}
document.write(outline[i].pic, ' ', outline[i].text, '<BR>')
} else {
var previous = i
for (var k = i + 1; k < outline.length && outline[k].depth >= outline[previous].depth; ++k) {
++i
}
}
}
document.write('</H4></PRE>')
// -->
</SCRIPT>
</BODY>
</HTML> 
<<Назад На главную

Автор и дизайн сайта: DeeCo
Copyright © 2002-2003

Сайт создан в системе uCoz