$(function() {
$(".header .nav .nav-li").eq(2).addClass("ac");
layui.form.on('select()', function (data) {
if (data.elem.id == "subject" || data.elem.id == "grade") {
Search();
}
});
});
var searcharea = $('#SearchArea');
function Search() {
var url = location.href;
var m = url.indexOf('?')
if (m > 0) {
url = url.substring(0, m)
}
searcharea.find('select[name],input[name]').each(function() {
var obj = $(this);
var val = obj.val();
var prompt = obj.attr('placeholder');
if (val != 0 && (!prompt || (prompt && prompt != val)))
url += (url.indexOf('?') > 0 ? '&' : '?') + obj.attr('name') + '=' + encodeURI(val);
});
searcharea.find('a.ac').each(function() {
var obj = $(this);
var con = obj.attr('url');
if (con) {
url += (url.indexOf('?') > 0 ? '&' : '?') + con;
}
});
location.href = url;
}
$(function() {
$(".view-by-category .category-list .btn").on("click", function() {
$(this).addClass("ac").siblings(".btn").removeClass('ac');
});
$(".category-detail-list .category-item ol li").on("click", function() {
if (!$(this).hasClass('ac')) {
$(this).addClass("ac").siblings("li").removeClass('ac');
}
});
//收藏
$(".cright").on("click", ".specific-question-ul .collection", function() {
var curli = $(this).parent().parent().parent();
var curqueid = curli.attr("qid");
var subject = Request("subject");
if (subject == "" || subject == null) {
subject = "KM01";
}
var curthis = $(this);
if (!$(this).hasClass('ac')) { //收藏
$.post('collectques', "qbankid=" + curqueid + "&subject=" + subject, function(data) {
if (data == "-1")
{
ShowLogin();
} else if (data == "-2")
{
ShowSubcribe();
}
else if (data == "1") {
curthis.text("取消收藏");
//$("#").modal("hide");//隐藏modal
curthis.toggleClass("ac");
} else
alert('收藏失败!请稍后再试');
});
} else { //取消收藏
var cid = $(this).attr("cid")
$.post('cancelcollect', "collectid=" + cid, function(data) {
if (data == "-1") {
ShowLogin();
}
else if (data == "1") {
curthis.text("收藏");
curthis.toggleClass("ac");
//$("#").modal("hide");//隐藏modal
} else
alert('取消失败,请稍后再试');
});
}
});
//纠错
var curqueid
$(".cright").on("click", ".specific-question-ul .error-correction", function() {
var curli = $(this).parent().parent().parent();
curqueid = curli.attr("qid");
});
$("#error-correction-modal").on("click", ".save", function() {
var con = $("#errortext").val();
if (con == "" || con == null) {
alert("纠错内容不能为空!");
return;
}
var subject = Request("subject");
if (subject == "" || subject == null) {
sub = "KM01";
}
$.post('AddError', "qbankid=" + curqueid + "&content=" + con + "&subject=" + subject, function(data) {
if (data == "-1") {
ShowLogin();
}else if(data=="1"){
alert('保存成功,审核通过之后会更新试题!');
$("#errortext").val('');
$("#error-correction-modal").modal("hide"); //隐藏modal
} else
alert('保存失败!请稍后再试');
});
});
var fmAdd = $('#analysis-modal');
fmAdd.on('shown.bs.modal', function(event) {
var cur = $(event.relatedTarget);
var curobj = cur.parent().parent().parent();
fmAdd.find(".question-topic").html(curobj.find(".questiondiv").html());
fmAdd.find(".answer").html("【答案】 " + curobj.find(".answerdiv").html());
fmAdd.find(".analysis-info").html("【解析】" + curobj.find(".analydiv").html());
});
});
$(function() {
// 数据统计
var dataStatistic = $('#dataStatistic');
//if ($("#dataStatistic")[0]) {
//var seriesData = [500, 1000, 600];
//$(seriesData).each(function (i, v) { $(".data-statistic .dataStatistic-text p").eq(i).append(v); });
var seriesData = [];
dataStatistic.next().children().each(function () {
seriesData.push(parseInt($(this).text().split(':')[1]));
});
var myChart = echarts.init(dataStatistic[0]);
var option = {
title: { text: '数据统计', textStyle: { color: '#333', fontSize: 14 } },
grid: { bottom: 10, top: 50, left: 10, right: 10 },
xAxis: {
type: 'category', data: ['试题总量', '试题浏览总量', '今日浏览试题'],
axisLine: { lineStyle: { color: '#999' } }, axisTick: { show: false }, axisLabel: { show: false, interval: 0 }
},
tooltip: { show: true },
yAxis: { show: false },
series: [{
data: seriesData,
type: 'bar',
itemStyle: {
normal: { color: function (params) { var colorList = ['#8c69dc', '#69dcd5', '#6aa6e5']; return colorList[params.dataIndex]; } }
},
label: { normal: { show: true, position: 'top', } }, barWidth: 15
}]
};
myChart.setOption(option);
//}
});
document.oncontextmenu = function (evt) {
evt.preventDefault();
}
document.onbeforecopy = function (evt) {
evt.preventDefault();
return false;
};
document.oncopy = function (evt) {
evt.preventDefault();
return false;
};
document.onkeydown = document.onkeyup = document.onkeypress = function (event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e && e.keyCode == 123) {
e.returnValue = false;
return (false);
}
}