This commit is contained in:
xice09
2018-05-30 15:31:33 +08:00
commit 4815ee7832
34 changed files with 18348 additions and 0 deletions

1277
js/form.js Normal file

File diff suppressed because it is too large Load Diff

110
js/init.js Normal file
View File

@@ -0,0 +1,110 @@
(function ($) {
'use strict';
$(function () {
// Plugin initialization
$('.scrollspy').scrollSpy();
$('.button-collapse').sideNav();
$('.materialboxed').materialbox();
$('select').material_select();
// Floating-Fixed table of contents
setTimeout(function () {
var tocWrapperHeight = 0,
/*Max height of ads.*/ tocHeight = $('.toc-wrapper .table-of-contents').length ? $('.toc-wrapper .table-of-contents').height() : 0,
socialHeight = $('nav').height(),
/*Height of unloaded social media in footer.*/ footerOffset = $('body>footer').first().length ? $('body>footer').first().offset().top : 0,
bottomOffset = footerOffset - socialHeight - tocHeight - tocWrapperHeight;
if ($('nav').length) {
$('.toc-wrapper').pushpin({
top: $('nav').height(),
width: $('.toc-wrapper').width(),
bottom: bottomOffset
});
} else if ($('#index-banner').length) {
$('.toc-wrapper').pushpin({
top: $('#index-banner').height(),
width: $('.toc-wrapper').width(),
bottom: bottomOffset
});
} else {
$('.toc-wrapper').pushpin({
top: 0,
width: $('.toc-wrapper').width(),
bottom: bottomOffset,
});
}
}, 100);
}); // end of document ready
})(jQuery); // end of jQuery name space
// Back to top & Header change
$(document).ready(function ($, document, undefined) {
'use strict';
var offset = 300,
//browser window scroll (in pixels) after which the "back to top" link opacity is reduced
offset_opacity = 1100,
//duration of the top scrolling animation (in ms)
scroll_top_duration = 700,
//grab the "back to top" link
$back_to_top = $('.c-button'),
header_offset = 300,
//browser window scroll (in pixels) after which "heander change"
$header_hidden = $('.Sticky'),
$header_show = $(".PageHeader");
//hide or show the "back to top" link
$(window).scroll(function () {
if ($(this).scrollTop() > offset) {
$back_to_top.addClass('cd-is-visible');
$back_to_top.removeClass('cd-fade-out');
} else {
$back_to_top.removeClass('cd-is-visible cd-fade-out');
}
if ($(this).scrollTop() > offset_opacity) {
$back_to_top.addClass('cd-fade-out');
}
if ($(this).scrollTop() > header_offset) {
$header_hidden.addClass('is-hidden');
$header_show.addClass('is-shown');
} else {
$header_hidden.removeClass('is-hidden');
$header_show.removeClass('is-shown');
}
});
//button ripple effice
var $ripple = $('.js-ripple');
$ripple.on('click.ui.ripple', function (e) {
var $this = $(this);
var $offset = $this.parent().offset();
var $circle = $this.find('.c-ripple__circle');
var x = e.pageX - $offset.left;
var y = e.pageY - $offset.top;
$circle.css({
top: y + 'px',
left: x + 'px'
});
$this.addClass('is-active');
//smooth scroll to top
if ($(this).hasClass('backtotop')) {
e.preventDefault();
$('body,html').animate({
scrollTop: 0,
}, scroll_top_duration);
}
});
$ripple.on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function () {
$(this).removeClass('is-active');
});
}); // end of back to top

4
js/jquery-2.1.4.min.js vendored Normal file

File diff suppressed because one or more lines are too long

8032
js/materialize.js vendored Normal file

File diff suppressed because one or more lines are too long

253
js/questionnaire.js Normal file
View File

@@ -0,0 +1,253 @@
//共占用3个变量名myFun,addOne,checkedInfo
var checkInfo, addOne;
//////////////////////////////////////////////////////////////////////////////////////////
(function(window) {
//倒计时
function remtime(timesec, clearT, fun) {
function countdown() {
function formatTime(sec) {
function fix(n) {
if (n < 10) return "0" + n.toString();
else return n;
// return n<10?'0'+n.toString():n;
}
return fix(Math.floor(sec / 60)) + ":" + fix(sec % 60);
}
timesec--;
var timeTmp=formatTime(timesec);
for (var e_array = document.getElementsByName('remtime'), i = e_array.length - 1; i >= 0; i--) {
e_array[i].innerText = timeTmp;
}
if (!timesec) {
clearTimeout(timer);
$.isFunction(fun) && fun();
}
if (!clearT[0]) {
clearTimeout(timer);
}
}
var timer = setInterval(countdown, 1000);
}
//边框效果--移入
function borderShow(obj) {
var hh = $(obj).height() + 50,
ww = $(obj).width() + 50;
$(obj).find('.biankuang_1').stop(true).animate({
height: hh
}, 300);
$(obj).find('.biankuang_2').stop(true).delay(300).animate({
width: ww
}, 300);
$(obj).find('.biankuang_3').stop(true).animate({
height: hh
}, 300);
$(obj).find('.biankuang_4').stop(true).delay(300).animate({
width: ww
}, 300);
}
//边框效果--移出
function borderHidden(obj) {
$(obj).find('.biankuang_1').stop(true).delay(100).animate({
height: '0px'
}, 100);
$(obj).find('.biankuang_2').stop(true).animate({
width: '0px'
}, 100);
$(obj).find('.biankuang_3').stop(true).delay(100).animate({
height: '0px'
}, 100);
$(obj).find('.biankuang_4').stop(true).animate({
width: '0px'
}, 100);
}
window.myFun = [remtime, borderShow, borderHidden];
})(window);
//////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
var clearT = [1],
//正则匹配规则
theRegex = [
/^[\u4e00-\u9fa5]{2,5}$/,
/^((200|199)\d|201[0-7])\d{6}$/,
/^[\u4e00-\u9fa5]{2,}$/,
/^[\u4e00-\u9fa5]{2,}$/,
/^1\d{10}$/
],
eName = [
"user_name",
"student_id",
"school",
"userclass",
"telephone"
],
lableValue = new Array(),
questionNum,
questionsChecked = new Array();
//初始化 questionNum
questionNum = document.getElementById("ppp").getAttribute('ppp');
//初始化数组 labelValue & questionChecked
for (var i = eName.length - 1; i >= 0; i--) {
lableValue[i] = $("#" + eName[i] + "_label").html();
}
for (var i = questionNum - 1; i >= 0; i--) {
questionsChecked[i] = 0;
}
//倒计时器
//name="remtime"
//remtime(sec,callback);
startremtime=function(){
myFun[0](600, clearT,
function() {
var btn = document.getElementById("submit");
$("#form1").ajaxSubmit({
beforeSubmit: function() {
if (!clearT[0]) {
return false;
}
},
success: function(responseText) {
clearT[0] = 0;
alert("时间到!");
alert(responseText);
}
});
btn.setAttribute('class', btn.getAttribute('class') + ' disabled');
});
}
//当鼠标离开节点时调用此方法,验证节点内容是否符合注册规范
checkInfo = function(node, num) {
var label_id = "#" + eName[num] + "_label";
console.log(node.value);
if (!theRegex[num].test(node.value) && !node.value.length == 0) { //验证是否符合节点对应的正则表达式
$(node).css("box-shadow", "0 1px 0 0 red");
$(node).css("border-bottom", "1px solid red"); //不符合,相应内容变成红色
$(label_id).html("请填写正确的" + lableValue[num] + "");
$(label_id).css("color", "red");
} else {
$(node).css("box-shadow", "0 1px 0 0 #26a69a");
$(node).css("border-bottom", "1px solid #26a69a"); //符合,相应内容变成绿色
$(label_id).html(lableValue[num]);
$(label_id).css("color", "#9e9e9e");
}
};
addOne = function(node) {
var sum = 0;
for (var i = questionNum; i > 0; i--) {
if ($(node).attr('name') == "answer_" + i) {
questionsChecked[i - 1] = 1;
break;
}
}
for (var i = questionNum - 1; i >= 0; i--) {
sum += questionsChecked[i];
}
$(".determinate").css("width", 100 * sum / questionNum + "%");
};
//表单验证
requestFirst = function() {
var ifblock = new Array(),
scroll_top_duration = 600; //ms
for (var i = eName.length - 1; i >= 0; i--) {
ifblock[i] = $.trim(document.getElementById(eName[i]).value);
}
//判断姓名和学好是否填写
for (var i = 0; i <= ifblock.length - 1; i++) {
if (ifblock[i].length == 0) {
Materialize.toast(lableValue[i] + '不能为空!', 4000);
$('body,html').animate({
scrollTop: 0
}, 400);
return false;
} else if (!theRegex[i].test(ifblock[i])) {
Materialize.toast(lableValue[i] + '不正确!', 4000);
$('body,html').animate({
scrollTop: 0
}, 400);
return false;
}
}
$("#information").hide();
$("#hiddenDisplay").hide();
$("#hiddenBefore").show();
$("#submit").show();
$("#theFooter").show();
startremtime();
return true;
}
function showRequest() {
var ifblock = new Array(),
scroll_top_duration = 600; //ms
for (var i = eName.length - 1; i >= 0; i--) {
ifblock[i] = $.trim(document.getElementById(eName[i]).value);
}
//判断姓名和学好是否填写
for (var i = 0; i <= ifblock.length - 1; i++) {
if (ifblock[i].length == 0) {
Materialize.toast(lableValue[i] + '不能为空!', 4000);
$('body,html').animate({
scrollTop: 0
}, 400);
return false;
} else if (!theRegex[i].test(ifblock[i])) {
Materialize.toast(lableValue[i] + '不正确!', 4000);
$('body,html').animate({
scrollTop: 0
}, 400);
return false;
}
}
//判断题目是非选择
for (var i = 1; i <= questionNum; i++) {
var answerno = "answer_" + i, //遍历每到题目
isAutoSend = document.getElementsByName(answerno),
nochecked = 0;
for (var x = 0; x < isAutoSend.length; x++) {
if (isAutoSend[x].checked) {
nochecked = 1;
break;
}
}
if (nochecked == 0) {
var question = "question_" + i,
obj = document.getElementsByName("div_e")[i - 1];
Materialize.toast("第" + i + "题未选择", 3000);
$('body,html').animate({
scrollTop: $(document.getElementById(question)).offset().top - 75
}, scroll_top_duration,
function() {
myFun[1](obj);
setTimeout(function() { myFun[2](obj) }, 1200);
}
);
return false;
}
}
//alert("提交成功。谢谢参与我们的活动请继续关注我们公众号bupt_stu的后续推送。现在你可以直接关闭页面了。"); //Alert("post success.");
if (!clearT[0]) {
return false;
}
return true;
}
function showResponse(responseText) {
clearT[0] = 0;
alert(responseText);
window.location.href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MjM5NzY1MjYyMg==&scene=124#wechat_redirect";
}
var options = {
beforeSubmit: showRequest,
success: showResponse
};
$("#form1").ajaxForm(options);
});