⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base.js

📁 学生选课系统 赶快来下载啊啊好东西 呵呵啊啊 啊啊啊啊啊
💻 JS
📖 第 1 页 / 共 5 页
字号:
			mq.scrollRight();
		}
	},

	scrollTop : function(){
		var mq = this;
		if(mq.currScroll == mq.clientScroll){
			if(mq.scrollDistance - mq.clientScroll <= mq.body.scrollTop){
				mq.body.scrollTop = mq.scrollDistance/2 - mq.clientScroll;
			}
			mq.currScroll = 0;
			if(mq.interValId != null){
				clearInterval(mq.interValId);
				mq.interValId = null;
			}
			var scrollFunc = mq.goon.bind(mq);
			mq.timerId = setTimeout(scrollFunc, mq.delayTime);
		}else{
			mq.body.scrollTop += mq.step;
			mq.currScroll += mq.step;
		}
	},

	scrollBottom : function(){
		var mq = this;
		if(mq.currScroll == mq.clientScroll){
			if(mq.clientScroll >= mq.body.scrollTop){
				mq.body.scrollTop += mq.scrollDistance/2;
			}
			mq.currScroll = 0;
			if(mq.interValId != null){
				clearInterval(mq.interValId);
				mq.interValId = null;
			}
			var scrollFunc = mq.goon.bind(mq);
			mq.timerId = setTimeout(scrollFunc, mq.delayTime);
		}else{
			mq.body.scrollTop -= mq.step;
			mq.currScroll += mq.step;
		}
	},

	scrollLeft : function(){
		var mq = this;
		if(mq.currScroll == mq.clientScroll){
			if(mq.scrollDistance - mq.clientScroll <= mq.body.scrollLeft){
				mq.body.scrollLeft = mq.scrollDistance/2 - mq.clientScroll;
			}
			mq.currScroll = 0;
			if(mq.interValId != null){
				clearInterval(mq.interValId);
				mq.interValId = null;
			}
			var scrollFunc = mq.goon.bind(mq);
			mq.timerId = setTimeout(scrollFunc, mq.delayTime);
		}else{
			mq.body.scrollLeft += mq.step;
			mq.currScroll += mq.step;
		}
	},

	scrollRight : function(){
		var mq = this;
		if(mq.currScroll == mq.clientScroll){
			if(mq.clientScroll >= mq.body.scrollLeft){
				mq.body.scrollLeft += mq.scrollDistance/2;
			}
			mq.currScroll = 0;
			if(mq.interValId != null){
				clearInterval(mq.interValId);
				mq.interValId = null;
			}
			var scrollFunc = mq.goon.bind(mq);
			mq.timerId = setTimeout(scrollFunc, mq.delayTime);
		}else{
			mq.body.scrollLeft -= mq.step;
			mq.currScroll += mq.step;
		}
	}
}


function Hashtable(){
  this._hash = new Object();
  this._size = 0;

  this.add=function add(key, value, childs){
    //alert("OK");
    //alert(typeof(key)!="undefined");
    //alert(this.contains(key));
    if(typeof(key)!="undefined"  && !this.contains(key)){
      var _h = new Object();
      _h.key = key;
      _h.value=typeof(value)=="undefined"?null:value;
      _h.childs = typeof(childs)=="undefined"?null:childs;
      this._hash[key] = _h;
      this._size++;
      //alert("add:" + this._hash[key]);
    }else{
      var _h = this._hash[key];
      _h.value=typeof(value)=="undefined"?null:value;
      _h.childs = typeof(childs)=="undefined"?null:childs;
      //alert("update:" + this._hash[key]);
    }
    return this;
  }

  this.addValue=function addValue(key, value){
    if(typeof(key)!="undefined"  && !this.contains(key)){
      var _h = new Object();
      _h.key = key;
      _h.value=typeof(value)=="undefined"?null:value;
      this._hash[key] = _h;
      this._size++;
      //alert("addValue add:" + this._hash[key]);
    }else{
      var _h = this._hash[key];
      _h.value=typeof(value)=="undefined"?null:value;
      //alert("addValue update:" + this._hash[key]);
    }
    return this;
  }

  this.addChilds=function addChilds(key, childs){
    if(typeof(key)!="undefined"  && !this.contains(key)){
      var _h = new Object();
      _h.key = key;
      _h.childs = typeof(childs)=="undefined"?null:childs;
      this._hash[key] = _h;
      this._size++;
      //alert("addChilds add:" + this._hash[key]);
    }else{
      var _h = this._hash[key];
      _h.childs = typeof(childs)=="undefined"?null:childs;
      //alert("addChilds update:" + this._hash[key]);
    }
    return this;
  }


  this.value=function value(key){
    return this._hash[key].value;
    if(o == null){
      return "";
    }
    return o;
  }

  this.childs=function childs(key){
    return this._hash[key].childs;
  }

  this.contains = function(key){
    return typeof(this._hash[key])!="undefined";
  }

  this.size=function size(){
    return this._size;
  }

  this.hash=function hash(){
    return this._hash;
  }
}


