📄 common.js
字号:
/**
##
# Project: PHPDisk
# This is NOT a freeware, use is subject to license terms.
#
# Site: http://www.phpdisk.com
#
# $Id: common.js 232 2009-03-08 04:54:57Z along $
#
# Copyright (C) 2008-2009 PHPDisk Team. All Rights Reserved.
#
##
*/
String.prototype.strtrim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}
function addEvent( obj, type, fn, userCapture )
{
userCapture = userCapture || false;
if (obj.addEventListener)
obj.addEventListener( type, fn, userCapture );
else if (obj.attachEvent)
{
obj["e"+type+fn] = fn;
obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
obj.attachEvent( "on"+type, obj[type+fn] );
}
}
function removeEvent( obj, type, fn, userCapture )
{
userCapture = userCapture || false;
if (obj.removeEventListener)
obj.removeEventListener( type, fn, userCapture );
else if (obj.detachEvent)
{
obj.detachEvent( "on"+type, obj[type+fn] );
obj[type+fn] = null;
obj["e"+type+fn] = null;
}
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}
else {
window.onload = function() {
oldonload();
func();
}
}
}
function resize(obj,type) {
if(type == 'plus'){
var newheight = parseInt($(obj).style.height, 10) + 50;
$(obj).style.height = newheight + 'px';
}else{
var newheight = parseInt($(obj).style.height, 10) - 50;
if(newheight > 0) {
$(obj).style.height = newheight + 'px';
}
}
}
function createHttpRequest(){
var xmlhttp;
try{
xmlhttp = new XMLHttpRequest();
if(xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType('text/xml');
}
}catch(e){
try{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}catch(e){
try{
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
}catch(e){
alert('Ajax error!');
}
}
}
return xmlhttp;
}
function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+"="+escape( value ) +
( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function deleteCookie( name, path, domain ) {
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
var menuTimer = null;
function show_menu(obj1,obj2,state,location){
var btn=$(obj1);
var obj=$(obj2);
var h=btn.offsetHeight;
var w=btn.offsetWidth;
var x=btn.offsetLeft;
var y=btn.offsetTop;
obj.onmouseover =function(){
show_menu(obj1,obj2,'show',location);
}
obj.onmouseout =function(){
show_menu(obj1,obj2,'hide',location);
}
while(btn=btn.offsetParent){y+=btn.offsetTop;x+=btn.offsetLeft;}
var hh=obj.offsetHeight;
var ww=obj.offsetWidth;
var xx=obj.offsetLeft;
var yy=obj.offsetTop;
var obj2state=state.toLowerCase();
var obj2location=location.toLowerCase();
var showx,showy;
if(obj2location=="left" || obj2location=="top" || obj2location=="right" || obj2location=="bottom"){
if(obj2location=="left"){showx=x-ww;showy=y;}
if(obj2location=="top"){showx=x;showy=y-hh;}
if(obj2location=="right"){showx=x+w;showy=y;}
if(obj2location=="bottom"){showx=x;showy=y+h;}
}else{
showx=xx;showy=yy;
}
obj.style.left=showx+"px";
obj.style.top=showy+"px";
if(state =="hide"){
menuTimer =setTimeout("_hide_menu('"+ obj2 +"')", 1);
}else{
clearTimeout(menuTimer);
obj.style.visibility ="visible";
}
}
function _hide_menu(id){
$(id).style.visibility ="hidden";
}
function show_thumb(id,str){
var xmlhttp = createHttpRequest();
xmlhttp.open("get","ajax.php?action="+str+"&file_id="+id,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
$('thb_'+id).src = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -