📄 post.js
字号:
$("ef_form")["user_unpassreason"].value = txt;
$("ef_form").submit();
}
}
}
/*主题推荐*/
function doCommend(button){
if(button){
button.disabled="true";
}
$("commendForm").submit();
}
/*举报帖子*/
function doReport(button){
if(!checkTextarea("post_report","内容",200)){
return false;
}
if(button){
button.disabled="true";
}
$("reportForm").submit();
}
/**悬赏的实时金额*/
function setRealValue(price,max,tax){
if(!price.search(/^\d+$/) ) {
n = Math.ceil(parseInt(price - max) + (price - max) * tax);
if(price < max) {
$("realprice").innerHTML = "<b>不能降低悬赏金钱</b>";
$("reward_tax").value = -1;
}else if (price < 1 || (0 > 0 && price > 0)) {
$("realprice").innerHTML = "<b>售价超出范围</b>";
$("reward_tax").value = -1;
} else {
$("realprice").innerHTML = n;
$("reward_tax").value = n;
}
}else{
$("realprice").innerHTML = "<b>填写无效</b>";
$("reward_tax").value = -1;
}
}
/*主题管理*/
function doTopicMan(obj){
if($("all_topic_selected").value==""){
alert("请先选择相应的主题!");
return;
}
$("log_reason").value = Trim($("log_reason").value);
if($("log_reason").value.length == 0){
alert("请填写操作原因");
return;
}
if($("log_reason").value.length >100 ){
alert("操作原因最多 100 个字符(汉字占两位)");
return;
}
if(obj){
obj.disabled="true";
}
$("topicManForm").submit();
}
/*主题管理选择主题*/
function selectTopic(obj){
if(obj.checked){
$("all_topic_selected").value += "," + obj.value;
}else{
$("all_topic_selected").value = $("all_topic_selected").value.replace("," + obj.value, "");
}
}
/** 预览帖子*/
function preView(){
document.forms['preview'].retype.value="";
document.forms['preview'].title.value=document.contentForm.topic.value;
document.forms['preview'].content.value=document.contentForm.content.value;
//alert();
//scrollbars=yes,width=750,height=450
var popupWin = window.open('', 'preview_page', '');
document.preview.submit();
}
function selectAllTopic(obj){
$("all_topic_selected").value = "";
var chk = document.getElementsByName("chk_topic_id");
if(chk){
if(chk.length){
for(i=0;i<chk.length;i++){
chk[i].checked = obj.checked;
if(obj.checked){
$("all_topic_selected").value += "," + chk[i].value ;
}
}
}else{
chk.checked = obj.checked;
if(obj.checked){
$("all_topic_selected").value = "," + chk[i].value;
}
}
}else{
alert("该页面没有主题!");
}
}
// 主题管理的提交;
function checkTopicSelected(button){
if($("all_topic_selected").value == ""){
alert("请先选择相应的主题!");
return ;
}
if(button){
button.disabled="true";
}
$("topicManForm").submit();
}
/*选择全部对象*/
function selectAll(elementName,checked){
var chk = document.getElementsByName(elementName);
if(chk){
if(chk.length){
for(i=0;i<chk.length;i++){
chk[i].checked = checked;
}
}else{
chk.checked = checked;
}
}
}
//在帖子列表中点击楼号的时候
function copyPostUrl(url){
window.clipboardData.clearData();
window.clipboardData.setData("Text", url);
alert("本楼地址已经复制到剪切板");
}
function tagLink(obj){
window.open("index.do?_fn=TagTopicList&tag_name="+encodeURI(obj),"_blank","");
}
/****/
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 isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function fetchCheckbox(cbn) {
return $(cbn) && $(cbn).checked == true ? 1 : 0;
}
function getRadioValue(name){
var obj = document.getElementsByName(name);
if(obj){
if(obj.length == undefined){
if(obj.checked==true){
return obj.value;
}
}else{
for(var i=0; i<obj.length; i++){
if(obj[i].checked==true){
return obj[i].value;
}
}
}
}
return null;
}
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 doane(event) {
e = event ? event : window.event;
if(is_ie) {
e.returnValue = false;
e.cancelBubble = true;
} else if(e) {
e.stopPropagation();
e.preventDefault();
}
}
function storeCaret(textEl){
if(textEl.createTextRange){
textEl.caretPos = document.selection.createRange().duplicate();
}
}
function setCaretAtEnd() {
var obj = typeof wysiwyg == 'undefined' || !wysiwyg ? $('ef_form').post_content : editwin;
if(typeof wysiwyg != 'undefined' && wysiwyg) {
if(is_moz || is_opera) {
} else {
var sel = editdoc.selection.createRange();
sel.moveStart('character', strlen(getEditorContents()));
sel.select();
}
} else {
if(obj.createTextRange) {
var sel = obj.createTextRange();
sel.moveStart('character', strlen(obj.value));
sel.collapse();
sel.select();
}
}
}
function strlen(str) {
return (is_ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}
var is_mac = userAgent.indexOf('mac') != -1;
var re;
if(isUndefined(codecount)) var codecount = '-1';
if(isUndefined(codehtml)) var codehtml = new Array();
var postSubmited = false;
var codehtml = new Array();
function ctlent(event) {
if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83) && $('postsubmit')) {
if(in_array($('postsubmit').name, ['topicsubmit', 'replysubmit', 'editsubmit', 'pmsubmit']) && !validate($('postform'))) {
doane(event);
return;
}
postSubmited = true;
$('postsubmit').disabled = true;
$('postform').submit();
}
}
function AddText(txt) {
var obj = typeof wysiwyg == 'undefined' || !wysiwyg ? $('ef_form').post_content : editwin;
selection = document.selection;
checkFocus();
if(!isUndefined(obj.selectionStart)) {
var opn = obj.selectionStart + 0;
obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
} else if(selection && selection.createRange) {
var sel = selection.createRange();
sel.text = txt;
sel.moveStart('character', -strlen(txt));
} else {
obj.value += txt;
}
}
function checkFocus() {
var obj = typeof wysiwyg == 'undefined' || !wysiwyg ? $('ef_form').post_content : editwin;
if(!obj.hasfocus) {
obj.focus();
}
}
function parseurl(str, mode) {
str= str.replace(/\s*\[code\]([\s\S]+?)\[\/code\]\s*/ig, function($1, $2) {return codetag($2);});
str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(jpg|gif|png|bmp))/ig, mode == 'html' ? '$1<img src="$2" border="0">' : '$1[img]$2[/img]');
str = str.replace(/([^>=\]"'\/@]|^)((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast):\/\/))([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
str = str.replace(/([^\w>=\]"'\/@]|^)((www\.)([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
str = str.replace(/([^\w->=\]:"'\.\/]|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1[email]$2[/email]');
for(var i = 0; i <= codecount; i++) {
str = str.replace("[\tEFORUM_CODE_" + i + "\t]", codehtml[i]);
}
return str;
}
function insertSmiley(smilieid) {
checkFocus();
var src = smilies[smilieid]['url'];
var code = smilies[smilieid]['code'];
if(typeof wysiwyg != 'undefined' && wysiwyg) {
if(is_moz) {
applyFormat('InsertImage', false, src);
var smileTags = editdoc.body.getElementsByTagName('img');
for(var i = 0; i < smileTags.length; i++) {
if(smileTags[i].src.lastIndexOf(src) != -1 && smileTags[i].getAttribute('smilieid') < 1) {
smileTags[i].setAttribute('smilieid', smilieid);
smileTags[i].setAttribute('border', "0");
}
}
} else {
insertText('<img src="' + src + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false);
}
} else {
code += ' ';
AddText(code);
}
}
function codetag(text) {
codecount++;
text = text.replace(/<br[^\>]*>/ig, '\n');
text = text.replace(/^[\n\r]*([\s\S]+?)[\n\r]*$/ig, '$1');
if(typeof wysiwyg != 'undefined' && wysiwyg) text = text.replace(/<(\/|)[A-Za-z].*?>/ig, '');
codehtml[codecount] = '[code]' + text + '[/code]';
return '[\tEFORUM_CODE_' + codecount + '\t]';
}
function insertAttach(attachNo){
checkFocus();
var sInsert = $('picShow' + attachNo).innerHTML;
if (sInsert.indexOf('.') != -1 && checkInsertID($("filePath" + attachNo).value,attachNo)) {
var code;
if($("filePath" + attachNo).value.indexOf("###") > -1){
code = "[upload]" + $("filePath" + attachNo).value + "[/upload]";
} else {
code = $("filePath" + attachNo).value;
}
if(typeof wysiwyg != 'undefined' && wysiwyg) {
//show img
var imgInfo = getLocalAttachImg(attachNo);
//alert(imgInfo);
if(imgInfo != ''){
insertText('<br>'+ imgInfo,false);
return;
}
insertText(code+' ');
return;
}
code += '';
AddText(code);
}
}
function getLocalAttachImg(attachNo){
var filePath = $("fileFullPath"+attachNo);
var ext = getFileType(filePath);
if(is_ie && in_array(ext, efallowpic)){
var img = $("demopic"+attachNo);
var src = $("fileFullPath"+attachNo).value;
var wh = getImageWh(src, thumbwidth, thumbheight);
if(!wh) return '';
return '<img style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=\'scale\',src=\'' +src + '\');width:' + wh['w'] + ';height=' + wh['h'] + '" src=\'ef/images/ubb/clear.gif\' border="0" aid="attach_' + attachNo + '" alt="" />';
}
return '';
}
function getUploadAttachImg(attachNo){
if(!isUndefined(attachArray)){
for(var i = 0; i < attachArray.length; i++) {
if(attachArray[i]['no'] == attachNo && in_array(attachArray[i]['ext'], efallowpic)){
return '<img src="' +attachArray[i]['filePath'] + '" border="0" aid="attach_' + attachNo + '" alt="" />';
}
}
}
return null;
}
function resetPostContent() {
if(wysiwyg ) {
editdoc.body.innerHTML = is_moz ? '<br>' : '';
} else {
textobj.value = '';
}
}
function writePopMenu(id,str){
document.write('\
<div id="'+id+'_Items" class="menu ubbMenu">\
<div class="popupmenu_option">\
<table>'+str+'\
<tr>\
<td><center><button id="'+id+'_submit" type="button">提交</button> <button onclick="hideActiveMenu();" type="button" >取消</button></center></td>\
</tr>\
</table></div>\
</div>\
');
}
function fetchOffset(obj) {
var left_offset = obj.offsetLeft;
var top_offset = obj.offsetTop;
while((obj = obj.offsetParent) != null) {
left_offset += obj.offsetLeft;
top_offset += obj.offsetTop;
}
return { 'left' : left_offset, 'top' : top_offset };
}
var msgwidth = 0;
function loadImg(obj,obj1){
if(is_ie && is_ie < 7) {
var objinfo = fetchOffset(obj);
msgwidth = document.body.clientWidth - objinfo['left'] - 20;
} else {
if(!msgwidth) {
var re = /postcontent/i;
var testobj = obj;
while((testobj = testobj.parentNode) != null) {
var matches = re.exec(testobj.className);
if(matches != null) {
msgwidth = testobj.clientWidth - 20;
break;
}
}
if(msgwidth < 1) {
msgwidth = window.screen.width;
}
}
}
var objWidth = obj.width;
if(objWidth > msgwidth) {
obj.resized = true;
obj.width = msgwidth;
if(typeof obj1 != 'undefined'){
obj.height = parseInt(obj.height * msgwidth /objWidth);
}
obj.style.cursor = 'pointer';
} else {
obj.onclick = null;
}
obj.onload = null;
}
function signature(obj) {
if(obj.style.maxHeightIE != '') {
var height = (obj.scrollHeight > parseInt(obj.style.maxHeightIE)) ? obj.style.maxHeightIE : obj.scrollHeight;
if(obj.innerHTML.indexOf('<img ') == -1) {
obj.style.maxHeightIE = '';
}
return height;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -