Indonesia
<html> <head> </head> <script bahasa="javascript"> fungsi PageLoad() { /*var myMenu = new MainMenu('menu','test.xml'); var myMenu = Menu Utama baru('menu'); var menuFile = MenuItem baru('File','File',null,'F'); var menuSave = MenuItem baru('Simpan','Simpan','document.execCommand ("Simpan Sebagai")','S'); var menuExit = new MenuItem('Exit','Exit','Exit()','X'); ,null,'E'); var menuView = new MenuItem('View','View',null,'V'); var menuProg = new MenuItem('Prog','Diinisialisasi melalui skrip program','SelectOpt(ini )'); var menuConf = new MenuItem('Conf','Diinisialisasi melalui file konfigurasi','SelectOpt(ini)'); var menuChk = new MenuItem('Chk','Test: beberapa pilihan'); new MenuItem('Chk1','Tes: Periksa Opsi 1','CheckOpt(ini)'); var menuChk2 = new MenuItem('Chk1','Tes: Periksa Opsi 2','CheckOpt(ini)'); menuHelp = new MenuItem('Help','Help',null,'H'); var menuTopics = new MenuItem('Topik','Help Topic',null,'T'); ','Konten bantuan',null,'C'); var menuAbout = new MenuItem('About','About MenuItem','alert("MenuItem Ver1.00 oleh Akira(akira_cn@msn.com)")', 'A'); menuFile.addChild(menuSave); menuFile.addChild(menuExit); menuView.addChild(menuProg); menuView.addChild(menuConf); menuChk.addChild(menuChk1); menuChk.addChild(menuChk2); menuHelp.addChild(menuTopics); menuHelp.addItem(menuFile); addItem(menuEdit); myMenu.addItem(menuView); myMenu.addItem(menuHelp); myMenu.Show(); menuEdit.Disable(); .Check(); } fungsi kontak() { peringatan('Hubungi kami'); } fungsi Keluar() { self.opener = self.close(); ('editBox1'); var editBox2 = document.getElementById('editBox2'); if (target.id == 'Conf') { editBox1.style.display = "tidak ada"; } else { editBox2.style.display = "tidak ada"; editBox1.style.display = "blok"; } target.Select(); } function CheckOpt(target) { target.Check(); style='padding:0 0 0 0;margin:0 0 0 0' onload='PageLoad()'> <textarea id="editBox1" style="width:100%;height:90%"> Inisialisasi halaman utama melalui contoh Menu program: <script> var myMenu = new MainMenu('menu'); var menuFile = new MenuItem('File','File',null,'F'); ' Simpan','document.execCommand("SaveAs")','S'); var menuExit = new MenuItem('Exit','Exit','Exit()','X'); ( 'Edit','Edit',null,'E'); var menuView = new MenuItem('View','View',null,'V'); var menuProg = new MenuItem('Prog','melalui program skrip Inisialisasi','SelectOpt(ini)'); var menuConf = new MenuItem('Conf','Inisialisasi melalui file konfigurasi','SelectOpt(ini)'); Opsi Kompleks 1','CheckOpt(ini)'); var menuChk2 = new MenuItem('Chk1','Uji: Periksa Opsi 2','CheckOpt(this)'); Bantuan ',null,'H'); var menuTopics = new MenuItem('Topik','Topik bantuan',null,'T'); var menuContent = new MenuItem('Konten','Konten bantuan',null,' C '); var menuTentang = MenuItem baru ('Tentang','TentangItemMenu','alert('MenuItem Ver1.00 oleh Akira(akira_cn@msn.com)')','A'); ; myMenu.addItem(menuEdit); myMenu.addItem(menuView); myMenu.addItem(menuBantuan); menuView.addLine(); //Baris terpisah menuView.addChild(menuChk1); menuView.addChild(menuChk2); menuHelp.addChild(menuTopics) ; myMenu.Show(); menuEdit.Disable(); menuTopics.Disable(); menuContent.Disable(); editBox2" style="width:100%;height:90%;display:none"> Contoh inisialisasi menu utama melalui file konfigurasi: <!--xml file konfigurasi, misalnya simpan sebagai test.xml-- > <?xml versi ="1.0" coding="gb2312" standalone="yes"?> <MainMenu> <MenuItem id="File" Text="File" Accelerator="F"> <MenuItem id="Simpan" Teks ="Simpan" Akselerator ="S" onClick="document.execCommand('SaveAs')"/> <MenuItem id="Keluar" Text="Keluar" Accelerator="X" onClick="Keluar()"/> < /MenuItem> <MenuItem id="Edit" Text="Edit" Accelerator="E" Disabled="true"> </MenuItem> <MenuItem id="View" Text="View" Accelerator="V"> <MenuItem id="Prog" Text="Diinisialisasi melalui skrip program" Selected="true" onClick="SelectOpt(this)"/> <MenuItem id="Conf" Text="Diinisialisasi melalui file konfigurasi" onClick="SelectOpt(this) "/> <MenuItem /> <MenuItem id="Chk1" Text="Uji: Periksa Opsi 1" Diperiksa="benar" onClick="CheckOpt(ini)"/> <MenuItem id="Chk2" Text="Uji: Centang Opsi 2" onClick ="CheckOpt(this)"/> </MenuItem> <MenuItem id="Help" Text="Help" Accelerator="H"> <MenuItem id="Topics" Text="Help Topics" Accelerator ="T" Disabled ="true"/> <MenuItem id="Content" Text="Bantuan konten" Accelerator="C" Disabled="true"/> <MenuItem/> <MenuItem id="Tentang" Text=" Tentang MenuItem" Accelerator= "A" onClick="alert('MenuItem Ver1.00 oleh Akira(akira_cn@msn.com)')"/> </MenuItem> </MainMenu> <script> var myMenu = new MainMenu(' menu','test .xml'); //Baca informasi menu dari file konfigurasi test.xml myMenu.Show(); </script> </textarea> </body> </html> <!---- ---- ------------------------------- ---- --------------- Kontrol menu bagian program utama Versi 1.00 Akira (akira_cn@msn.com) --------------- - ---------------------------------- - - ---> <script bahasa="javascript"> fungsi MenuItem(id, teks, clickEvent, akselerator, subWidth) { this.id = null; this.text = null; if (id == null) { this.id = "menu" + (new Date()).getTime(); } else this.id = id; .subWidth = 0; untuk (var i = 0; this.text != null && i < this.text.length; i++) { this.subWidth = this.subWidth - 0 + (text.charCodeAt(i) > 127 ? 20 : 10); } //ini.subLebar = ini.teks != null ? ini.teks.panjang * 16 : 96;//100; lain ini.subWidth = subLebar; onclick = function(){}; else this.onclick = function(){eval(clickEvent);}; if (akselerator != null) //Tombol pintasan { this.accelerator = akselerator } this.subMenuItems = Array baru ( ); ini.terlihat = benar; ini.dinonaktifkan = salah; ini.diperiksa = salah; ini.dipilih = salah; MenuItem.prototipe.Sembunyikan = fungsi() { ini.terlihat = salah; "tidak ada"; } MenuItem.prototype.Show = function() { this.visible = true; this._span.style.display = "block"; this._span.EventHandler = ini; this._span.onmouseover = function(){this.EventHandler._span_MouseOver(ini,acara);} this._span.onmouseout = function(){ini.EventHandler._span_MouseOut(ini,acara) );} this._span.onclick = function(){this.EventHandler._span_Click(this,event);} this._span.style.color = "#000000"; } MenuItem.prototype.Disable = function() { ini .disabled = benar; this._span.onmouseover = function(){} this._span.onmouseout = function(){} this._span.onclick = function(){} this._span.style.color = "#ACA899" ; } MenuItem.prototype.Check = function() { if (!this.checked) { var textObj = document.createElement('b'); textObj.innerText = '√'; (var i = 0; i < this._span.childNodes.length - 1; i++) { this._span.appendChild(this._span.removeChild(this._span.childNodes[i])); ; this._span.style.paddingLeft = "6px"; } else { this._span.removeChild(this._span.childNodes[0]); ini.dicentang = false; } } MenuItem.prototype.Select = function() { var parent = this.parent; untuk (var i = 0; i < parent.subMenuItems.length; i++) { parent.subMenuItems[i]._unselect(); liObj = document.createElement("li"); this._span.appendChild(liObj); untuk (var i = 0; i < this._span.childNodes.length - 1; i++) { liObj.appendChild(this._span. hapusAnak(ini._span.childNodes[i])); } ini.dipilih = benar; //ini.subLebar = ini.subLebar - 0 + 16; ini._span.style.paddingLeft = "2px"; ._unselect = function() { if (ini.dipilih) { var liObj = this._span.removeChild(this._span.childNodes[0]); untuk (var i = 0; i < liObj.childNodes.length; i++) { this._span.appendChild(liObj.childNodes[i] } ini.dipilih = salah; this._span.style.paddingLeft = "18px"; //ini.subWidth = ini.subWidth - 16; prototype.addChild = fungsi(menuItem) { this.subMenuItems.push(menuItem); menuItem.parent = ini; } MenuItem.prototype.addLine = function() { this.addChild(new MenuItem()); hasChild = function() { kembalikan this.subMenuItems.length > 0; } this._span = document.createElement("span"); this._span.id = this._span.style.cursor = "default" ; jika (ini.teks == null) { this._span.appendChild(document.createElement("hr")); this._span.style.height = "2px"; ; this._span.style.marginBottom = "2px"; } else { if (akselerator != null) { var situs = text.indexOf(akselerator); 0, situs); var part2 = text.slice(situs + 1); var textNode1 = document.createTextNode(part1); .style.textDecoration = "garis bawah"; node.innerText = akselerator; this._span.appendChild(textNode1); this._span.appendChild(node); createTextNode(teks + "("); var node = document.createElement("font"); node.style.textDecoration = "garis bawah"; node.innerText = akselerator; this._span.appendChild(textNode); this._span. appendChild(node); this._span.appendChild(document.createTextNode(")")); this.subWidth = this.subWidth - 0 + 48; .appendChild(textNode); } this._span.style.height = "20px"; this._span.style.marginTop = "2px"; = "12px"; ini._span.style.paddingTop = "5px"; ini._span.style.paddingLeft = "18px"; ini._span.style.paddingRight = "10px"; ._span.onmouseover = function(){this.EventHandler._span_MouseOver(this,event);} this._span.onmouseout = function(){this.EventHandler._span_MouseOut(this,event);} this._span.onclick = fungsi (){this.EventHandler._span_Click(this,event);} } if (akselerator != null) { this.accelerator = accelerator.charCodeAt(0 } MenuItem.prototype.ShowSubmenu = function() { var pos = ini .getObjPosition(); var subSpan = document.createElement("span"); subSpan.style.position = "mutlak"; if(ini.instans induk dari MainMenu) { subSpan.style.left = pos[0]; .top = pos[1] + this._span.clientHeight; } else { subSpan.style.left = pos[0] + this._span.clientWidth + 1; subSpan.style.top = pos[1]; style.paddingLeft = "0px"; subSpan.style.width = 0; subSpan.style.backgroundColor = "#FFFFFF"; subSpan.style.border = "1px padat #ACA899"; ; subSpan.className = "subMenu"; subSpan.pemilik = ini.id; //ini._span.onmouseout = function(){} untuk (var i = 0; i < this.subMenuItems.length; i++) { ini .subMenuItems[i]._span.style.marginTop = 0; this.subMenuItems[i]._span.style.marginBottom = 0; this.subMenuItems[i]._span.style.width = "100%"; .subWidth < ini.subMenuItems[i].subWidth) { ini.subWidth = ini.subMenuItems[i].subWidth; } subSpan.appendChild(ini.subMenuItems[i]._span); subWidth > 96 ? this.subWidth : 96; //this._span.appendChild(subSpan); document.body.appendChild(subSpan); ) { if (!this.hasChild() || this.clickEvent) { this.hideSubmenu(true); this.onclick() } else { if(this.hasChild()) { ini. parent._showSub = benar; } } if (event.stopPropagation) event.stopProgpagation(); else event.cancelBubble = true; } MenuItem.prototype._span_MouseOver = fungsi(pengirim, acara) { this._activeMenu(); (pengirim); if(this.hasChild() && (this.parent._showSub || this.parent instanceof MenuItem)) { this.ShowSubmenu(); ._cleanMenu(pengirim); //ini.hideSubmenu(); } MenuItem.prototype._activeMenu = fungsi(menuSpan) { menuSpan.style.backgroundColor = "#316AC5"; .prototype._cleanMenu = fungsi(menuSpan) { if (menuSpan.parentNode.className == "subMenu") menuSpan.style.backgroundColor = "#FFFFFF"; else menuSpan.style.backgroundColor = "#F1EEE5"; warna = "#000000"; } MenuItem.prototype.hideSubmenu = fungsi(bHideAll) { var subMenus = document.getElementsByTagName("span"); ) { if (subMenus[i].className == "subMenu" && (bHideAll || !this.isParentOf(subMenus[i].owner))) { if (bHideAll) { var parent = this.parent; != null) { parent._showSub = false; parent = parent.parent; } this._cleanMenu(this._span); subMenus[i].parentNode.removeChild(subMenus[i]); isParentOf = function(pemilik) { var parent = this.parent; while(parent != null) { if (owner == parent.id) return true; koordinat MenuItem.prototype.getObjPosition = function() { var obj = this._span; var objLeft = obj.offsetLeft; var objTop = obj.offsetTop; { objLeft += objParent.offsetLeft; objTop += objParent.offsetTop; objParent = objParent.offsetParent; } return([objLeft,objTop]); ( ini); if (document.body.onkeydown == null) { document.body.onkeydown = function() { untuk (var i = 0; i < MenuItem.Instances.All.length; i++) { if (MenuItem. Instances .All[i].accelerator != null) { if (event.altKey && event.keyCode == MenuItem.Instances.All[i].accelerator) { MenuItem.Instances.All[i]._span_Click.call(MenuItem .Instances.Semua[i],MenuItem.Instances.Semua[i]._span,event); .Instances.Semua[0].hideSubmenu(true); } } } MenuItem.Instances = Array baru(); MenuItem.Instances.All = Array baru(); ( ); this.parent = null; this.id = id; MainMenu.prototype._loadCfg = function(src) //Baca dari file konfigurasi { coba { var objXMLDoc = new ActiveXObject("Microsoft.XMLDOM"); async = false; objXMLDoc.load(src); if (objXMLDoc.documentElement == null) throw new TypeError("Penguraian dokumen XML gagal! "); return objXMLDoc; } catch(e) { alert("Penguraian dokumen XML gagal!"); throw new TypeError("Penguraian dokumen XML gagal!"); } } MainMenu.prototype._applyCfg = function(elemen, menuItem) { var id = elemen.getAttribute("id"); var teks = elemen.getAttribute("Teks"); var onClick = elemen.getAttribute("onClick"); subMenuItem = MenuItem baru(id,teks,onClick,Accelerator); if(menuItem != null) menuItem.addChild(subMenuItem); lain ini.addItem(subMenuItem); ; i++) { if (element.childNodes[i].tagName == "MenuItem") { this._applyCfg(element.childNodes[i], subMenuItem); cfgElements = xmlDoc.getElementsByTagName("MenuItem"); untuk (var i = 0; i < cfgElements.length; i++) { var elemen = cfgElements[i]; var id = element.getAttribute("id"); elemen.getAttribute("Diperiksa"); var dipilih = elemen.getAttribute("Dipilih"); var terlihat = elemen.getAttribute("Terlihat"); var dinonaktifkan = elemen.getAttribute("Dinonaktifkan"); null) { lanjutkan; } if (dicentang == "benar") { MenuItem.Instances[id].Check(); if (terlihat == "salah") { MenuItem.Instances[id].Hide(); } if (dinonaktifkan == "true") { MenuItem.Instances[id].Disable(); menuItem = function(id) { kembalikan this._find(id, this.items); } MainMenu.prototype._find = function(id, items) { for (var i = 0; i < items.length; i++) { jika (item[i].id == id) { mengembalikan item[i]; } if (item[i].subMenuItems.length > 0) { this._find(id, item[i].subMenuItems); null; } MainMenu.prototype.addItem = fungsi(menuItem) { this.items.push(menuItem.parent = ini; } MainMenu.prototype.removeItem = function(id) { kembalikan ini._delete(id, ini. item); } MainMenu.prototype._delete = fungsi(id, item) { for (var i = 0; i < item.length; i++) { if (item[i].id == id) { var item = item [i]; item.sambungan(i); kembalikan item; } if (item[i].subMenuItems.length > 0) { this.find(id, item[i].subMenuItems); ._div = dokumen.createElement("div"); this._div.id = ini.id; this._div.style.height = "24px"; this._div.style.backgroundColor = "#F1EEE5"; .body.appendChild(ini._div); if(cfgSrc != null) { var objXMLDoc = this._loadCfg(cfgSrc); var rootElement = objXMLDoc.documentElement; Dokumen XML bukan file konfigurasi menu utama yang sah! (Nama tag elemen root bukan MainMenu)"); throw new TypeError("Dokumen XML bukan file konfigurasi menu utama yang sah! (Nama tag elemen root bukan MainMenu)"); } for ( var i = 0; i < rootElement .childNodes.length i++) { jika (rootElement.childNodes[i].tagName == "MenuItem") { this._applyCfg(rootElement.childNodes[i]); (objXMLDoc); } MainMenu.prototype .Show = function() { document.body.appendChild(this._div); for (var i = 0; i < document.body.childNodes.length; i++) { if(document. body.childNodes[i].id != this.id) { document.body.appendChild(document.body.removeChild(document.body.childNodes[i])); untuk (var i = 0; i < ini .item.panjang; i++) { this._div.appendChild(ini.item[i]._span);