123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- var editor="";
- var editor2="";
- var art_editor;
- var notify = null;
- var isNotifyShowing = false;
- var isError = false;
- $(function() {
- Notification.requestPermission(function(status) {});
- $("#addanswerkvip").click(function (){
- if(!editor.hasContents()){ //此处以非空为例
- alert("请输入内容");
- return false;
- }
-
- });
- $("#addansweragainkvip").click(function (){
- if(!editor2.hasContents()){ //此处以非空为例
- alert("请输入内容");
- return false;
- }
-
- });
- // 轮询查找是否有未处理的审批
- var permission = Notification.permission;
- if (permission === 'granted') {
- var interval = setInterval(checkNotify, 60000);
- if (isError) {
- clearInterval(interval);
- }
- }
- });
- /**
- * 获取未审批数量
- */
- function checkNotify() {
- $.ajax({
- url: '/examine_check',
- type: 'get',
- data: '',
- dataType: 'json',
- error: function() {
- console.log('数据错误');
- isError = true;
- },
- success: function(response) {
- var count = response.count;
- count = parseInt(count);
- if (count > 0 && !isNotifyShowing) {
- notify = new Notification("你有"+ count +"条问答需要审批", {
- icon: '/global/img/wen.png',
- body: '点击本消息可跳转至审批页',
- silent: true
- });
- notify.onclick = function() {
- notify.close();
- window.location.href = '/index/main_examine_manage';
- };
- notify.onshow = function () {
- isNotifyShowing = true;
- };
- notify.onclose = function () {
- isNotifyShowing = false;
- };
- }
- }
- });
- }
-
- function login_form() {
- var name = $("#name").val();
- var password = $("#password").val();
- if (name.length == 0 || password.length == 0) {
- alert('提示');
- return false;
- }
- }
- function user_form(){
- var password = $("#password").val();
-
- var confirmpw = $("#confirmpw").val();
-
- if (password != confirmpw) {
- alert('密码不一致');
- return false;
- }
- }
- function article_form(){
- var title = $("#title").val();
-
- if (title == "") {
- alert('请填写相关信息');
- return false;
- }
- }
- //选中所有用户
- function checkall(name) {
- var e = is_ie ? event : checkall.caller.arguments[0];
- obj = is_ie ? e.srcElement : e.target;
- var arr = document.getElementsByName(name);
- var k = arr.length;
- for(var i=0; i<k; i++) {
- arr[i].checked = obj.checked;
- }
- }
- //选中删除用户
- function remove(){
- if($("input[name='uid[]']:checked").length == 0){
- alert('你没有选择任何用户');
- return false;
- }
- if(confirm('是否同时删除用户的所有问答?')==true){
- document.userForm.action="/index/main_user_manage_delete/all";
- document.userForm.submit();
- }else{
- // document.userForm.action="/index/main_user_manage_delete/some";
- // document.userForm.submit();
- }
- }
- //设置问题状态
- function set_status_question(){
- if($("input[name='id[]']:checked").length == 0){
- alert('你没有选择任何问题');
- return false;
- }
-
- if(confirm('确认将问题设置为未解决.只针对已关闭的问题')==true){
- document.userForm.action="/index/main_question_manage_set_status";
- document.userForm.submit();
- }else{
-
- }
- }
- //关闭选中问题
- function colse_question(){
- if($("input[name='id[]']:checked").length == 0){
- alert('你没有选择任何问题');
- return false;
- }
- if(confirm('确认关闭选中问题')==true){
- document.userForm.action="/index/main_question_manage_close";
- document.userForm.submit();
- }else{
-
- }
- }
- //选中删除问题
- function remove_question(){
- if($("input[name='id[]']:checked").length == 0){
- alert('你没有选择任何问题');
- return false;
- }
- if(confirm('确认删除选中问答?此操作不可返回')==true){
- document.userForm.action="/index/main_question_manage_delete";
- document.userForm.submit();
- }else{
-
- }
- }
- //选中删除问题
- function remove_article(){
- if($("input[name='id[]']:checked").length == 0){
- alert('你没有选择任何公告');
- return false;
- }
- if(confirm('确认删除选中公告?此操作不可返回')==true){
- document.userForm.action="/index/main_article_delete_manage";
- document.userForm.submit();
- }else{
-
- }
- }
- function group_form(){
- var grouptitle = $("#grouptitle").val();
-
- if (grouptitle=="") {
- alert('请填写用户组名称');
- return false;
- }
- }
- var userAgent = navigator.userAgent.toLowerCase();
- var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
- var is_moz = (navigator.product == 'Gecko')
- && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
- var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera)
- && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
- function getbyid(id) {
- return document.getElementById(id);
- }
- Array.prototype.push = function(value) {
- this[this.length] = value;
- return this.length;
- }
- function _attachEvent(obj, evt, func) {
- if (obj.addEventListener) {
- obj.addEventListener(evt, func, false);
- } else if (obj.attachEvent) {
- obj.attachEvent("on" + evt, func);
- }
- }
- function _cancelBubble(e, returnValue) {
- if (!e)
- return;
- if (is_ie) {
- if (!returnValue)
- e.returnValue = false;
- e.cancelBubble = true;
- } else {
- e.stopPropagation();
- if (!returnValue)
- e.preventDefault();
- }
- }
- function checkall(name) {
- var e = is_ie ? event : checkall.caller.arguments[0];
- obj = is_ie ? e.srcElement : e.target;
- var arr = document.getElementsByName(name);
- var k = arr.length;
- for ( var i = 0; i < k; i++) {
- arr[i].checked = obj.checked;
- }
- }
- function getposition(obj) {
- var r = new Array();
- r['x'] = obj.offsetLeft;
- r['y'] = obj.offsetTop;
- while (obj = obj.offsetParent) {
- r['x'] += obj.offsetLeft;
- r['y'] += obj.offsetTop;
- }
- return r;
- }
- function addMouseEvent(obj) {
- var checkbox, atr, ath, i;
- atr = obj.getElementsByTagName("tr");
- for (i = 0; i < atr.length; i++) {
- atr[i].onclick = function() {
- ath = this.getElementsByTagName("th");
- checkbox = this.getElementsByTagName("input")[0];
- if (!ath.length && checkbox.getAttribute("type") == "checkbox") {
- if (this.className != "currenttr") {
- this.className = "currenttr";
- checkbox.checked = true;
- } else {
- this.className = "";
- checkbox.checked = false;
- }
- }
- }
- }
- }
- // editor.js
- if (is_ie)
- document.documentElement.addBehavior("#default#userdata");
- function setdata(key, value) {
- if (is_ie) {
- document.documentElement.load(key);
- document.documentElement.setAttribute("value", value);
- document.documentElement.save(key);
- return document.documentElement.getAttribute("value");
- } else {
- sessionStorage.setItem(key, value);
- }
- }
- function getdata(key) {
- if (is_ie) {
- document.documentElement.load(key);
- return document.documentElement.getAttribute("value");
- } else {
- return sessionStorage.getItem(key)
- && sessionStorage.getItem(key).toString().length == 0 ? ''
- : (sessionStorage.getItem(key) == null ? '' : sessionStorage
- .getItem(key));
- }
- }
- function form_option_selected(obj, value) {
- for ( var i = 0; i < obj.options.length; i++) {
- if (obj.options[i].value == value) {
- obj.options[i].selected = true;
- }
- }
- }
- function setselect(selectobj, value) {
- var len = selectobj.options.length;
- for (i = 0; i < len; i++) {
- if (selectobj.options[i].value == value) {
- selectobj.options[i].selected = true;
- }
- }
- }
- function show(id, display) {
- if (!getbyid(id))
- return false;
- if (display == 'auto') {
- getbyid(id).style.display = getbyid(id).style.display == '' ? 'none'
- : '';
- } else {
- getbyid(id).style.display = display;
- }
- }
- function category_form(){
- var title = $("#name").val();
-
- if (title == "") {
- alert('请填写相关信息');
- return false;
- }
- }
- //选中删除分类
- function remove_category(){
- if($("input[name='id[]']:checked").length == 0){
- alert('你没有选择任何分类');
- return false;
- }
- if(confirm('确认删除选中分类和属于该分类的所有问题?此操作不可返回')==true){
- document.userForm.action="/index/main_category_delete_manage";
- document.userForm.submit();
- }else{
-
- }
- }
- //选中删除分类
- function remove_answer(){
- if($("input[name='id[]']:checked").length == 0){
- alert('你没有选择回答');
- return false;
- }
- if(confirm('确认删除选中回答?此操作不可返回')==true){
- document.userForm.action="/index/main_answer_manage_delete";
- document.userForm.submit();
- }else{
-
- }
- }
|