var BROWSER = {}; var USERAGENT = navigator.userAgent.toLowerCase(); BROWSER.ie = window.ActiveXObject && USERAGENT.indexOf('msie') != -1 && USERAGENT.substr(USERAGENT.indexOf('msie') + 5, 3); BROWSER.firefox = document.getBoxObjectFor && USERAGENT.indexOf('firefox') != -1 && USERAGENT.substr(USERAGENT.indexOf('firefox') + 8, 3); BROWSER.chrome = window.MessageEvent && !document.getBoxObjectFor && USERAGENT.indexOf('chrome') != -1 && USERAGENT.substr(USERAGENT.indexOf('chrome') + 7, 10); BROWSER.opera = window.opera && opera.version(); BROWSER.safari = window.openDatabase && USERAGENT.indexOf('safari') != -1 && USERAGENT.substr(USERAGENT.indexOf('safari') + 7, 8); BROWSER.other = !BROWSER.ie && !BROWSER.firefox && !BROWSER.chrome && !BROWSER.opera && !BROWSER.safari; BROWSER.firefox = BROWSER.chrome ? 1 : BROWSER.firefox; var marked_row = new Array; function PMA_markRowsInit() { // for every table row ... var rows = document.getElementsByTagName('tr'); for ( var i = 0; i < rows.length; i++ ) { // ... with the class 'odd' or 'even' ... if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) { continue; } // ... add event listeners ... // ... to highlight the row on mouseover ... if ( navigator.appName == 'Microsoft Internet Explorer' ) { // but only for IE, other browsers are handled by :hover in css rows[i].onmouseover = function() { this.className += ' hover'; } rows[i].onmouseout = function() { this.className = this.className.replace( ' hover', '' ); } } // Do not set click events if not wanted if (rows[i].className.search(/noclick/) != -1) { continue; } // ... and to mark the row on click ... rows[i].onmousedown = function() { var unique_id; var checkbox; checkbox = this.getElementsByTagName( 'input' )[0]; if ( checkbox && checkbox.type == 'checkbox' ) { unique_id = checkbox.name + checkbox.value; } else if ( this.id.length > 0 ) { unique_id = this.id; } else { return; } if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) { marked_row[unique_id] = true; } else { marked_row[unique_id] = false; } if ( marked_row[unique_id] ) { this.className += ' marked'; } else { this.className = this.className.replace(' marked', ''); } if ( checkbox && checkbox.disabled == false ) { checkbox.checked = marked_row[unique_id]; } } // ... and disable label ... var labeltag = rows[i].getElementsByTagName('label')[0]; if ( labeltag ) { labeltag.onclick = function() { return false; } } // .. and checkbox clicks var checkbox = rows[i].getElementsByTagName('input')[0]; if ( checkbox ) { checkbox.onclick = function() { // opera does not recognize return false; this.checked = ! this.checked; } } } } window.onload=PMA_markRowsInit; /** * marks all rows and selects its first checkbox inside the given element * the given element is usaly a table or a div containing the table or tables * * @param container DOM element */ function markAllRows( container_id ) { var rows = document.getElementById(container_id).getElementsByTagName('tr'); var unique_id; var checkbox; for ( var i = 0; i < rows.length; i++ ) { checkbox = rows[i].getElementsByTagName( 'input' )[0]; if ( checkbox && checkbox.type == 'checkbox' ) { unique_id = checkbox.name + checkbox.value; if ( checkbox.disabled == false ) { checkbox.checked = true; if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) { rows[i].className += ' marked'; marked_row[unique_id] = true; } } } } return true; } /** * marks all rows and selects its first checkbox inside the given element * the given element is usaly a table or a div containing the table or tables * * @param container DOM element */ function unMarkAllRows( container_id ) { var rows = document.getElementById(container_id).getElementsByTagName('tr'); var unique_id; var checkbox; for ( var i = 0; i < rows.length; i++ ) { checkbox = rows[i].getElementsByTagName( 'input' )[0]; if ( checkbox && checkbox.type == 'checkbox' ) { unique_id = checkbox.name + checkbox.value; checkbox.checked = false; rows[i].className = rows[i].className.replace(' marked', ''); marked_row[unique_id] = false; } } return true; } function redirect2(url) { window.location.replace(url); } ///////// liubi /////// function Liubichanges(form,typ,obj){ //alert(form +'.' + typ + '_id\n'+form +'.' + typ + '_id'); //var f = document.classes; cbtext = eval( form+'.' + typ + '_id'); cbimg = eval( form+'.' + typ + '_img'); if (cbtext.value==1) { cbtext.value=0; cbimg.src = "/images/common/publish_x.png"; }else{ cbtext.value=1; cbimg.src = "/images/common/publish_g.png"; } } function changes(form,typ,obj){ id = obj.parentElement.parentElement.rowIndex - 1; alert(id); //var f = document.form; alert(form +'.' + typ + '_id') cbtext = eval(form +'.' + typ + '_id'); cbimg = eval(form +'.' + typ + '_img'); alert(cbtext); alert(cbimg); if(cbtext.length>1){ if (cbtext[id].value==1) { cbtext[id].value=0; //cbimg[id].src = "/images/common/publish_x.png"; }else{ cbtext[id].value=1; //cbimg[id].src = "/images/common/publish_g.png"; } } else { if (cbtext.value==1) { cbtext.value=0; cbimg.src = "/images/common/publish_x.png"; }else{ cbtext.value=1; cbimg.src = "/images/common/publish_g.png"; } } } function showhint(obj,objhint,msg){ document.getElementById(obj).className='hintform1'; document.getElementById(objhint).innerHTML=msg; } function hiddenhint(obj,objhint,msg){ document.getElementById(obj).className='hintform0'; document.getElementById(objhint).innerHTML=''; } ////////////////// function display(id) { $(id).style.display = $(id).style.display == '' ? 'none' : ''; } function isUndefined(variable) { return typeof variable == 'undefined' ? true : false; } function in_array(needle, haystack) { if(typeof needle == 'string' || typeof needle == 'number') { for(var i in haystack) { if(haystack[i] == needle) { return true; } } } return false; } function trim(str) { return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, ''); } function strlen(str) { return (BROWSER.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length; } function mb_strlen(str) { var len = 0; for(var i = 0; i < str.length; i++) { len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1; } return len; } function mb_cutstr(str, maxlen, dot) { var len = 0; var ret = ''; var dot = !dot ? '...' : ''; maxlen = maxlen - dot.length; for(var i = 0; i < str.length; i++) { len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1; if(len > maxlen) { ret += dot; break; } ret += str.substr(i, 1); } return ret; } function redirect(url) { window.location.replace(url); } function checkAll(type, form, value, checkall, changestyle) { var checkall = checkall ? checkall : 'chkall'; for(var i = 0; i < form.elements.length; i++) { var e = form.elements[i]; if(type == 'option' && e.type == 'radio' && e.value == value && e.disabled != true) { e.checked = true; } else if(type == 'value' && e.type == 'checkbox' && e.getAttribute('chkvalue') == value) { e.checked = form.elements[checkall].checked; } else if(type == 'prefix' && e.name && e.name != checkall && (!value || (value && e.name.match(value)))) { e.checked = form.elements[checkall].checked; if(changestyle && e.parentNode && e.parentNode.tagName.toLowerCase() == 'li') { e.parentNode.className = e.checked ? 'checked' : ''; } } } } function altStyle(obj) { function altStyleClear(obj) { var input, lis, i; lis = obj.parentNode.getElementsByTagName('li'); for(i=0; i < lis.length; i++){ lis[i].className = ''; } } var input, lis, i, cc, o; cc = 0; lis = obj.getElementsByTagName('li'); for(i=0; i < lis.length; i++){ lis[i].onclick = function(e) { o = BROWSER.ie ? event.srcElement.tagName : e.target.tagName; if(cc) { return; } cc = 1; input = this.getElementsByTagName('input')[0]; if(input.getAttribute('type') == 'checkbox' || input.getAttribute('type') == 'radio') { if(input.getAttribute('type') == 'radio') { altStyleClear(this); } if(BROWSER.ie || o != 'INPUT' && input.onclick) { input.click(); } if(this.className != 'checked') { this.className = 'checked'; input.checked = true; } else { this.className = ''; input.checked = false; } } } lis[i].onmouseup = function(e) { cc = 0; } } } var addrowdirect = 0; function addrow(obj, type) { var table = obj.parentNode.parentNode.parentNode.parentNode; if(!addrowdirect) { var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex); } else { var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex + 1); } var typedata = rowtypedata[type]; for(var i = 0; i <= typedata.length - 1; i++) { var cell = row.insertCell(i); cell.colSpan = typedata[i][0]; var tmp = typedata[i][1]; if(typedata[i][2]) { cell.className = typedata[i][2]; } tmp = tmp.replace(/\{(\d+)\}/g, function($1, $2) {return addrow.arguments[parseInt($2) + 1];}); cell.innerHTML = tmp; } addrowdirect = 0; } function dropmenu(obj){ showMenu({'ctrlid':obj.id, 'menuid':obj.id + 'child', 'evt':'mouseover'}); $(obj.id + 'child').style.top = (parseInt($(obj.id + 'child').style.top) - document.documentElement.scrollTop) + 'px'; } function dropmenu2(obj){ showMenu({'ctrlid':obj.id, 'menuid':obj.id + 'child', 'evt':'mouseover'}); $(obj.id + 'child').style.top = (parseInt($(obj.id + 'child').style.top) - Math.max(document.body.scrollTop, document.documentElement.scrollTop)) + 'px'; if(BROWSER.ie > 6 || !BROWSER.ie) { $(obj.id + 'child').style.left = (parseInt($(obj.id + 'child').style.left) - Math.max(document.body.scrollLeft, document.documentElement.scrollLeft)) + 'px'; } } function textareasize(obj, op) { if(!op) { if(obj.scrollHeight > 70) { obj.style.height = (obj.scrollHeight < 300 ? obj.scrollHeight : 300) + 'px'; if(obj.style.position == 'absolute') { obj.parentNode.style.height = obj.style.height; } } } else { if(obj.style.position == 'absolute') { obj.style.position = ''; obj.style.width = ''; obj.parentNode.style.height = ''; } else { obj.parentNode.style.height = obj.parentNode.offsetHeight + 'px'; obj.style.width = BROWSER.ie > 6 || !BROWSER.ie ? '90%' : '600px'; obj.style.position = 'absolute'; } } } function showanchor(obj) { var navs = $('submenu').getElementsByTagName('li'); for(var i = 0; i < navs.length; i++) { if(navs[i].id.substr(0, 4) == 'nav_' && navs[i].id != obj.id) { navs[i].className = ''; $(navs[i].id.substr(4)).style.display = 'none'; if($(navs[i].id.substr(4) + '_tips')) $(navs[i].id.substr(4) + '_tips').style.display = 'none'; } } obj.className = 'current'; currentAnchor = obj.id.substr(4); $(currentAnchor).style.display = ''; if($(currentAnchor + '_tips')) $(currentAnchor + '_tips').style.display = ''; if($(currentAnchor + 'form')) { $(currentAnchor + 'form').anchor.value = currentAnchor; } else if($('cpform')) { $('cpform').anchor.value = currentAnchor; } } function updatecolorpreview(obj) { $(obj).style.background = $(obj + '_v').value; } function entersubmit(e, name) { var e = e ? e : event; if(e.keyCode != 13) { return; } var tag = BROWSER.ie ? e.srcElement.tagName : e.target.tagName; if(tag != 'TEXTAREA') { doane(e); if($('submit_' + name).offsetWidth) { $('formscrolltop').value = document.documentElement.scrollTop; $('submit_' + name).click(); } } } function parsetag(tag) { var str = document.body.innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) { if(tag && $3.indexOf(tag) != -1) { $3 = $3.replace(tag, ''); } return $2 + $3; }); document.body.innerHTML = str.replace(//ig, function($1, $2) { return '' + tag + ''; }); } function LiubiIsDeldxSelect(form,value){ var j=0; for(var i = 0; i < form.elements.length; i++) { var e = form.elements[i]; if(value && e.name.match(value)){ if(e.checked==true){ j++; } } } return j; } function LiubiDelJingGao(form,value){ var dd=false; var delnums=0; delnums=LiubiIsDeldxSelect(form,value); if(delnums>0){ dd=confirm("本次操作中有 "+delnums+" 个主题将删除,确定要执行该操作吗!"); if(dd!=true){ return false; } } } function openok_lhg1(id,url,w,h,tit){ $.dialog({ id:id, width:w, height:h, title:tit, content:'url:'+url, top:'50%', fixed: true, max: false, min: false, lock: true, background: '#eee', opacity: 0.5, resize: false }); } function openok_lhg2(id,url,w,h,tit){ W.$.dialog({ id:id, width:w, height:h, title:tit, content:'url:'+url, top:'50%', fixed: true, max: false, min: false, lock: true, background: '#eee', opacity: 0.5, resize: false, parent:api, }); } function xzstr(value,num,can=1) { if(parseInt(value)>num){ value=""; } if(!can) { if(!parseInt(value)) { value=""; } } return value; }