//------注册相关

// 检查用户ID是否已经存在
function checkUserId(){
  $('_registerfn').value = 'CheckUser';
  formSubmit('registerForum');
}

// 检查用户昵称是否已经存在

function checkUserNickname(){
  $('_registerfn').value = 'CheckUserNickname';
  formSubmit('registerForum');
}

// 检查Email已经存在
function checkEmail(){
  $('_registerfn').value = 'CheckEmail';
  formSubmit('registerForum');
}

//预览用户头像
var UploadFile = Class.create();

UploadFile.prototype={
  initialize : function(file, fileExt, fileMaxSize){
		var upload = this;
		upload.fileObj = $(file);
		upload.fileCopy = upload.fileObj.cloneNode(true);
		upload.format = fileExt;
		upload.needCheckSize = true;
		upload.fileMaxSize = fileMaxSize;
		if(upload.fileObj == null) return;
		Event.addEvent(upload.fileObj, "onchange", upload.checkUpload.bind(upload));
		upload.fileImg = $(file + "_fimg");
		if(upload.fileImg){
			if(fileMaxSize == null || fileMaxSize<=0) {
				upload.needCheckSize = false;
			}
		}else{
			upload.needCheckSize = false;
		}
	},

	checkUpload: function(){
		var upload = this;
		if(!upload.checkFileFormat(upload)){
			alert('文件格式不符合要求,请重新选择图片');
			upload.clearUpload(upload);
			return;
		}
		if(upload.needCheckSize){
			upload.tmpImg = document.createElement("img");
			Event.addEvent(upload.tmpImg, "onreadystatechange", upload.checkFileSize.bind(upload));
			upload.tmpImg.src = upload.fileObj.value;
		}
	},
	
	checkFileFormat: function(upload){
		var format = upload.format;
		if(format == null) return true;
		var filename = upload.fileObj.value;
		if(filename == null) return true;
		var len = filename.length;
		var i= filename.lastIndexOf('.');
		if(i == -1) return false;
		var pfx = filename.substring(i+1, len);
		if(format.indexOf(pfx.toLowerCase())==-1){
			return false;
		}else{
			return true;
		}
	},

	checkFileSize: function(){
		var upload = this;
		if(upload.tmpImg.readyState == "complete"){
			var maxsize = upload.fileMaxSize;
			var picsize = upload.tmpImg.fileSize/1024;
			if(picsize > maxsize){
				alert("文件尺寸过大,请重新选择图片");
				upload.clearUpload(upload);
			}else{
				upload.fileImg.src = upload.tmpImg.src;
			}
			upload.tmpImg.removeNode(true);
			upload.tmpImg = null;
		}
	},

	clearUpload: function(upload){
		var copy = upload.fileCopy.cloneNode(true);
		var parentObj = upload.fileObj.parentNode;
		var nextObj = upload.fileObj.nextSibling;
		parentObj.removeChild(upload.fileObj);
		parentObj.insertBefore(copy, nextObj);
		upload.fileObj = $(copy);
		Event.addEvent(upload.fileObj, "onchange", upload.checkUpload.bind(upload));
	}
}



/**
 * 标签搜索业务,选择论坛版面
 */
function selectForum(forumId,forumName){
  $("forum_id").value = forumId;
  $("forum_name").innerHTML = forumName;
}

/**
 * 更多相似标签搜索
 */
function doMoreTagSearch(tagName){
  $("_pNo").value = "1";
  $("tag_name").value = tagName;
  $("tagSearch").submit();
}

//返回当前键盘按钮键值

function getKeyCode(event){
  return event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
}

//按回车提交登陆

function commitLogin(event){
 //回车
 if (getKeyCode(event) == 13){
    formSubmit("loginForm");
 }
}

//复选框全部选中
function checkAll(form,checkBoxName){
  for (var i=0;i<form.elements.length;i++) { 
    var e = form.elements[i]; 
    if (e.name == checkBoxName &&e.disabled!=true){ 
      e.checked = form.chkAll.checked; 
    }
  }
}

//显示注册条款
function showRegisterClause(){
  showWindow(_contextPath+"/register.do?_fn=ViewResiterClause", 600, 520, "注册条款","no",true);
  return false;
}

//控制同意按钮实效时间的js;
function setRegisterButton(secs){
  var wait = secs * 1000;
  $('agree_submit').value = "同 意(" + secs + ")";
  $('agree_submit').disabled = true;
  for(i = 1; i <= secs; i++) {
    window.setTimeout("update(" + i + "," +wait + ")", i * 1000);
  }
  window.setTimeout("timer()", wait);
}

//注册计数器

function update(num,wait) {
  if(num == (wait/1000)) {
    $('agree_submit').value = "同 意";
  } else {
    printnr = (wait / 1000) - num;
    $('agree_submit').value = "同 意("+ printnr +")";
  }
}

//注册计数结束
function timer() {
  $('agree_submit').disabled = false;
  $('agree_submit').value = "同 意";
}

// 根据是否同意,转到不同页面;
function agreeClause(obj,button){
  if(button){
    button.disabled="true";
  }
  if(obj == "yes"){
    window.location="register.do?_fn=ViewRegister&viewrule=1";
  }else{
    window.location="index.fhtml";
  }
}

//注册高级选项的显示和隐藏
function showRegisterAdv(){
  var adv = $("registerAdv");
  var hasAdv = $("showAdvanceInfo");

  if(adv.className=="registerAdvHidden"){
    adv.className="registerAdvShow";
	hasAdv.value="0";
  }else{
    adv.className="registerAdvHidden";
	hasAdv.value="1";
  }
}

// 装载页面时判断是否需要显示高级选项
function checkRegisterAdv(){
  var adv = $("registerAdv");
  var hasAdv = $("showAdvanceInfo");
  var checkBox = $("advCheckBox");
  if(hasAdv.value=="0"){
    adv.className="registerAdvShow";
	checkBox.checked=true;
  }else{
    adv.className="registerAdvHidden";
	checkBox.checked=false;
  }
}

//联动:初始化国家
function initCountry(countryId, provinceId, cityId){
  $('user_country').options.length = 0;
  var i = 0;
  for(var key in Country.hash()){ 
    $('user_country').options[i] = new Option(Country.value(key), key);
    if(key == countryId){
      $('user_country').options[i].selected = true;
    }
    i++;
  }
  initProvince(provinceId);
  initCity(cityId);
}

//联动:初始化省

function initProvince(provinceId){
  var countryId = $('user_country').value;
  $('user_province').options.length = 0;
  var i = 0;
  var province = Country.childs(countryId);
  if(province == null) {
    $('user_province').style.visibility = "hidden";
    $('user_city').style.visibility = "hidden";
    return;
  }
  $('user_province').style.visibility = "visible";
  for(var key in province.hash()){ 
    $('user_province').options[i] = new Option(province.value(key), key);
    if(key == provinceId){
      $('user_province').options[i].selected = true;
    }
    i++;
  }
  initCity(-1);
}

//联动:初始化城市
function initCity(cityId){
  var countryId = $('user_country').value;
  var provinceId = $('user_province').value;
  $('user_city').options.length = 0;
  var i = 0;
  var prov = Country.childs(countryId);
  if(prov == null){
    $('user_city').style.visibility = "hidden";
    return;
  }
  var city = prov.childs(provinceId);
  if(city == null) {
    $('user_city').style.visibility = "hidden";
    return;
  }
  $('user_city').style.visibility = "visible";
  for(var key in city.hash()){ 
    $('user_city').options[i] = new Option(city.value(key), key);
    if(key == cityId){
      $('user_city').options[i].selected = true;
    }
    i++;
  }
}


//高亮风格
function highLightTemp(obj){
  theobject=obj;
  if(browser.isIE){
    highlighting=setInterval("highLightIE(theobject)",30);
  }else if(browser.isNS){
    highlighting=setInterval("highLightFF(theobject)",30);
  }
}

//减亮风格
function lowLightTemp(obj,val){
  theobject=obj;
  if(browser.isIE){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -