您的位置:首页 > 其它

写了几个类,希望对大家有用。

2006-12-20 00:00 393 查看
1.日历


#oContainer {
width: 193px;
padding: 3px;
background-color: menu;
border-left: buttonhighlight 1px solid;
border-top: buttonhighlight 1px solid;
border-right: buttonshadow 1px solid;
border-bottom: buttonshadow 2px solid;
}
.DateTable {
font: 10pt;
word-break: break-all;
}
.WeekTd, .BlankTd {
font: 10pt;
border: 1px solid menu;
}
.Today {
font: 10pt;
color: red;
cursor: hand;
position: relative;
left: 1px;
top: 1px;
border-left: 1px solid dimgray;
border-top: 1px solid dimgray;
border-right: 1px solid white;
border-bottom: 1px solid white;
}
.MonthTd {
font: 10pt;
font-family: webdings;
cursor: hand;
border: 1px solid menu;
zmm: expression(onmouseenter = function() {
style.color = 'red';
},
onmouseout = function() {
style.color = '';
});
}
.SelectTd {
border: 1px solid menu;
}
.over {
position: relative;
cursor: hand;
border-right: 1px solid buttonshadow;
border-bottom: 1px solid buttonshadow;
border-left: 1px solid buttonhighlight;
border-top: 1px solid buttonhighlight;
}
.out {
border-left: 1px solid buttonface;
border-top: 1px solid buttonface;
border-right: 1px solid buttonface;
border-bottom: 1px solid buttonface;
}
.down {
position: relative;
left: 1px;
top: 1px;
border-left: 1px solid dimgray;
border-top: 1px solid dimgray;
border-right: 1px solid white;
border-bottom: 1px solid white;
}


var oDate = new Object();

function DateClass(_container) {
this.author = '51JS.COM-ZMM';
this.version = 'Web Calendar 1.0';
this.container = _container;
this.weekArr = ['日', '一', '二', '三', '四', '五', '六'];
this.dateArr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

this.showTable = function(_year, _month) {
this.container.innerHTML = this.getDateTable(_year, _month);
}

this.getDateTable = function(_year, _month) {
if (this.checkArgs(_year, _month)) {
_year = parseInt(this.checkDate(_year, _month).split('-')[0]);
_month = parseInt(this.checkDate(_year, _month).split('-')[1]);
this.Thead = '\n';
this.Thead += '3';
this.Thead += '';
for (var i=1900; i 0) {
_left.style.top = _right.style.top = _oTop + 1 + 'px';
var oTime = window.setTimeout('oCouplet.doScroll()', this.delay);
} else {
window.clearTimeout(oTime);
}
} else {
if ((_oTop - _nTop) > 0) {
_left.style.top = _right.style.top = _oTop - 1 + 'px';
var oTime = window.setTimeout('oCouplet.doScroll()', this.delay);
} else {
window.clearTimeout(oTime);
}
}
}
}
window.onload = function() {
var oTop = 50, oWidth = 120, oHeight = 250, oOffset = 20;
var oDelay = 80, oAmount = 1;
oCouplet = new Couplet(oTop, oWidth, oHeight, oOffset, oDelay, oAmount);
with (document.body) {
innerHTML += oCouplet.drawCouplet(self.oContent.innerHTML);
onscroll = function() {
oCouplet.doScroll();
}
}
}




对联内容




[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
5.图片轮换


var oInterval, oTime, oRotator = new Object();

function Rotator(_container, _width, _height, _array, _delay) {
this.author = '51JS.COM-ZMM';
this.version = 'Rotator 1.0';
this.container = _container;
this.width = _width;
this.height = _height;

this.box = (function(_container, _width, _height) {
var _box = document.createElement('DIV');
_box.id = 'RotatorBox';
_box.align = 'center';
_box.style.width = _width;
_box.style.height = _height;
_box.style.border = '1px solid menu';
_box.style.overflow = 'hidden';
return _box;
})(this.container, this.width, this.height);
this.container.appendChild(this.box);
this.sAmount = 0;

this.drawRotator = function(_array, _delay) {
this.delay = _delay;
var _bool = (_array.length == 3);
_bool = _bool & (_array[0].length == _array[1].length);
_bool = _bool & (_array[0].length == _array[2].length);
_bool = _bool & (_array[1].length == _array[2].length);
if (_bool) {
this.itemArr = [];
this.panel = (function(_width, _height, _array) {
var _panel = document.createElement('DIV');
_panel.style.position = 'absolute';
_panel.style.top = '0px';
_panel.style.left = '0px';
return _panel;
})(this.width, this.height, _array);
for (var i=0; i this.rowsCount ? this.rowsCount : _datas.length ;
for (var i = 0; i < _itemNum; i ++) {
var n = 0;
for (j = 0; j < this.items.length - 2; j ++) {
if (j % 2 == 0) {
var _dataPanel = document.createElement('NOBR');
var _tableCell = this.items[j].firstChild.rows[i].cells[0];
with (_dataPanel) {
style.width = this.itemWidth;
style.overflow = 'hidden';
style.textOverflow = 'ellipsis';
innerHTML = _datas[i][n];
}
_tableCell.innerHTML = new String();
_tableCell.appendChild(_dataPanel);
_tableCell.title = _datas[i][0];
n ++;
}
}
}
},

selectedRow : function(n) {
for (var i = 0; i < this.items.length; i++) {
if (i % 2 == 0) {
var _table = this.items[i].firstChild;
for (var j = 0; j < _table.rows.length; j ++) {
var _dataPanel = _table.rows[j].cells[0].children[0];
if (typeof _dataPanel != 'undefined') {
if (j == n) {
_table.rows[j].cells[0].style.color = 'highlighttext';
_table.rows[j].cells[0].style.backgroundColor = 'highlight';
} else {
_table.rows[j].cells[0].style.color = '';
_table.rows[j].cells[0].style.backgroundColor = '';
}
var _children = _table.rows[j].cells[0].firstChild.children;
this.changeChild(_children, j == n);
}
}
}
}
},

changeChild : function(_children, _isSelected) {
if (typeof _children != 'undefined') {
for (var i = 0; i < _children.length; i ++) {
if (_isSelected) {
_children[i].style.color = 'highlighttext';
_children[i].style.backgroundColor = 'highlight';
} else {
_children[i].style.color = '';
_children[i].style.backgroundColor = '';
}
}
} else {
return false;
}
},

showSelected : function(n) {
var _text = new String();
for (var i = 0; i < this.items.length - 2; i++) {
if (i % 2 == 0) {
var _table = this.items[i].firstChild;
_text += this.headers[i].innerText + ':\n';
_text += _table.rows[n].cells[0].firstChild.innerHTML + '\n\n';
}
}
alert(_text);
}
}

function initListView() {
var _headers = [];
_headers[_headers.length] = '标题';
_headers[_headers.length] = '内容';
_headers[_headers.length] = '时间';
_headers[_headers.length] = '管理';
var _aligns = [];
_aligns[_aligns.length] = 'left';
_aligns[_aligns.length] = 'left';
_aligns[_aligns.length] = 'center';
_aligns[_aligns.length] = 'center';
oListView = new listView(self.oContainer);
oListView.drawListView(_headers, _aligns);

var _items = [];
_items[_items.length] = ['标题一', '内容一', '2006-6-21 10:30:00', '编辑 删除'];
_items[_items.length] = ['标题二', '内容二', '2006-6-21 14:20:12', '编辑 删除'];
_items[_items.length] = ['标题三', '内容三', '2006-6-21 20:45:36', '编辑 删除'];
oListView.addListItem(_items);
}

attachEvent('onload', initListView);




[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
7.表单多文件上传类 [ASP]

2 Then
ReDim Preserve itemStart(itemCount)
ReDim Preserve itemLength(itemCount)
itemStart(itemCount) = iStart
itemLength(itemCount) = iLength
itemCount = itemCount + 1
End If
Loop
Call FillItemValue
End Function

Private Function FillItemValue
Dim dataPart, bInfor
Dim iStart : iStart = 1
Dim iCount : iCount = 0
Dim iCheck : iCheck = StrToByte("filename")
For i = 0 To itemCount - 1
ReDim Preserve itemName(iCount)
ReDim Preserve itemData(iCount)
ReDim Preserve extenArr(iCount)
ReDim Preserve dataStart(iCount)
ReDim Preserve dataLength(iCount)
dataPart = MidB(formData, itemStart(i), itemLength(i))
iStart = InStrB(1, dataPart, ChrB(34)) + 1
iLength = InStrB(iStart, dataPart, ChrB(34)) - iStart
itemName(iCount) = FormItemName(MidB(dataPart, iStart, iLength))
iStart = InStrB(1, dataPart, bVBCrlf) + 4
iLength = LenB(dataPart) - iStart + 1
If InStrB(1, dataPart, iCheck) > 0 Then
bInfor = MidB(dataPart, 1, iStart - 5)
extenArr(iCount) = FileExtenName(bInfor)
If Mid(folderPath, Len(folderPath) - 1) = "/" Then
itemData(iCount) = folderPath & GetRndName(6) & extenArr(iCount)
Else
itemData(iCount) = folderPath & "/" & GetRndName(6) & extenArr(iCount)
End If
dataStart(iCount) = itemStart(i) + iStart - 2
dataLength(iCount) = iLength
Else
extenArr(iCount) = ""
itemData(iCount) = ByteToStr(MidB(dataPart, iStart, iLength))
dataStart(iCount) = ""
dataLength(iCount) = ""
End If
iCount = iCount + 1
Next
Call SaveUpload
End Function

Private Function FormItemName(byVal bName)
FormItemName = ByteToStr(bName)
End Function

Private Function FileExtenName(byVal bInfor)
Dim pStart, pLength, pContent, regEx
pStart = InStr(1, ByteToStr(bInfor), "filename=" & Chr(34)) + 10
pLength = InStr(pStart, ByteToStr(bInfor), Chr(34)) - pStart
pContent = Mid(ByteToStr(bInfor), pStart, pLength)
If pContent = "" Then
FileExtenName = ""
Else
Set regEx = New RegExp
regEx.Pattern = "^.*(\.[^\.]*)$"
regEx.Global = False
regEx.IgnoreCase = True
FileExtenName = regEx.Replace(pContent, "$1")
Set regEx = Nothing
End If
End Function

Private Function GetRndName(byVal sLen)
Dim regEx, sTemp, arrFields, n : n = 0
Set regEx = New RegExp
regEx.Pattern = "[^\d]*"
regEx.Global = True
regEx.IgnoreCase = True
sTemp = regEx.Replace(Now, "") & "-"
Set regEx = Nothing
arrFields = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", _
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", _
"u", "v", "w", "x", "y", "z", "A", "B", "C", "D", _
"E", "F", "G", "H", "I", "J", "K", "L", "M", "N", _
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", _
"Y", "Z")
Randomize
Do While n < sLen
sTemp = sTemp & CStr(arrFields(61 * Rnd))
n = n + 1
Loop
GetRndName = sTemp
End Function

Private Function SaveUpload
Dim isValidate
Dim filePath, oStreamGet, oStreamPut
isValidate = CheckFile
If isValidate Then
For i = 0 To itemCount - 1
If (dataStart(i) "") And (dataLength(i) "") Then
If dataLength(i) = 0 Then
itemData(i) = ""
Else
filePath = Server.MapPath(itemData(i))
If CreateFolder("|", ParentFolder(filePath)) Then
Set oStreamGet = Server.CreateObject("ADODB.Stream")
oStreamGet.Type = 1
oStreamGet.Mode = 3
oStreamGet.Open
oStreamGet.Write formData
oStreamGet.Position = dataStart(i)
Set oStreamPut = Server.CreateObject("ADODB.Stream")
oStreamPut.Type = 1
oStreamPut.Mode = 3
oStreamPut.Open
oStreamPut.Write oStreamGet.Read(dataLength(i))
oStreamPut.SaveToFile(filePath)
oStreamGet.Close
Set oStreamGet = Nothing
oStreamPut.Close
Set oStreamPut = Nothing
End If
End If
End If
Next
Finished = True
Call ItemToColl
Else
Finished = False
End If
End Function

Private Function CheckFile
Dim oBoolean : oBoolean = True
If cFields = "" Then
oBoolean = oBoolean And True
Else
For i = 0 To itemCount - 1
If extenArr(i) "" Then
If InStr(1, Ucase(cFields), "|" & Ucase(Mid(extenArr(i), 2)) & "|") > 0 Then
oBoolean = oBoolean And True
Else
sErrors = sErrors & "表单[ " & itemName(i) & " ]的文件格式错误!\n" & _
"支持的格式为:" & Replace(Mid(cFields, 2, Len(cFields) - 1), "|", " ") & "\n\n"
oBoolean = oBoolean And False
End If
End If
Next
End If
CheckFile = oBoolean
End Function

Private Function CreateFolder(byVal sLine, byVal sPath)
Dim oFso
Set oFso = Server.CreateObject("Scripting.FileSystemObject")
If Not oFso.FolderExists(sPath) Then
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "^(.*)\\([^\\]*)$"
regEx.Global = False
regEx.IgnoreCase = True
sLine = sLine & regEx.Replace(sPath, "$2") & "|"
sPath = regEx.Replace(sPath, "$1")
If CreateFolder(sLine, sPath) Then CreateFolder = True
Set regEx = Nothing
Else
If sLine = "|" Then
CreateFolder = True
Else
Dim sTemp : sTemp = Mid(sLine, 2, Len(sLine) - 2)
If InStrRev(sTemp, "|") = 0 Then
sLine = "|"
sPath = sPath & "\" & sTemp
Else
Dim Folder : Folder = Mid(sTemp, InStrRev(sTemp, "|") + 1)
sLine = "|" & Mid(sTemp, 1, InStrRev(sTemp, "|") - 1) & "|"
sPath = sPath & "\" & Folder
End If
oFso.CreateFolder sPath
If CreateFolder(sLine, sPath) Then CreateFolder = True
End if
End If
Set oFso = Nothing
End Function

Function ParentFolder(byVal sPath)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "^(.*)\\[^\\]*$"
regEx.Global = True
regEx.IgnoreCase = True
ParentFolder = regEx.Replace(sPath, "$1")
Set regEx = Nothing
End Function

Private Function StrToByte(byVal sText)
For i = 1 To Len(sText)
StrToByte = StrToByte & ChrB(Asc(Mid(sText, i, 1)))
Next
End Function

Private Function ByteToStr(byVal sByte)
Dim oStream
Set oStream = Server.CreateObject("ADODB.Stream")
oStream.Type = 2
oStream.Mode = 3
oStream.Open
oStream.WriteText sByte
oStream.Position = 0
oStream.CharSet = "gb2312"
oStream.Position = 2
ByteToStr = oStream.ReadText
oStream.Close
Set oStream = Nothing
End Function

Private Function ItemToColl
For i = 0 To itemCount - 1
If Not Form.Exists(itemName(i)) Then
Form.Add itemName(i), itemData(i)
End If
Next
End Function

Private Sub Class_Terminate
Form.RemoveAll
Set Form = Nothing
End Sub
End Class

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Rem 建立上传类实例
Set oUpload = New Upload
Rem 指定允许上传文件的类型
oUpload.CheckFields = "|GIF|BMP|JPG|"
Rem 指定上传文件所存储的相对路径
oUpload.Folder = "51JS.COM-ZMM/UploadFile"
Rem 开始上传处理
oUpload.Start
If oUpload.Finished Then
Rem 上传成功,显示上传信息
Dim sHtml : sHtml = ""
sHtml = sHtml & ""
sHtml = sHtml & ""
sHtml = sHtml & "上传表单数据
"
sHtml = sHtml & "标题:
" & oUpload.Form("P_title") & "
"
sHtml = sHtml & "类型:
" & oUpload.Form("P_assort") & "
"
sHtml = sHtml & "小图:
服务器端路径:" & oUpload.Form("P_image_s") & "
"
sHtml = sHtml & "中图:
服务器端路径:" & oUpload.Form("P_image_m") & "
"
sHtml = sHtml & "大图:
服务器端路径:" & oUpload.Form("P_image_b") & "
"
sHtml = sHtml & "介绍:
" & oUpload.Form("P_content") & "
"
sHtml = sHtml & ""
sHtml = sHtml & ""
Response.Write sHtml
Response.End
Else
Rem 上传失败,显示错误信息
Call ShowMsg(oUpload.ErrMessage, Request.ServerVariables("SCRIPT_NAME"))
End If
Rem 对话框提示函数
Function ShowMsg(byVal sText, byVal sTarget)
Dim sScript : sScript = ""
sScript = sScript & "" & vbCrlf & _
"window.alert('" & sText & "');" & vbCrlf & _
"window.location.replace('" & sTarget & "');" & vbCrlf & _
""
Response.Write sScript
Response.End
End Function
End If
%>



多文件、表单混合上传类


body {
margin: 0px;
border: 0px;
font-size: 10pt;
}
table {
border-collapse: collapse;
font-size: 10pt;
}
td {
font-size: 10pt;
}


function formCheck(_form) {
for (var i = 0; i < _form.elements.length; i ++) {
if (_form.elements[i].value == '') {
window.alert('请将表单填写完整,提交失败!');
return false;
}
}
return true;
}









上传功能测试




标题:



类型:


电子
医疗




小图:



中图:



大图:



介绍:




















[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
8.TabPage类


body {
background-color: menu;
}

#oContainer {
width: 500px;
height: 400px;
}


var oTabPage = new Object();

var TabPage = function(_container) {
this.author = '51JS.COM-ZMM';
this.version = 'TabPage 1.0';
this.container = _container;
this.barHeight = 22;
this.put_barHeight = function(_height) { return _height; };
this.get_barHeight = function() { return this.barHeight; };
this.guideWidth = 82;
this.put_guideWidth = function(_width) { return _width; };
this.get_guideWidth = function() { return this.guideWidth; };
}

TabPage.prototype = {
boxInit : function() {
this.box = (function(_object) {
var _box = document.createElement('DIV');
with (_box) {
style.width = _object.offsetWidth;
style.height = _object.offsetHeight;
style.padding = '0px';
}
return _box;
})(this.container);
this.box.appendChild(this.bar = (function(_height) {
var _bar = document.createElement('DIV');
with (_bar) {
align = 'left';
style.width = '100%';
style.height = _height;
style.padding = '0px';
attachEvent('oncontextmenu', new Function('return false'));
attachEvent('onselectstart', new Function('return false'));
}
return _bar;
})(this.barHeight));
this.box.appendChild(this.page = (function(_height) {
var _page = document.createElement('DIV');
with (_page) {
style.width = '100%';
style.height = _height;
style.fontSize = '12px';
style.textAlign = 'left';
style.padding = '5px';
style.borderLeft = '1px solid white';
style.borderRight = '2px outset';
style.borderBottom = '2px outset';
style.backgroundColor = 'menu';
}
return _page;
})(parseInt(this.box.style.height) - this.barHeight));
this.container.appendChild(this.box);
},

addTabPage : function(_guides, _contents) {
this.guides = [];
this.contents = [];
for (var i = 0; i < _contents.length; i ++) {
var _page = document.createElement('DIV');
with (_page) {
style.display = (i == 0) ? 'inline' : 'none' ;
innerHTML = _contents[i].innerHTML;
_contents[i].removeNode(true);
}
this.page.appendChild(_page);
this.contents[this.contents.length] = _page;
}
this.bar.appendChild((function(_object) {
var _table = document.createElement('TABLE');
with (_table) {
width = '100%';
cellSpacing = 0;
cellPadding = 0;
style.tableLayout = 'fixed';
}
var _tbody = document.createElement('TBODY');
var _tr = document.createElement('TR');
for (var i = 0; i < _guides.length; i ++) {
var _td = document.createElement('TD');
with (_td) {
vAlign = 'bottom';
style.width = _object.guideWidth;
if (i != 0) style.borderBottom = '1px solid white';
appendChild (_object.guides[_object.guides.length] = (function(n) {
var _guide = document.createElement('SPAN');
with (_guide) {
style.width = _object.guideWidth - 2;
style.fontSize = '12px';
style.textAlign = 'center';
style.cursor = 'default';
style.paddingTop = '3px';
style.borderLeft = '1px solid white';
style.borderTop = '1px solid white';
style.backgroundColor = 'menu';
if (i == 0) {
style.height = _object.barHeight;
_contents[i].style.display = 'inline';
} else {
style.height = _object.barHeight - 4;
}
innerText = _guides[i];
attachEvent('onselectstart', new Function('return false;'));
attachEvent('onmousedown', function() {
with (oTabPage) {
for (var j = 0; j < guides.length; j ++) {
if (guides[j] == event.srcElement) {
guides[j].style.height = _object.barHeight;
guides[j].nextSibling.style.height = _object.barHeight;
guides[j].parentNode.style.borderBottom = '0px';
contents[j].style.display = 'inline';
} else {
guides[j].style.height = _object.barHeight - 4;
guides[j].nextSibling.style.height = _object.barHeight - 4;
guides[j].parentNode.style.borderBottom = '1px solid white';
contents[j].style.display = 'none';
}
}
}
});
}
return _guide;
})(i));
}
_td.appendChild((function(o, n) {
var _line = document.createElement('SPAN');
with (_line) {
style.width = '2px';
style.height = (n == 0) ? o.barHeight : o.barHeight - 4 ;
style.borderLeft = '1px solid dimgray';
style.borderRight = '1px solid black';
}
return _line;
})(_object, i));
_tr.appendChild(_td);
}
_tr.appendChild((function() {
var _surplus = document.createElement('TD');
with (_surplus) {
style.width = '100%';
style.borderBottom = '1px solid white';
innerHTML = ' ';
}
return _surplus;
})());
_tbody.appendChild(_tr);
_table.appendChild(_tbody);
return _table;
})(this));
}
}

attachEvent('onload', function() {
var _guideArr = ['基本信息', '划分类别', '简单介绍'];
var _contentArr = [Content1, Content2, Content3];

oTabPage = new TabPage(self.oContainer);
oTabPage.boxInit();
oTabPage.addTabPage(_guideArr, _contentArr);
});





标题:

来源:



分类: 计算机网络计算机软件


测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: