復(fù)制代碼 代碼如下:
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
html>
head>
title>code collection v0.44/title>
meta http-equiv="Content-Type" content="text/html; charset=GB2312">
HTA:APPLICATION
ID="ttyp's code collection v0.44"
APPLICATIONNAME="ttyp's code collection v0.44"
VERSION="0.1"
SCROLL="no"
INNERBORDER="no"
CONTEXTMENU="yes"
CAPTION="yes"
ICON="skin//cc.ico"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal"
NAVIGABLE="yes"
/>
script language="JavaScript" src="js/xml.js">/script>
script language="JavaScript" src="js/xmlhttp.js">/script>
SCRIPT language=JavaScript src="js/skin.js">/script>
SCRIPT language=JavaScript src="js/progressorbar.js">/script>
script language="JavaScript" src="js/xtree.js">/script>
script language="JavaScript" src="js/dom.js">/script>
script language="JavaScript" src="js/config.js">/script>
script language="JavaScript" src="js/global.js">/script>
script language="JavaScript" src="js/highlight.js">/script>
script language="VbScript" src="js/ts.vbs">/script>
script language="JavaScript" src="js/autoupdate.js">/script>
SCRIPT language=JavaScript src="js/dmenu.js">/script>
SCRIPT language=JavaScript src="js/output.js">/script>
SCRIPT language=JavaScript src="js/splitbar.js">/script>
SCRIPT language=JavaScript src="js/search.js">/script>
SCRIPT language=JavaScript src="js/toolbar.js">/script>
SCRIPT language=JavaScript src="js/inputfile.js">/script>
SCRIPT language=JavaScript src="js/createlink.js">/script>
SCRIPT language=JavaScript src="js/password.js">/script>
SCRIPT language=JavaScript src="js/chm.js">/script>
SCRIPT LANGUAGE="JavaScript">
var _designMode=0;
var g_prompt;
var g_window;
var doc;
!--
function init()
{
//定義全局變量
g_prompt = new CLASS_PROMPT();
g_window = new CLASS_WINDOW();
var doc = new CLASS_XML("xml/data.xml")
//用于直接加載時獲得根接點(diǎn)
var rootXml = doc.root();
var root = getRootNode(rootXml);
//dom.js
loadChild(root,rootXml);
doc.dispose();
root.setup(document.getElementById("divTree"));
bt_newitem.onclick = function(){
if(Global.selectedNode!=null){
writeDate(document.frames.fraGeneral,"");
changeModel(0);
var o = new Node("新接點(diǎn)","javascript:writeCode()","fraGeneral");
if(Global.selectedNode.childNodes.length>0Global.selectedNode.load==false){
Global.selectedNode.expand();
Global.selectedNode.load = false;
}else{
Global.selectedNode.load = true;
}
Global.selectedNode.add(o);
o.select();
o.edit();
var o_xml = new CLASS_XML("xml/data.xml");
var n = o_xml.selectSingleNode("http://*[@id=" + o.parent.key + "]");
var q = o_xml.createElement("item");
q.setAttribute("name","新接點(diǎn)");
q.setAttribute("id",o.key);
n.appendChild(q);
//保存菜單文件
o_xml.save();
o_xml.dispose();
}else{
g_prompt.show("請選擇要添加的接點(diǎn)欄目");
}
}
bt_delete.onclick = function(){
var _o = Global.selectedNode;
if(_o){
if(_o.childNodes.length==0){
var o_xml = new CLASS_XML("xml/data.xml");
var m = o_xml.selectSingleNode("http://*[@id=" + _o.key + "]");
if(m!=nullm.nodeName=="item"){
if(confirm("是否真的刪除接點(diǎn)[" + _o.text + "]?")){
m.parentNode.removeChild(m);
o_xml.save();
//刪除數(shù)據(jù)文件
deleteContent(_o.key);
_o.remove();
}
}else{
g_prompt.show("根接點(diǎn)不能刪除!");
}
o_xml.dispose();
}else{
g_prompt.show("有子接點(diǎn)不能刪除",true);
}
}else{
g_prompt.show("請選擇要刪除的接點(diǎn)");
}
}
bt_save.onclick = function(){
var _o = Global.selectedNode;
if(_o){
//獲取文本
var s = "";
var t = _o.text;
switch(_designMode){
case 0:
s = document.frames.fraGeneral.document.documentElement.outerHTML;
break;
case 1:
s = document.getElementById("editBox").innerText;
break;
case 2:
s = document.frames.fraPreview.document.documentElement.outerHTML;
default:
break;
}
//保存文本(dom.js)
if(saveContent(_o.key,t,s)){
g_prompt.show("[" + _o.text + "]保存成功!");
}else{
g_prompt.show("[" + _o.text + "]保存失?。?);
}
}else{
g_prompt.show("請選擇要保存的接點(diǎn)");
}
}
bt_update.onclick = function(){
var auto = new CLASS_AUTOUPDATE("CLASS_AUTOUPDATE",g_window);
auto.update();
}
/*
* 樹接點(diǎn)編輯事件
*/
Node.prototype.onAfterEdit = function(e,oldText,newText){
if(oldText!=newText){
var _o = Global.selectedNode;
_o.setText(this.text);
var o_xml = new CLASS_XML("xml/data.xml");
var m = o_xml.selectSingleNode("http://*[@id=" + _o.key + "]");
if(m!=null){
m.setAttribute("name",this.text);
m.setAttribute("password",this.password);
//保存菜單文件
o_xml.save();
var data = new CLASS_XML("xml\\" + _o.key + ".xml");
if(data.error == false){
var title = data.selectSingleNode("http://title");
if(title!=null){
title.setAttribute("value",this.text);
}
data.save();
}
data.dispose();
}else{
document.title = "Error:沒有找到接點(diǎn)" + _o.key;
}
o_xml.dispose();
this.select();
}
}
/*
* 接點(diǎn)拖動事件
*/
Node.prototype.onDrag = function(from,to){
var _f = from.path+"";
var _t = to.path+"";
if(_f.length_t.length_t.substring(0,_f.length)==_f){
g_prompt.show("不能移動到子接點(diǎn)");
return;
}
//處理樹
to.moveToChild(from);
/*
*開始移動接點(diǎn)
*/
var o_xml = new CLASS_XML("xml/data.xml");
//處理XML
var o_f = o_xml.selectSingleNode("http://*[@id=" + from.key + "]");
var o_t = o_xml.selectSingleNode("http://*[@id=" + to.key + "]");
o_t.appendChild(o_f);
o_xml.save();
o_xml.dispose();
}
Node.prototype.onExpand = function(n){
var o = this;
if(!this.load){
if(this.locked){
var r = window.showModalDialog("js/password.htm",this.key,"dialogHeight:80px;dialogWidth:250px;");
if(typeof(r)=="undefined"||r==0){
return false;
}else{
o.locked = false;
}
}
this.open = 1;
this.load = true;
var o_xml = new CLASS_XML("xml/data.xml");
var m = o_xml.selectSingleNode("http://*[@id=" + o.key + "]");
var f = o.getFirstChild();
f.remove();
//dom.js
loadChild(o,m);
o_xml.dispose();
}
return true;
}
document.frames.fraGeneral.document.designMode = "on";
//創(chuàng)建右鍵菜單
var g_rightmenu = new CLASS_RIGHTMENU(document.getElementById("test"),document.getElementById("divTree"),"xml/rightmenu.xml");
//創(chuàng)建分割條
var g_splitbar = new CLASS_SPLITBAR_HORIZON(document.getElementById("divSplit"),document.getElementById("divTree"),document.getElementById("divList"));
var auto = new CLASS_AUTOUPDATE("CLASS_AUTOUPDATE",g_window);
auto.check();
CLASS_TOOLBAR.prototype.highlight = doHighlight;
var g_toolbar = new CLASS_TOOLBAR(document.getElementById("cbHead"),document.frames.fraGeneral,g_window);
g_toolbar.path = skinPath;
//全局鍵盤事件
document.onkeydown = function(e){
var code,o;
//兼容nsie事件
if(!e) e = window.event;
//兼容nsie按鍵
code = e.which ? e.which : e.keyCode;
switch(code){
case 83:
case 115: //ctrl+s
if(e.ctrlKey){
document.getElementById("bt_save").click();
}
break;
case 110: //ctrl+n
case 78:
if(e.ctrlKey){
document.getElementById("bt_newitem").click();
}
break;
case 46: //delete
if(e.shiftKey){
document.getElementById("bt_delete").click();
}
break;
case 81: //ctrl+q
case 113:
if(e.ctrlKey)
{
changeModel(0,true);
}
break;
case 87: //ctrl+w
case 119:
if(e.ctrlKey)
{
changeModel(1,true);
}
break;
case 69: //ctrl+e,ctrl+b
case 101:
case 66:
case 98:
if(e.ctrlKey)
{
changeModel(2,true);
}
break;
default:break;
}
}
//開始畫面
about();
}
/*
* 數(shù)據(jù)導(dǎo)入導(dǎo)出
*/
function odata(flag){
var _o = Global.selectedNode;
if(_o){
if(flag){
outData(_o);
}else{
inData(_o);
}
}else{
g_prompt.show("請選擇要操作的接點(diǎn)");
}
}
/*
* 重命名接點(diǎn)
*/
function editNode(){
var _o = Global.selectedNode;
if(_o){
_o.edit();
}
}
/*
* 轉(zhuǎn)到連接
*/
function go(url){
changeModel(2,false);
document.getElementById("fraPreview").src = url;
}
/*
* 寫正文
*/
function writeCode(id){
//獲得接點(diǎn)的文本(dom.js)
var sid;
if(typeof(id)=="undefined"){
sid = Global.selectedNode.key;
if(Global.selectedNode.locked){
var r = window.showModalDialog("js/password.htm",Global.selectedNode.key,"dialogHeight:80px;dialogWidth:250px;");
if(typeof(r)=="undefined"||r==0){
Global.selectedNode.unselect();
return false;
}else{
Global.selectedNode.locked = false;
}
}
}else{
sid = id;
//判斷id是否是鎖定的
}
var s= readContent(sid);
changeModel(2,false);
writeDate(document.frames.fraPreview,s);
writeDate(document.frames.fraGeneral,s);
document.getElementById("editBox").innerText = s;
}
/*
* 關(guān)于
*/
function about(){
var doc = new CLASS_XML("xml\\autoupdate.xml");
var info= doc.selectNodes("http://UpdateInfo");
var ab = doc.selectSingleNode("http://About");
var ns = doc.selectSingleNode("http://nextversion");
var s = "";
if(doc.error==false){
if(ab!=null){
s += ab.childNodes[0].text;
}
for(var i=0;iinfo.length;i++){
//s += "xmp>" + info[i].childNodes[0].text + "/xmp>br>";
s += info[i].childNodes[0].text + "";
}
if(ns!=null){
s += ns.childNodes[0].text;
}
}else{
s = "讀配置文件失??!";
}
doc.dispose();
//切換瀏覽模式
changeModel(2,false);
//寫正文
writeDate(document.frames.fraPreview,s);
writeDate(document.frames.fraGeneral,s);
document.getElementById("editBox").innerText = s;
}
/*
* 寫框價數(shù)據(jù)
*/
function writeDate(fra,data){
fra.document.close();
fra.document.write(data);
fra.document.close();
}
/*
* 切換瀏覽模式
*/
function changeModel(n,flag){
var _dm=parseInt(n);
document.getElementById("Img_modelBtn").style.pixelTop=_dm*(-15);
var d = document.getElementById("editBox");
var g = document.getElementById("fraGeneral");
var p = document.getElementById("fraPreview");
var gd= document.frames.fraGeneral.document;
var pd= document.frames.fraPreview.document;
var c = document.getElementById("cbHead");
switch(_dm){
case 0: //普通
d.style.display = "none";
g.style.display = "";
p.style.display = "none";
c.style.display = "";
if(flag==true){
writeDate(document.frames.fraGeneral,d.innerText);
}
break;
case 1: //HTML
d.style.display = "";
g.style.display = "none";
p.style.display = "none";
c.style.display = "none";
if(flag==true){
d.innerText = gd.documentElement.outerHTML;
}
break;
case 2: //瀏覽
d.style.display = "none";
g.style.display = "none";
p.style.display = "";
c.style.display = "none";
if(flag==true){
if(_designMode==0){
writeDate(document.frames.fraPreview,gd.documentElement.outerHTML);
d.innerText = gd.documentElement.outerHTML;
}
if(_designMode==1){
writeDate(document.frames.fraGeneral,d.innerText);
writeDate(document.frames.fraPreview,d.innerText);
}
}
break;
}
_designMode = _dm;
}
function editTab(){
sel =event.srcElement.document.selection.createRange();
switch (event.keyCode){
case 8:
break
case 9:
sel.text = "\t\t\t\t";
event.returnValue = false;
break;
case 13 :
break;
default:
break;
}
}
//-->
/SCRIPT>
/head>
body marginleft=0 marginright=0 onload="init()" oncontextmenu="if(event.srcElement.tagName!='TEXTAREA'event.srcElement.tagName!='INPUT'event.srcElement.contentEditable!='true'){return false;}">
SCRIPT LANGUAGE="JavaScript">
!--
progressorbar.start();
//-->
/SCRIPT>
DIV id=test style="diaplay:none;position:absolute;">/DIV>
div id="logoBar" noWrap oncontextmenu ="return false;" onselectstart="return false;">b>Welcome to a href='mailto:ttyp@21cn.com'>font color='#ffffff'>ttyp/font>/a>/b>'s code collection v0.44,and enjoy it:)/div>
div id="toolBar" noWrap oncontextmenu ="return false;" onselectstart="return false;">
a href="#" class="bt_off" id="bt_newitem" hideFocus="true">div>/div>NewItem/a>a href="#" class="bt_off" id="bt_delete" hideFocus="true" style="border-right-width:0px">div>/div>Delete/a>a href="#" class="bt_off" id="bt_save" hideFocus="true" style="border-right-width:1px">div>/div>Save/a>
span id="settingBar">
a href="#" class="setting" id="bt_update" hideFocus="true" style="border-right:0px">Update/a>
/span>
/div>
/div>
div id="divTree" xmlSrc="xml/data.xml">/div>
div id="divList" onfocus="this.blur();">
div id=cbHead style="display:none;">/div>
div id="divContent">
iframe id="fraGeneral" name="fraGeneral" style="display:none;" frameborder=0 width="100%" height="100%" marginwidth=0 marginheight=0 >/iframe>
iframe id="fraPreview" name="fraPreview" style="display:none;" frameborder=0 width="100%" height="100%" marginwidth=0 marginheight=0 >/iframe>
div id="editBox" name="editBox" style="width:100%;height:100%;" marginheight="1" marginwidth="1" contenteditable="true" onselectstart="event.cancelBubble=true;" designMode="off" oncontextmenu="return true;" onkeydown="editTab()">/div>
/div>
SPAN STYLE="position:absolute;width:123;height:15;clip: rect(0 123 15 0)" onfocus="this.blur();">
IMG ID="Img_modelBtn" style="border:0" SRC="skin/default/img/editmode.gif" STYLE="position:absolute;top:0;left:0" usemap="#MBtnMap">
/SPAN>
/div>
div id="divSplit">/div>
map name="MBtnMap">
area shape="rect" coords="0, 0, 40, 44" alt="普通設(shè)計模式" onclick="changeModel(0,true)">
area shape="rect" coords="41, 0, 81, 44" alt="HTML原碼模式" onclick="changeModel(1,true)">
area shape="rect" coords="82, 0, 122, 44" alt="預(yù)覽模式" onclick="changeModel(2,true)">
/map>
/body>
/html>
SCRIPT language=JavaScript src="js/plugin.js">/script>