this.id = config.id;
this.author = config.author;
this.price = config.price;
this.publisher = config.publisher;
this.count = config.count;
this.insertData() ;
insertData : function()
>
var book = doc.createElement("book");
book.setAttribute("id", this.id);
var name = doc.createElement("name");
var nameValue = doc.createTextNode(this.name);
name.appendChild(nameValue);
var author = doc.createElement("author");
var authorValue = doc.createTextNode(this.author);
author.appendChild(authorValue);
var 価格 = doc.createElement("price");
varpriceValue = doc.createTextNode(this.price);
price.appendChild(priceValue);
var count = doc.createElement("count") ");
var countValue = doc.createTextNode(this.count);
count.appendChild(countValue);
book.appendChild(count);
var Publisher = doc.createElement("publisher ");
varpublisherValue = doc.createTextNode(this.publisher);
publisher.appendChild(publisherValue);
book.appendChild(publisher);
if(doc.documentElement == null)
{
books = doc.createElement("books");
books.appendChild(book);
doc.appendChild(books);
}
else
{
books = doc.documentElement;
books.appendChild(book) ;
}
doc.save("books.xml" );
}
}
window.js ソース コード::
コードをコピー
コードは次のとおりです:
var windows = ClassModel.create();
windows.prototype =
{
construct : function(jsonObject)
{
this.title = jsonObject.title;
this.width = jsonObject.width;
this.height = jsonObject.height;
this.titleColor = jsonObject.titleColor;
this.backgroundColor = jsonObject.backgroundColor;
this.LwHeight = (document.body.clientHeight - this.width) / 2; //div 画面画面の中间
this.LwWidth = (document.body.clientWidth - this.height) / 2; //div 画面画面の中の
this.content = jsonObject.content;
var loginWindow = this.createLoginBody();
var title = this.createLoginTitle();
loginWindow.appendChild(title);
var cont = this.createContent();
loginWindow.appendChild(続き);
document.body.appendChild(loginWindow);
},
createLoginBody: function() //创建登陆框,即整个框
{
var loginWindow = document.createElement("div");
loginWindow.id = "ダイアログ";
with(loginWindow.style)
{
border = "1px 単色白";
位置 = "絶対";
width = this.width "px";
高さ = this.height "px";
top = this.LwHeight "px";
left = this.LwWidth "px";
backgroundColor = this.backgroundColor;
}
ログインウィンドウを返す;
},
createLoginTitle:function() //创建标题即効图的黑色标题
{
var title = document.createElement("div");
var table = document.createElement("table");
var tbody = document.createElement("tbody");
var tr = document.createElement("tr");
var td_1 = document.createElement("td");
var td_2 = document.createElement("td");
var close = document.createElement("a");
close.onclick = function()
{
document.body.removeChild(title.parentNode);
}
close.innerHTML = "X";
td_1.innerHTML = this.title;
with(title.style)
{
width = "100%";
高さ = this.height / 10 "ピクセル";
backgroundColor = this.titleColor;
}
with(table.style)
{
color = "白";
fontSize = "12pt";
幅 = "100%";
backgroundColor = this.titleColor;
色 = "赤";
}
td_2.style.textAlign = "右";
td_2.appendChild(close);
tr.appendChild(td_1);
tr.appendChild(td_2);
tbody.appendChild(tr);
table.appendChild(tbody);
title.appendChild(テーブル);
タイトルを返します;
},
createContent : function()
{
var div = document.createElement("div");
if(typeof(this.content) == 'string')
{
div.innerHTML = this.content;
}else
{
div.appendChild(this.content);
}
with(div.style)
{
paddingLeft = "80px";
paddingTop = "50px";
float = "左";
幅 = "100%";
}
div を返します。
}
}
book_infor.jsソースコード::
var doc = new ActiveXObject("Msxml2.DOMDocument.3.0");
doc.load("books.xml");
var query = ClassModel.create();
var v = 0;
query.prototype =
{
construct : function()
{
this.bookInfor();
},
bookInfor : function()
{
var div = document.createElement("div");
var root = doc.documentElement;
if(root == null)
{
div.innerHTML = "データなし";
document.body.appendChild(div);
}else
{
with(div.style)
{
marginLeft = "200px";
オーバーフロー = "自動";
border = "0px 単色白";
幅 = "605px";
}
var table = document.createElement("table");
table.cellSpacing = "0";
with(table.style)
{
fontSize = "12pt";
色 = "白";
border = "0px";
幅 = "600px";
}
var tbody = document.createElement("tbody");
var trHead = document.createElement("tr");
with(trHead.style)
{
height = "20px";
backgroundColor = "透明";
}
var tname = document.createElement("td");
var tauthor = document.createElement("td");
var tprice = document.createElement("td");
var tCount = document.createElement("td");
var tpublisher = document.createElement("td");
tname.innerHTML = "名前";
tauthor.innerHTML = "作成者";
tprice.innerHTML = "价格";
tCount.innerHTML = "库存";
tpublisher.innerHTML = "出版社";
tname.style.borderBottom = "1px ソリッド";
tauthor.style.borderBottom = "1px ソリッド";
tprice.style.borderBottom = "1px ソリッド";
tCount.style.borderBottom = "1px ソリッド";
tpublisher.style.borderBottom = "1px ソリッド";
tname.style.width = "20%";
tauthor.style.width = "20%";
tprice.style.width = "20%";
tCount.style.width = "20%";
tpublisher.style.width = "20%";
trHead.appendChild(tname);
trHead.appendChild(tauthor);
trHead.appendChild(tprice);
trHead.appendChild(tCount);
trHead.appendChild(tpublisher);
tbody.appendChild(trHead);
for(var c = 0; c < root.getElementsByTagName("book").length; c )
{
varroot = root.getElementsByTagName("本")[c];
var id =roots.getAttribute("id");
var name =roots.getElementsByTagName("name")[0].childNodes[0].nodeValue;
var author =roots.getElementsByTagName("author")[0].childNodes[0].nodeValue;
var 価格 =roots.getElementsByTagName("価格")[0].childNodes[0].nodeValue;
var count =roots.getElementsByTagName("count")[0].childNodes[0].nodeValue;
var Publisher =roots.getElementsByTagName("publisher")[0].childNodes[0].nodeValue;
var tr = document.createElement("tr");
with(tr.style)
{
backgroundColor = "透明";
}
var tdName = document.createElement("td");
var tdAuthor = document.createElement("td");
var tdPrice = document.createElement("td");
var tdCount = document.createElement("td");
var tdPublisher = document.createElement("td");
tdName.innerHTML = 名前;
tdAuthor.innerHTML = 著者;
tdPrice.innerHTML = 価格;
tdCount.innerHTML = カウント;
tdPublisher.innerHTML = パブリッシャー;
tdName.id = "tdName" c;
tdAuthor.id = "tdAuthor" c;
tdPrice.id = "tdPrice" c;
tdCount.id = "tdCount" c;
tdPublisher.id = "tdPublisher" c;
tr.appendChild(tdName);
tr.appendChild(tdAuthor);
tr.appendChild(tdPrice);
tr.appendChild(tdCount);
tr.appendChild(tdPublisher);
tbody.appendChild(tr);
tdName.onmouseover = function(){
document.body.style.cursor= "ポインター";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdName.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdAuthor.onmouseover = function(){
document.body.style.cursor= "ポインター";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdAuthor.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdPrice.onmouseover = function(){
document.body.style.cursor= "ポインター";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdPrice.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdCount.onmouseover = function(){
document.body.style.cursor= "ポインター";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdCount.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdPublisher.onmouseover = function(){
document.body.style.cursor= "ポインター";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdPublisher.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
}
table.appendChild(tbody);
div.appendChild(テーブル);
document.body.appendChild(div);
}
}
}