First commit

This commit is contained in:
2025-06-18 10:24:27 +08:00
commit ebc39cd5dd
3873 changed files with 412712 additions and 0 deletions

495
static/js/admincp.js Normal file
View File

@@ -0,0 +1,495 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: admincp.js 31631 2012-09-17 06:36:25Z monkey $
*/
function redirect(url) {
window.location.replace(url);
}
function scrollTopBody() {
return Math.max(document.documentElement.scrollTop, document.body.scrollTop);
}
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;
if(changestyle) {
multiupdate(e);
}
} else if(type == 'prefix' && e.name && e.name != checkall && (!value || (value && e.name.match(value)))) {
e.checked = form.elements[checkall].checked;
if(changestyle) {
if(e.parentNode && e.parentNode.tagName.toLowerCase() == 'li') {
e.parentNode.className = e.checked ? 'checked' : '';
}
if(e.parentNode.parentNode && e.parentNode.parentNode.tagName.toLowerCase() == 'div') {
e.parentNode.parentNode.className = e.checked ? 'item checked' : 'item';
}
}
}
}
}
function altStyle(obj, disabled) {
function altStyleClear(obj) {
var input, lis, i;
lis = obj.parentNode.getElementsByTagName('li');
for(i=0; i < lis.length; i++){
lis[i].className = '';
}
}
var disabled = !disabled ? 0 : disabled;
if(disabled) {
return;
}
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;
altKey = BROWSER.ie ? window.event.altKey : e.altKey;
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;
}
if(altKey && input.name.match(/^multinew\[\d+\]/)) {
miid = input.id.split('|');
mi = 0;
while($(miid[0] + '|' + mi)) {
$(miid[0] + '|' + mi).checked = input.checked;
if(input.getAttribute('type') == 'radio') {
altStyleClear($(miid[0] + '|' + mi).parentNode);
}
$(miid[0] + '|' + mi).parentNode.className = input.checked ? 'checked' : '';
mi++;
}
}
}
};
lis[i].onmouseup = function(e) {
cc = 0;
}
}
}
var addrowdirect = 0;
var addrowkey = 0;
function addrow(obj, type) {
var table = obj.parentNode.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(/\{(n)\}/g, function($1) {return addrowkey;});
tmp = tmp.replace(/\{(\d+)\}/g, function($1, $2) {return addrow.arguments[parseInt($2) + 1];});
cell.innerHTML = tmp;
}
addrowkey ++;
addrowdirect = 0;
}
function deleterow(obj) {
var table = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
var tr = obj.parentNode.parentNode.parentNode;
table.deleteRow(tr.rowIndex);
}
function dropmenu(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 insertunit(obj, text, textend) {
obj.focus();
textend = isUndefined(textend) ? '' : textend;
if(!isUndefined(obj.selectionStart)) {
var opn = obj.selectionStart + 0;
if(textend != '') {
text = text + obj.value.substring(obj.selectionStart, obj.selectionEnd) + textend;
}
obj.value = obj.value.substr(0, obj.selectionStart) + text + obj.value.substr(obj.selectionEnd);
obj.selectionStart = opn + strlen(text);
obj.selectionEnd = opn + strlen(text);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
obj.value += text;
}
obj.focus();
}
var heightag = BROWSER.chrome ? 4 : 0;
function textareakey(obj, event) {
if(event.keyCode == 9) {
insertunit(obj, '\t');
doane(event);
}
}
function textareasize(obj, op) {
if(!op) {
} else {
if(obj.style.position == 'absolute') {
obj.style.position = '';
obj.style.width = '';
obj.parentNode.style.height = '';
obj.style.resize = 'none';
} else {
obj.parentNode.style.height = obj.parentNode.offsetHeight + 'px';
obj.style.width = BROWSER.ie > 6 || !BROWSER.ie ? '90%' : '600px';
obj.style.position = 'absolute';
obj.style.resize = 'vertical';
}
}
}
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) {
if($(navs[i].id.substr(4))) {
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) {
if(loadUserdata('is_blindman')) {
return false;
}
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 parse = function (tds) {
for(var i = 0; i < tds.length; i++) {
if(tds[i].getAttribute('s') == '1') {
tds[i].innerHTML = tds[i].innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {
if(tag && $3.toLowerCase().indexOf(tag.toLowerCase()) != -1) {
re = new RegExp(tag, "ig");
$3 = $3.replace(re, '<font class="highlight">$&</font>');
}
return $2 + $3;
});
}
}
};
parse(document.body.getElementsByTagName('td'));
parse(document.body.getElementsByTagName('span'));
}
function sdisplay(id, obj) {
obj.innerHTML = $(id).style.display == 'none' ? '<img src="static/image/admincp/desc.gif" style="vertical-align:middle" />' : '<img src="static/image/admincp/add.gif" style="vertical-align:middle" />';
display(id);
}
if(ISFRAME) {
try {
_attachEvent(document.documentElement, 'keydown', parent.resetEscAndF5);
} catch(e) {}
}
var multiids = new Array();
function multiupdate(obj) {
v = obj.value;
if(obj.checked) {
multiids[v] = v;
} else {
multiids[v] = null;
}
}
function getmultiids() {
var ids = '', comma = '';
for(i in multiids) {
if(multiids[i] != null) {
ids += comma + multiids[i];
comma = ',';
}
}
return ids;
}
function toggle_group(oid, obj, conf) {
obj = obj ? obj : $('a_'+oid);
if(!conf) {
var conf = {'show':'[-]','hide':'[+]'};
}
var obody = $(oid);
if(obody.style.display == 'none') {
obody.style.display = '';
obj.innerHTML = conf.show;
} else {
obody.style.display = 'none';
obj.innerHTML = conf.hide;
}
}
function show_all() {
var tbodys = $("cpform").getElementsByTagName('tbody');
for(var i = 0; i < tbodys.length; i++) {
var re = /^group_(\d+)$/;
var matches = re.exec(tbodys[i].id);
if(matches != null) {
tbodys[i].style.display = '';
$('a_group_' + matches[1]).innerHTML = '[-]';
}
}
}
function hide_all() {
var tbodys = $("cpform").getElementsByTagName('tbody');
for(var i = 0; i < tbodys.length; i++) {
var re = /^group_(\d+)$/;
var matches = re.exec(tbodys[i].id);
if(matches != null) {
tbodys[i].style.display = 'none';
$('a_group_' + matches[1]).innerHTML = '[+]';
}
}
}
function show_all_hook(prefix, tagname) {
var tbodys = $("cpform").getElementsByTagName(tagname);
for(var i = 0; i < tbodys.length; i++) {
var re = new RegExp('^' + prefix + '(.+)$');
var matches = re.exec(tbodys[i].id);
if(matches != null) {
tbodys[i].style.display = '';
$('a_' + prefix + matches[1]).innerHTML = '[-]';
}
}
}
function hide_all_hook(prefix, tagname) {
var tbodys = $("cpform").getElementsByTagName(tagname);
for(var i = 0; i < tbodys.length; i++) {
var re = new RegExp('^' + prefix + '(.+)$');
var matches = re.exec(tbodys[i].id);
if(matches != null) {
tbodys[i].style.display = 'none';
$('a_' + prefix + matches[1]).innerHTML = '[+]';
}
}
}
function srchforum() {
var fname = $('srchforumipt').value.toLowerCase();
if(!fname) return false;
var inputs = $("cpform").getElementsByTagName('input');
for(var i = 0; i < inputs.length; i++) {
if(inputs[i].name.match(/^name\[\d+\]$/)) {
if(inputs[i].value.toLowerCase().indexOf(fname) !== -1) {
inputs[i].parentNode.parentNode.parentNode.parentNode.style.display = '';
inputs[i].parentNode.parentNode.parentNode.style.background = '#eee';
window.scrollTo(0, fetchOffset(inputs[i]).top - 100);
return false;
}
}
}
return false;
}
function setfaq(obj, id) {
if(!$(id)) {
return;
}
$(id).style.display = '';
if(!obj.onmouseout) {
obj.onmouseout = function () {
$(id).style.display = 'none';
}
}
}
function floatbottom(id) {
if(!$(id)) {
return;
}
$(id).style.position = 'fixed';
$(id).style.bottom = '0';
$(id).parentNode.style.paddingBottom = '15px';
if(!BROWSER.ie || BROWSER.ie && BROWSER.ie > 6) {
window.onscroll = function() {
var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
$(id).style.marginLeft = '-' + scrollLeft + 'px';
};
$(id).style.display = '';
}
}
var sethtml_id = null;
function sethtml(id) {
$(id).className = 'txt html';
$(id).contentEditable = true;
$(id).onkeyup = function () {
$(id + '_v').value = $(id).innerHTML;
};
var curvalue = $(id).innerHTML;
var div = document.createElement('div');
div.id = id + '_c_menu';
div.style.display = 'none';
div.innerHTML = '<iframe id="' + id + '_c_frame" src="" frameborder="0" width="210" height="148" scrolling="no"></iframe>';
$(id).parentNode.appendChild(div);
var btn = document.createElement('input');
btn.id = id + '_c';
btn.type = 'button';
btn.className = 'htmlbtn c';
if(curvalue.search(/<font/ig) !== -1) {
btn.className = 'htmlbtn c current';
}
btn.onclick = function() {
$(id + '_c_frame').src = 'static/image/admincp/getcolor.htm?||sethtml_color';
showMenu({'ctrlid' : id + '_c'});
sethtml_id = id;
};
$(id).parentNode.appendChild(btn);
var btn = document.createElement('input');
btn.id = id + '_b';
btn.type = 'button';
btn.className = 'htmlbtn b';
if(curvalue.search(/<b>/ig) !== -1) {
btn.className = 'htmlbtn b current';
}
btn.onclick = function() {
var oldvalue = $(id).innerHTML;
$(id).innerHTML = preg_replace(['<b>', '</b>'], '', $(id).innerHTML);
if(oldvalue == $(id).innerHTML) {
$(id + '_b').className = 'htmlbtn b current';
$(id).innerHTML = '<b>' + $(id).innerHTML + '</b>';
} else {
$(id + '_b').className = 'htmlbtn b';
}
$(id + '_v').value = $(id).innerHTML;
};
$(id).parentNode.appendChild(btn);
var btn = document.createElement('input');
btn.id = id + '_i';
btn.type = 'button';
btn.className = 'htmlbtn i';
if(curvalue.search(/<i>/ig) !== -1) {
btn.className = 'htmlbtn i current';
}
btn.onclick = function() {
var oldvalue = $(id).innerHTML;
$(id).innerHTML = preg_replace(['<i>', '</i>'], '', $(id).innerHTML);
if(oldvalue == $(id).innerHTML) {
$(id + '_i').className = 'htmlbtn i current';
$(id).innerHTML = '<i>' + $(id).innerHTML + '</i>';
} else {
$(id + '_i').className = 'htmlbtn i';
}
$(id + '_v').value = $(id).innerHTML;
};
$(id).parentNode.appendChild(btn);
var btn = document.createElement('input');
btn.id = id + '_u';
btn.type = 'button';
btn.style.textDecoration = 'underline';
btn.className = 'htmlbtn u';
if(curvalue.search(/<u>/ig) !== -1) {
btn.className = 'htmlbtn u current';
}
btn.onclick = function() {
var oldvalue = $(id).innerHTML;
$(id).innerHTML = preg_replace(['<u>', '</u>'], '', $(id).innerHTML);
if(oldvalue == $(id).innerHTML) {
$(id + '_u').className = 'htmlbtn u current';
$(id).innerHTML = '<u>' + $(id).innerHTML + '</u>';
} else {
$(id + '_u').className = 'htmlbtn u';
}
$(id + '_v').value = $(id).innerHTML;
};
$(id).parentNode.appendChild(btn);
}
function sethtml_color(color) {
$(sethtml_id).innerHTML = preg_replace(['<font[^>]+?>', '</font>'], '', $(sethtml_id).innerHTML);
if(color != 'transparent') {
$(sethtml_id + '_c').className = 'htmlbtn c current';
$(sethtml_id).innerHTML = '<font color=' + color + '>' + $(sethtml_id).innerHTML + '</font>';
} else {
$(sethtml_id + '_c').className = 'htmlbtn c';
}
$(sethtml_id + '_v').value = $(sethtml_id).innerHTML;
}
function uploadthreadtypexml(formobj, formaction) {
formobj.action = formaction;
formobj.submit();
}

107
static/js/admincp_base.js Normal file
View File

@@ -0,0 +1,107 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
*/
function run_toggle(target, styles, source) {
var rmstyle = styles.shift();
if (!source) {
source = target;
}
if (rmstyle) {
if (typeof rmstyle == 'string') {
target.classList.remove(rmstyle);
} else {
for (var i in rmstyle) {
target.classList.remove(rmstyle[i]);
}
}
}
if (styles[0]) {
if (typeof styles[0] == 'string') {
target.classList.add(styles[0]);
} else {
for (var i in styles[0]) {
target.classList.add(styles[0][i]);
}
}
if (styles.length > 1) {
function nextstep() {
source.removeEventListener('transitionend', nextstep);
run_toggle(target, styles, source);
}
source.addEventListener('transitionend', nextstep);
}
}
}
function init_darkmode() {
var dmcookie = getcookie('darkmode');
var dmdark = 0, dmauto = 1;
document.querySelector('.darkmode').addEventListener('click', toggledarkmode);
if (dmcookie && dmcookie.indexOf('a') == -1) {
dmauto = 0;
if (dmcookie.indexOf('d') != -1) {
dmdark = 1;
}
switchdmvalue(dmdark, dmauto);
} else {
var colormedia = window.matchMedia('(prefers-color-scheme: dark)');
switchdmvalue(colormedia.matches, dmauto);
colormedia.addEventListener('change', function () {
var dmlcookie = getcookie('darkmode');
if (dmlcookie && dmlcookie.indexOf('a') != -1) {
switchdmvalue(this.matches, 1);
}
});
}
}
function toggledarkmode() {
var dmcookie = getcookie('darkmode');
var dmdark = 0, dmauto = 1;
var colormedia = window.matchMedia('(prefers-color-scheme: dark)');
if (dmcookie && dmcookie.indexOf('a') == -1) {
dmauto = 0;
if (dmcookie.indexOf('d') != -1) {
dmdark = 1;
}
} else {
dmdark = colormedia.matches ? 1 : 0;
}
if (dmauto) {
dmauto = dmauto ? 0 : 1;
dmdark = dmdark ? 0 : 1;
} else if (colormedia.matches == dmdark) {
dmauto = 1;
} else {
dmdark = dmdark ? 0 : 1;
}
switchdmvalue(dmdark, dmauto);
}
function switchdmvalue(ifdark, ifauto) {
var dmcookie = '';
var dmmeta = '';
if (ifdark) {
document.body.classList.add('st-d');
document.body.classList.remove('st-l');
dmcookie = 'd';
dmmeta = 'dark';
} else {
document.body.classList.add('st-l');
document.body.classList.remove('st-d');
dmcookie = 'l';
dmmeta = 'light';
}
if (ifauto) {
document.body.classList.add('st-a');
dmcookie += 'a';
dmmeta = 'light dark';
} else {
document.body.classList.remove('st-a');
} console.log(dmcookie);
if (getcookie('darkmode') != dmcookie) {
setcookie('darkmode', dmcookie);
}
if (document.querySelector('meta[name="color-scheme"]').content != dmmeta) {
document.querySelector('meta[name="color-scheme"]').content = dmmeta;
}
}

210
static/js/admincp_frame.js Normal file
View File

@@ -0,0 +1,210 @@
function init_darkmode() {
var dmcookie = getcookie('darkmode');
var dmdark = 0, dmauto = 1;
document.querySelector('.darkmode').addEventListener('click', toggledarkmode);
if (dmcookie && dmcookie.indexOf('a') == -1) {
dmauto = 0;
if (dmcookie.indexOf('d') != -1) {
dmdark = 1;
}
switchdmvalue(dmdark, dmauto);
} else {
var colormedia = window.matchMedia('(prefers-color-scheme: dark)');
switchdmvalue(colormedia.matches, dmauto);
colormedia.addEventListener('change', function () {
var dmlcookie = getcookie('darkmode');
if (dmlcookie && dmlcookie.indexOf('a') != -1) {
switchdmvalue(this.matches, 1);
}
});
}
}
function toggledarkmode() {
var dmcookie = getcookie('darkmode');
var dmdark = 0, dmauto = 1;
var colormedia = window.matchMedia('(prefers-color-scheme: dark)');
if (dmcookie && dmcookie.indexOf('a') == -1) {
dmauto = 0;
if (dmcookie.indexOf('d') != -1) {
dmdark = 1;
}
} else {
dmdark = colormedia.matches ? 1 : 0;
}
if (dmauto) {
dmauto = dmauto ? 0 : 1;
dmdark = dmdark ? 0 : 1;
} else if (colormedia.matches == dmdark) {
dmauto = 1;
} else {
dmdark = dmdark ? 0 : 1;
}
switchdmvalue(dmdark, dmauto);
}
function switchdmvalue(ifdark, ifauto) {
var dmcookie = '';
var dmmeta = '';
if (ifdark) {
document.body.classList.add('st-d');
document.body.classList.remove('st-l');
dmcookie = 'd';
dmmeta = 'dark';
} else {
document.body.classList.add('st-l');
document.body.classList.remove('st-d');
dmcookie = 'l';
dmmeta = 'light';
}
if (ifauto) {
document.body.classList.add('st-a');
dmcookie += 'a';
dmmeta = 'light dark';
} else {
document.body.classList.remove('st-a');
}
let iframe = document.getElementById('main');
iframe.onload = function(){
switchframedmvalue(ifdark, ifauto)
}
switchframedmvalue(ifdark, ifauto)
console.log(dmcookie);
if (getcookie('darkmode') != dmcookie) {
setcookie('darkmode', dmcookie);
}
if (document.querySelector('meta[name="color-scheme"]').content != dmmeta) {
document.querySelector('meta[name="color-scheme"]').content = dmmeta;
}
}
function switchframedmvalue(ifdark, ifauto) {
let iframe = document.getElementById('main');
if (ifdark) {
iframe.contentWindow.document.body.classList.add('st-d');
iframe.contentWindow.document.body.classList.remove('st-l');
} else {
iframe.contentWindow.document.body.classList.add('st-l');
iframe.contentWindow.document.body.classList.remove('st-d');
}
if (ifauto) {
iframe.contentWindow.document.body.classList.add('st-a');
} else {
iframe.contentWindow.document.body.classList.remove('st-a');
}
}
(function () {
var prevnav = prevtab = menunav = navt = navkey = headerST = null;
function switchnav(key, nolocation = false, switchheader = true) {
if (!key || !$('header_' + key)) {
return;
}
if (prevnav && $('header_' + prevnav) && key != 'cloudaddons' && key != 'uc') {
document.querySelectorAll('#topmenu button').forEach(function (nav) {
navkey = nav.id.substring(7);
if (navkey && $('header_' + navkey)) {
if (switchheader) {
$('header_' + navkey).className = '';
}
$('lm_' + navkey).className = '';
}
});
}
href = $('lm_' + key).childNodes[1].childNodes[0].childNodes[0].href;
if (key == 'cloudaddons' || key == 'uc') {
if (!nolocation) {
window.open(href);
doane();
}
} else {
if (prevnav == key && (getcookie('admincp_leftlayout') || parseInt(document.documentElement.clientWidth) < 1200)) {
$('header_' + prevnav).className = '';
$('lm_' + prevnav).className = '';
prevnav = null;
} else {
$('lm_' + key).className = 'active';
if (switchheader) {
$('header_' + key).className = 'active';
prevnav = key;
}
if (!nolocation) {
switchtab($('lm_' + key).childNodes[1].childNodes[0].childNodes[0]);
parent.main.location = href;
}
}
}
}
function switchtab(key) {
if (!key || !key.href) {
return;
}
if(prevtab) {
prevtab.className = '';
}
key.className = 'active';
prevtab = key;
$('navcontainer').classList.remove('show');
}
function openinnewwindow(obj) {
var href = obj.parentNode.href;
if(obj.parentNode.href.indexOf(admincpfilename + '?') != -1) {
href += '&frames=yes';
}
window.open(href);
doane();
}
document.querySelectorAll('#leftmenu > li > a').forEach(function (nav) {
nav.addEventListener('click', function () {
nolocation = true;
id = this.id.substring(7);
if (id == 'cloudaddons' || id == 'uc') {
nolocation = false;
}
switchnav(id, nolocation);
});
});
document.querySelectorAll('#topmenu > li > a').forEach(function (nav) {
nav.addEventListener('click', function () {
switchnav(this.id.substring(7));
});
});
document.querySelectorAll('#topmenu button').forEach(function (nav) {
nav.addEventListener('click', function () {
switchnav(this.id.substring(7));
});
nav.addEventListener('mouseover', function () {
id = this.id.substring(7);
headerST = setTimeout(function () {
switchnav(id, true, false);
}, 1000);
});
nav.addEventListener('mouseout', function () {
clearTimeout(headerST);
});
});
document.querySelectorAll('nav ul ul a').forEach(function (tab) {
tab.addEventListener('click', function () {
switchtab(this);
});
});
document.querySelectorAll('nav ul ul a > em').forEach(function (tabem) {
tabem.addEventListener('click', function () {
openinnewwindow(this);
});
});
switchnav(typeof defaultNav != 'undefined' ? defaultNav : 'index', 1);
switchtab(document.querySelector('nav ul li.active ul a.active') != null ? document.querySelector('nav ul li.active ul a.active') : document.querySelector('nav ul ul a'));
$('cpsetting').addEventListener('click', function(){
$('bdcontainer').classList.toggle('oldlayout');
setcookie('admincp_leftlayout', 1, getcookie('admincp_leftlayout') ? -2592000 : 2592000);
});
document.querySelector('#frameuinfo > img').addEventListener('click', function(){
document.querySelector('.mainhd').classList.toggle('toggle');
});
$('navbtn').addEventListener('click', function(){
$('navcontainer').classList.add('show');
});
$('navcontainer').addEventListener('click', function(e){
if(e.target === this){
this.classList.remove('show')
}
})
})()

View File

@@ -0,0 +1,7 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
*/
function init_darkmode() {
}

264
static/js/ajax.js Normal file
View File

@@ -0,0 +1,264 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ajax.js 34259 2013-11-26 07:37:25Z nemohou $
*/
function _ajaxget(url, showid, waitid, loading, display, recall) {
waitid = typeof waitid == 'undefined' || waitid === null ? showid : waitid;
var x = new Ajax();
x.setLoading(loading);
x.setWaitId(waitid);
x.display = typeof display == 'undefined' || display == null ? '' : display;
x.showId = $(showid);
if(url.substr(strlen(url) - 1) == '#') {
url = url.substr(0, strlen(url) - 1);
x.autogoto = 1;
}
var url = url + '&inajax=1&ajaxtarget=' + showid;
x.get(url, function(s, x) {
var evaled = false;
if(s.indexOf('ajaxerror') != -1) {
evalscript(s);
evaled = true;
}
if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
if(x.showId) {
x.showId.style.display = x.display;
ajaxinnerhtml(x.showId, s);
ajaxupdateevents(x.showId);
if(x.autogoto) scroll(0, x.showId.offsetTop);
}
}
ajaxerror = null;
if(recall && typeof recall == 'function') {
recall();
} else if(recall) {
eval(recall);
}
if(!evaled) evalscript(s);
});
}
function _ajaxpost(formid, showid, waitid, showidclass, submitbtn, recall) {
var waitid = typeof waitid == 'undefined' || waitid === null ? showid : (waitid !== '' ? waitid : '');
var showidclass = !showidclass ? '' : showidclass;
var ajaxframeid = 'ajaxframe';
var ajaxframe = $(ajaxframeid);
var curform = $(formid);
var formtarget = curform.target;
var handleResult = function() {
var s = '';
var evaled = false;
showloading('none');
try {
s = $(ajaxframeid).contentWindow.document.XMLDocument.text;
} catch(e) {
try {
s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.wholeText;
} catch(e) {
try {
s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.nodeValue;
} catch(e) {
s = '内部错误,无法显示此内容';
}
}
}
if(s != '' && s.indexOf('ajaxerror') != -1) {
evalscript(s);
evaled = true;
}
if(showidclass) {
if(showidclass != 'onerror') {
$(showid).className = showidclass;
} else {
showError(s);
ajaxerror = true;
}
}
if(submitbtn) {
submitbtn.disabled = false;
}
if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
ajaxinnerhtml($(showid), s);
}
ajaxerror = null;
if(curform) curform.target = formtarget;
if(typeof recall == 'function') {
recall();
} else {
eval(recall);
}
if(!evaled) evalscript(s);
ajaxframe.loading = 0;
if(!BROWSER.firefox || BROWSER.safari) {
$('append_parent').removeChild(ajaxframe.parentNode);
} else {
setTimeout(
function(){
$('append_parent').removeChild(ajaxframe.parentNode);
},
100
);
}
};
if(!ajaxframe) {
var div = document.createElement('div');
div.style.display = 'none';
div.innerHTML = '<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '" loading="1"></iframe>';
$('append_parent').appendChild(div);
ajaxframe = $(ajaxframeid);
} else if(ajaxframe.loading) {
return false;
}
_attachEvent(ajaxframe, 'load', handleResult);
showloading();
curform.target = ajaxframeid;
var action = curform.getAttribute('action');
action = hostconvert(action);
curform.action = action.replace(/\&inajax\=1/g, '')+'&inajax=1';
curform.submit();
if(submitbtn) {
submitbtn.disabled = true;
}
doane();
return false;
}
function _ajaxmenu(ctrlObj, timeout, cache, duration, pos, recall, idclass, contentclass) {
if(!ctrlObj.getAttribute('mid')) {
var ctrlid = ctrlObj.id;
if(!ctrlid) {
ctrlObj.id = 'ajaxid_' + Math.random();
}
} else {
var ctrlid = ctrlObj.getAttribute('mid');
if(!ctrlObj.id) {
ctrlObj.id = 'ajaxid_' + Math.random();
}
}
var menuid = ctrlid + '_menu';
var menu = $(menuid);
if(isUndefined(timeout)) timeout = 3000;
if(isUndefined(cache)) cache = 1;
if(isUndefined(pos)) pos = '43';
if(isUndefined(duration)) duration = timeout > 0 ? 0 : 3;
if(isUndefined(idclass)) idclass = 'p_pop';
if(isUndefined(contentclass)) contentclass = 'p_opt';
var func = function() {
showMenu({'ctrlid':ctrlObj.id,'menuid':menuid,'duration':duration,'timeout':timeout,'pos':pos,'cache':cache,'layer':2});
if(typeof recall == 'function') {
recall();
} else {
eval(recall);
}
};
if(menu) {
if(menu.style.display == '') {
hideMenu(menuid);
} else {
func();
}
}
menu = document.createElement('div');
menu.id = menuid;
menu.style.display = 'none';
menu.className = idclass;
menu.innerHTML = '<div class="' + contentclass + '" id="' + menuid + '_content"></div>';
$('append_parent').appendChild(menu);
var url = (!isUndefined(ctrlObj.attributes['shref']) ? ctrlObj.attributes['shref'].value : (!isUndefined(ctrlObj.href) ? ctrlObj.href : ctrlObj.attributes['href'].value));
url += (url.indexOf('?') != -1 ? '&' :'?') + 'ajaxmenu=1';
ajaxget(url, menuid + '_content', 'ajaxwaitid', '', '', func);
doane();
}
function _appendscript(src, text, reload, charset) {
var id = hash(src + text);
if(!reload && in_array(id, evalscripts)) return;
if(reload && $(id)) {
$(id).parentNode.removeChild($(id));
}
evalscripts.push(id);
var scriptNode = document.createElement("script");
scriptNode.type = "text/javascript";
scriptNode.id = id;
scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset);
try {
if(src) {
scriptNode.src = src;
scriptNode.onloadDone = false;
scriptNode.onload = function () {
scriptNode.onloadDone = true;
JSLOADED[src] = 1;
};
scriptNode.onreadystatechange = function () {
if((scriptNode.readyState == 'loaded' || scriptNode.readyState == 'complete') && !scriptNode.onloadDone) {
scriptNode.onloadDone = true;
JSLOADED[src] = 1;
}
};
} else if(text){
scriptNode.text = text;
}
document.getElementsByTagName('head')[0].appendChild(scriptNode);
} catch(e) {}
}
function _ajaxupdateevents(obj, tagName) {
tagName = tagName ? tagName : 'A';
var objs = obj.getElementsByTagName(tagName);
for(k in objs) {
var o = objs[k];
ajaxupdateevent(o);
}
}
function _ajaxupdateevent(o) {
if(typeof o == 'object' && o.getAttribute) {
if(o.getAttribute('ajaxtarget')) {
if(!o.id) o.id = Math.random();
var ajaxevent = o.getAttribute('ajaxevent') ? o.getAttribute('ajaxevent') : 'click';
var ajaxurl = o.getAttribute('ajaxurl') ? o.getAttribute('ajaxurl') : o.href;
_attachEvent(o, ajaxevent, newfunction('ajaxget', ajaxurl, o.getAttribute('ajaxtarget'), o.getAttribute('ajaxwaitid'), o.getAttribute('ajaxloading'), o.getAttribute('ajaxdisplay')));
if(o.getAttribute('ajaxfunc')) {
o.getAttribute('ajaxfunc').match(/(\w+)\((.+?)\)/);
_attachEvent(o, ajaxevent, newfunction(RegExp.$1, RegExp.$2));
}
}
}
}
function _ajaxinnerhtml(showid, s) {
if(showid.tagName != 'TBODY') {
showid.innerHTML = s;
} else {
while(showid.firstChild) {
showid.firstChild.parentNode.removeChild(showid.firstChild);
}
var div1 = document.createElement('DIV');
div1.id = showid.id+'_div';
div1.innerHTML = '<table><tbody id="'+showid.id+'_tbody">'+s+'</tbody></table>';
$('append_parent').appendChild(div1);
var trs = div1.getElementsByTagName('TR');
var l = trs.length;
for(var i=0; i<l; i++) {
showid.appendChild(trs[0]);
}
var inputs = div1.getElementsByTagName('INPUT');
var l = inputs.length;
for(var i=0; i<l; i++) {
showid.appendChild(inputs[0]);
}
div1.parentNode.removeChild(div1);
}
}

192
static/js/at.js Normal file
View File

@@ -0,0 +1,192 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: at.js 31619 2012-09-17 01:05:07Z monkey $
*/
if(typeof EXTRAFUNC['keydown'] != "undefined") {
EXTRAFUNC['keydown']['at'] = 'extrafunc_atMenu';
EXTRAFUNC['keyup']['at'] = 'extrafunc_atMenuKeyUp';
EXTRAFUNC['showEditorMenu']['at'] = 'extrafunc_atListMenu';
}
var atKeywords = null, keyMenuObj = null,atResult = [];
var curatli = 0, atliclass = '', atsubmitid = '', atkeypress = 0;
function extrafunc_atMenu() {
if(BROWSER.opera) {
return;
}
if(wysiwyg && EXTRAEVENT.shiftKey && EXTRAEVENT.keyCode == 50 && postaction && (postaction == 'newthread' || postaction == 'reply' || postaction == 'edit')) {
keyMenu('@', atMenu);
ctlent_enable[13] = 0;
doane(EXTRAEVENT);
atkeypress = 1;
}
if($('at_menu') && $('at_menu').style.display == '' && (EXTRAEVENT.keyCode == 38 || EXTRAEVENT.keyCode == 40 || EXTRAEVENT.keyCode == 13)) {
doane(EXTRAEVENT);
}
}
function extrafunc_atMenuKeyUp() {
if(BROWSER.opera) {
return;
}
if(wysiwyg && EXTRAEVENT.shiftKey && EXTRAEVENT.keyCode == 50 && postaction && (postaction == 'newthread' || postaction == 'reply' || postaction == 'edit') && !atkeypress) {
keyBackspace();
keyMenu('@', atMenu);
ctlent_enable[13] = 0;
doane(EXTRAEVENT);
}
if(wysiwyg && $('at_menu') && $('at_menu').style.display == '' && postaction && (postaction == 'newthread' || postaction == 'reply' || postaction == 'edit')) {
if(EXTRAEVENT.keyCode == 32 || EXTRAEVENT.keyCode == 9 || EXTRAEVENT.keyCode == 8 && !keyMenuObj.innerHTML.substr(1).length) {
$('at_menu').style.display = 'none';
ctlent_enable[13] = 1;
} else {
atFilter(keyMenuObj.innerHTML.substr(1), 'at_menu', 'atMenuSet', EXTRAEVENT);
}
}
atkeypress = 0;
}
function extrafunc_atListMenu(tag, op) {
if(tag != 'at') {
return false;
}
if(!op) {
if($('at_menu')) {
$('at_menu').style.display = 'none';
ctlent_enable[13] = 1;
}
curatli = 0;
setTimeout(function() {atFilter('', 'at_list','atListSet');$('atkeyword').focus();}, 100);
return '请输用户名:<br /><input type="text" id="atkeyword" style="width:240px" value="" class="px" onkeydown="atEnter(event, \'atListSet\')" onkeyup="atFilter(this.value, \'at_list\',\'atListSet\',event, true);" /><div class="p_pop" id="at_list" style="width:250px;"><ul><li>@朋友账号,就能提醒他来看文章</li></ul></div>';
} else {
if($('atkeyword').value) {
str = '@' + $('atkeyword').value + (wysiwyg ? '&nbsp;' : ' ');
insertText(str, strlen(str), 0, true, EXTRASEL);
} else {
insertText('', 0, 0, true, EXTRASEL);
}
checkFocus();
return true;
}
}
function atMenu(x, y) {
if(!$('at_menu')) {
div = document.createElement("div");
div.id = "at_menu";
document.body.appendChild(div);
div.style.position = 'absolute';
div.className = 'p_pop';
div.style.zIndex = '100000';
}
$('at_menu').style.marginTop = (keyMenuObj.offsetHeight + 2) + 'px';
$('at_menu').style.marginLeft = (keyMenuObj.offsetWidth + 2) + 'px';
$('at_menu').style.left = x + 'px';
$('at_menu').style.top = y + 'px';
$('at_menu').style.display = '';
$('at_menu').innerHTML = '<div class="loadicon vm"></div> 请稍候... ';
}
function atSearch(kw, call) {
if(atKeywords === null) {
atKeywords = '';
var x = new Ajax();
x.get('misc.php?mod=getatuser&inajax=1', function(s) {
if(s) {
atKeywords = s.split(',');
}
if(call) {
if(typeof call == 'function') {
call();
} else {
eval(call);
}
}
});
}
var lsi = 0;
for(i in atKeywords) {
if(atKeywords[i].indexOf(kw) !== -1 || kw === '') {
atResult[lsi] = kw !== '' ? atKeywords[i].replace(kw, '<b>' + kw + '</b>') : atKeywords[i];
lsi++;
if(lsi > 10) {
break;
}
}
}
if(kw && !lsi) {
curatli = -1;
}
}
function atEnter(e, call) {
if(e) {
if(e.keyCode == 38 && curatli > 0) {
curatli--;
return false;
}
if(e.keyCode == 40 && curatli < (atResult.length -1)) {
curatli++;
return false;
}
if(e.keyCode == 13) {
var call = !call ? 'insertText' : call;
if(curatli > -1) {
eval(call+'($(\'atli_'+curatli+'\').innerText)');
}
hideMenu();
doane(e);
return true;
}
}
return false;
}
function atFilter(kw, id, call, e, nae) {
var nae = !nae ? false : nae;
atResult = [];
atSearch(kw, function () { atFilter(kw, id, call); });
if(nae || !atEnter(e, call)) {
var newlist = '';
if(atResult.length) {
$(id).style.visibility = 'visible';
for(i in atResult) {
var atclass = i == curatli ? ' class="a"' : '';
newlist += '<li><a href="javascript:;" id="atli_'+i+'"'+atclass+' onclick="'+call+'(this.innerText)">' + atResult[i] + '</a></li>';
}
$(id).innerHTML = '<ul>' + newlist + '<li class="xg1">@朋友账号,就能提醒他来看文章</li></ul>';
} else {
$(id).style.visibility = 'hidden';
}
}
}
function atListSet(kw) {
$('atkeyword').value = kw;
if(!atsubmitid) {
$(editorid + '_at_submit').click();
} else {
$(atsubmitid).click();
}
}
function atMenuSet(kw) {
keyMenuObj.innerHTML = '@' + kw + (wysiwyg ? '&nbsp;' : ' ');
$('at_menu').style.display = 'none';
ctlent_enable[13] = 1;
curatli = 0;
if(BROWSER.firefox) {
var selection = editwin.getSelection();
var range = selection.getRangeAt(0);
var tmp = keyMenuObj.firstChild;
range.setStart(tmp, keyMenuObj.innerHTML.length - 5);
range.setEnd(tmp, keyMenuObj.innerHTML.length - 5);
selection.removeAllRanges();
selection.addRange(range);
}
checkFocus();
}

108
static/js/autoloadpage.js Normal file
View File

@@ -0,0 +1,108 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: autoloadpage.js 33246 2013-05-09 02:07:17Z kamichen $
*/
(function() {
var autopbn = $('autopbn');
var nextpageurl = autopbn.getAttribute('rel').valueOf();
var curpage = parseInt(autopbn.getAttribute('curpage').valueOf());
var totalpage = parseInt(autopbn.getAttribute('totalpage').valueOf());
var picstyle = parseInt(autopbn.getAttribute('picstyle').valueOf());
var forumdefstyle = parseInt(autopbn.getAttribute('forumdefstyle').valueOf());
picstyle = picstyle && !forumdefstyle;
var autopagenum = 0;
var maxpage = (curpage + autopagenum) > totalpage ? totalpage : (curpage + autopagenum);
var loadstatus = 0;
autopbn.onclick = function() {
var oldloadstatus = loadstatus;
loadstatus = 2;
autopbn.innerHTML = '正在加载, 请稍后...';
getnextpagecontent();
loadstatus = oldloadstatus;
};
if(autopagenum > 0) {
window.onscroll = function () {
var curtop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
if(curtop + document.documentElement.clientHeight + 500 >= document.documentElement.scrollHeight && !loadstatus) {
loadstatus = 1;
autopbn.innerHTML = '正在加载, 请稍后...';
setTimeout(getnextpagecontent, 1000);
}
};
}
function getnextpagecontent() {
if(curpage + 1 > totalpage) {
window.onscroll = null;
autopbn.style.display = 'none';
return;
}
if(loadstatus != 2 && curpage + 1 > maxpage) {
autopbn.innerHTML = '下一页 &raquo;';
if(curpage + 1 > maxpage) {
window.onscroll = null;
}
return;
}
curpage++;
var url = nextpageurl + '&t=' + parseInt((+new Date()/1000)/(Math.random()*1000));
var x = new Ajax('HTML');
x.get(url, function (s) {
s = s.replace(/\n|\r/g, ' ');
if(s.indexOf("id=\"autopbn\"") == -1) {
$("autopbn").style.display = "none";
window.onscroll = null;
}
if(!picstyle) {
var tableobj = $('threadlisttableid');
var nexts = s.match(/\<tbody id="normalthread_(\d+)"\>(.+?)\<\/tbody>/g);
for(i in nexts) {
if(i == 'index' || i == 'lastIndex') {
continue;
}
var insertid = nexts[i].match(/<tbody id="normalthread_(\d+)"\>/);
if(!$('normalthread_' + insertid[1])) {
var newbody = document.createElement('tbody');
tableobj.appendChild(newbody);
var div = document.createElement('div');
div.innerHTML = '<table>' + nexts[i] + '</table>';
tableobj.replaceChild(div.childNodes[0].childNodes[0], tableobj.lastChild);
}
}
} else {
var nexts = s.match(/\<li style="width:\d+px;" id="picstylethread_(\d+)"\>(.+?)\<\/li\>/g);
for(i in nexts) {
var insertid = nexts[i].match(/id="picstylethread_(\d+)"\>/);
if(!$('picstylethread_' + insertid[1])) {
$('threadlist_picstyle').innerHTML += nexts[i];
}
}
}
var pageinfo = s.match(/\<span id="fd_page_bottom"\>(.+?)\<\/span\>/);
nextpageurl = nextpageurl.replace(/&page=\d+/, '&page=' + (curpage + 1));
$('fd_page_bottom').innerHTML = pageinfo[1];
var pageinfo = s.match(/\<span id="fd_page_top"\>(.+?)\<\/span\>/);
$('fd_page_top').innerHTML = pageinfo[1];
autopbn.style.display = 'none';
if (curpage + 1 <= totalpage) {
autopbn.innerHTML = '下一页 &raquo;';
setTimeout(function () {
autopbn.style.display = 'block';
}, 100);
}
loadstatus = 0;
});
}
})();

772
static/js/bbcode.js Normal file
View File

@@ -0,0 +1,772 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: bbcode.js 36359 2017-01-20 05:06:45Z nemohou $
*/
var re, DISCUZCODE = [];
DISCUZCODE['num'] = '-1';
DISCUZCODE['html'] = [];
EXTRAFUNC['bbcode2html'] = [];
EXTRAFUNC['html2bbcode'] = [];
function addslashes(str) {
return preg_replace(['\\\\', '\\\'', '\\\/', '\\\(', '\\\)', '\\\[', '\\\]', '\\\{', '\\\}', '\\\^', '\\\$', '\\\?', '\\\.', '\\\*', '\\\+', '\\\|'], ['\\\\', '\\\'', '\\/', '\\(', '\\)', '\\[', '\\]', '\\{', '\\}', '\\^', '\\$', '\\?', '\\.', '\\*', '\\+', '\\|'], str);
}
function atag(aoptions, text) {
if(trim(text) == '') {
return '';
}
var pend = parsestyle(aoptions, '', '');
href = getoptionvalue('href', aoptions);
if(href.substr(0, 11) == 'javascript:') {
return trim(recursion('a', text, 'atag'));
}
return pend['prepend'] + '[url=' + href + ']' + trim(recursion('a', text, 'atag')) + '[/url]' + pend['append'];
}
function bbcode2html(str) {
if(str == '') {
return '';
}
if(typeof(parsetype) == 'undefined') {
parsetype = 0;
}
if(!fetchCheckbox('bbcodeoff') && allowbbcode && parsetype != 1) {
str = str.replace(/\[code\]([\s\S]+?)\[\/code\]/ig, function($1, $2) {return parsecode($2);});
}
if(fetchCheckbox('allowimgurl')) {
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|webp))/ig, '$1[img]$2[/img]');
}
if(!allowhtml || !fetchCheckbox('htmlon')) {
str = str.replace(/</g, '&lt;');
str = str.replace(/>/g, '&gt;');
if(!fetchCheckbox('parseurloff')) {
str = parseurl(str, 'html', false);
}
}
for(i in EXTRAFUNC['bbcode2html']) {
EXTRASTR = str;
try {
eval('str = ' + EXTRAFUNC['bbcode2html'][i] + '()');
} catch(e) {}
}
if(!fetchCheckbox('smileyoff') && allowsmilies) {
if(typeof smilies_type == 'object') {
for(var typeid in smilies_array) {
for(var page in smilies_array[typeid]) {
for(var i in smilies_array[typeid][page]) {
re = new RegExp(preg_quote(smilies_array[typeid][page][i][1]), "g");
str = str.replace(re, '<img src="' + STATICURL + 'image/smiley/' + smilies_type['_' + typeid][1] + '/' + smilies_array[typeid][page][i][2] + '" border="0" smilieid="' + smilies_array[typeid][page][i][0] + '" alt="' + smilies_array[typeid][page][i][1] + '" />');
}
}
}
}
}
if(!fetchCheckbox('bbcodeoff') && allowbbcode) {
str = clearcode(str);
str = str.replace(/\[url\]\s*((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)([^\[\"']+?)\s*\[\/url\]/ig, function($1, $2, $3, $4) {return cuturl($2 + $4);});
str = str.replace(/\[url=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:|tel:|magnet:)?([^\r\n\[\"']+?)\]([\s\S]+?)\[\/url\]/ig, '<a href="$1$3" target="_blank">$4</a>');
str = str.replace(/\[email\](.[^\\=[]*)\[\/email\]/ig, '<a href="mailto:$1">$1</a>');
str = str.replace(/\[email=(.[^\\=[]*)\](.*?)\[\/email\]/ig, '<a href="mailto:$1" target="_blank">$2</a>');
str = str.replace(/\[postbg\]\s*([^\[\<\r\n;'\"\?\(\)]+?)\s*\[\/postbg\]/ig, function($1, $2) {
addCSS = '';
if(in_array($2, postimg_type["postbg"])) {
addCSS = '<style type="text/css" name="editorpostbg">body{background-image:url("'+STATICURL+'image/postbg/'+$2+'");}</style>';
}
return addCSS;
});
str = str.replace(/\[color=([\w#\(\),\.\s]+?)\]/ig, '<font color="$1">');
str = str.replace(/\[backcolor=([\w#\(\),\.\s]+?)\]/ig, '<font style="background-color:$1">');
str = str.replace(/\[size=(\d+?)\]/ig, '<font size="$1">');
str = str.replace(/\[size=(\d+(\.\d+)?(px|pt)+?)\]/ig, '<font style="font-size: $1">');
str = str.replace(/\[font=([^\[\<\=]+?)\]/ig, '<font face="$1">');
str = str.replace(/\[align=([^\[\<\=]+?)\]/ig, '<div align="$1">');
str = str.replace(/\[p=(\d{1,2}|null), (\d{1,2}|null), (left|center|right)\]/ig, '<p style="line-height: $1px; text-indent: $2em; text-align: $3;">');
str = str.replace(/\[float=left\]/ig, '<br style="clear: both"><span style="float: left; margin-right: 5px;">');
str = str.replace(/\[float=right\]/ig, '<br style="clear: both"><span style="float: right; margin-left: 5px;">');
if(parsetype != 1) {
str = str.replace(/\[quote]([\s\S]*?)\[\/quote\]\s?\s?/ig, '<div class="quote"><blockquote>$1</blockquote></div>\n');
}
re = /\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*([\s\S]+?)\s*\[\/table\]/ig;
for (i = 0; i < 4; i++) {
str = str.replace(re, function($1, $2, $3, $4) {return parsetable($2, $3, $4);});
}
str = preg_replace([
'\\\[\\\/color\\\]', '\\\[\\\/backcolor\\\]', '\\\[\\\/size\\\]', '\\\[\\\/font\\\]', '\\\[\\\/align\\\]', '\\\[\\\/p\\\]', '\\\[b\\\]', '\\\[\\\/b\\\]',
'\\\[i\\\]', '\\\[\\\/i\\\]', '\\\[u\\\]', '\\\[\\\/u\\\]', '\\\[s\\\]', '\\\[\\\/s\\\]', '\\\[hr\\\]', '\\\[list\\\]', '\\\[list=1\\\]', '\\\[list=a\\\]',
'\\\[list=A\\\]', '\\s?\\\[\\\*\\\]', '\\\[\\\/list\\\]', '\\\[indent\\\]', '\\\[\\\/indent\\\]', '\\\[\\\/float\\\]'
], [
'</font>', '</font>', '</font>', '</font>', '</div>', '</p>', '<b>', '</b>', '<i>',
'</i>', '<u>', '</u>', '<strike>', '</strike>', '<hr class="l" />', '<ul>', '<ul type=1 class="litype_1">', '<ul type=a class="litype_2">',
'<ul type=A class="litype_3">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'
], str, 'g');
}
if(!fetchCheckbox('bbcodeoff')) {
if(allowimgcode) {
str = str.replace(/\[img\]\s*([^\[\"\<\r\n]+?)\s*\[\/img\]/ig, '<img src="$1" border="0" alt="" style="max-width:400px" />');
str = str.replace(/\[attachimg\](\d+)\[\/attachimg\]/ig, function ($1, $2) {
if(!$('image_' + $2)) {
return '';
}
width = $('image_' + $2).getAttribute('cwidth');
if(!width) {
re = /cwidth=(["']?)(\d+)(\1)/i;
var matches = re.exec($('image_' + $2).outerHTML);
if(matches != null) {
width = matches[2];
}
}
return '<img src="' + $('image_' + $2).src + '" border="0" aid="attachimg_' + $2 + '" width="' + width + '" alt="" />';
});
str = str.replace(/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\"\<\r\n]+?)\s*\[\/img\]/ig, function ($1, $2, $3, $4) {return '<img' + ($2 > 0 ? ' width="' + $2 + '"' : '') + ($3 > 0 ? ' _height="' + $3 + '"' : '') + ' src="' + $4 + '" border="0" alt="" />'});
} else {
str = str.replace(/\[img\]\s*([^\[\"\<\r\n]+?)\s*\[\/img\]/ig, '<a href="$1" target="_blank">$1</a>');
str = str.replace(/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\"\<\r\n]+?)\s*\[\/img\]/ig, '<a href="$3" target="_blank">$3</a>');
}
}
for(var i = 0; i <= DISCUZCODE['num']; i++) {
str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]);
}
if(!allowhtml || !fetchCheckbox('htmlon')) {
str = str.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {
return $2 + preg_replace(['\t', ' ', ' ', '(\r\n|\n|\r)'], ['&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;', '<br />'], $3);
});
} else {
str = str.replace(/<script[^\>]*?>([^\x00]*?)<\/script>/ig, '');
}
return str;
}
function clearcode(str) {
str= str.replace(/\[url\]\[\/url\]/ig, '', str);
str= str.replace(/\[url=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:|tel:|magnet:)?([^\s\[\"']+?)\]\[\/url\]/ig, '', str);
str= str.replace(/\[email\]\[\/email\]/ig, '', str);
str= str.replace(/\[email=(.[^\[]*)\]\[\/email\]/ig, '', str);
str= str.replace(/\[color=([^\[\<]+?)\]\[\/color\]/ig, '', str);
str= str.replace(/\[size=(\d+?)\]\[\/size\]/ig, '', str);
str= str.replace(/\[size=(\d+(\.\d+)?(px|pt)+?)\]\[\/size\]/ig, '', str);
str= str.replace(/\[font=([^\[\<]+?)\]\[\/font\]/ig, '', str);
str= str.replace(/\[align=([^\[\<]+?)\]\[\/align\]/ig, '', str);
str= str.replace(/\[p=(\d{1,2}), (\d{1,2}), (left|center|right)\]\[\/p\]/ig, '', str);
str= str.replace(/\[float=([^\[\<]+?)\]\[\/float\]/ig, '', str);
str= str.replace(/\[quote\]\[\/quote\]/ig, '', str);
str= str.replace(/\[code\]\[\/code\]/ig, '', str);
str= str.replace(/\[table\]\[\/table\]/ig, '', str);
str= str.replace(/\[free\]\[\/free\]/ig, '', str);
str= str.replace(/\[b\]\[\/b]/ig, '', str);
str= str.replace(/\[u\]\[\/u]/ig, '', str);
str= str.replace(/\[i\]\[\/i]/ig, '', str);
str= str.replace(/\[s\]\[\/s]/ig, '', str);
return str;
}
function cuturl(url) {
var length = 65;
var urllink = '<a href="' + (url.toLowerCase().substr(0, 4) == 'www.' ? 'http://' + url : url) + '" target="_blank">';
if(url.length > length) {
url = url.substr(0, parseInt(length * 0.5)) + ' ... ' + url.substr(url.length - parseInt(length * 0.3));
}
urllink += url + '</a>';
return urllink;
}
function dstag(options, text, tagname) {
if(trim(text) == '') {
return '\n';
}
var pend = parsestyle(options, '', '');
var prepend = pend['prepend'];
var append = pend['append'];
if(in_array(tagname, ['div', 'p'])) {
align = getoptionvalue('align', options);
if(in_array(align, ['left', 'center', 'right'])) {
prepend = '[align=' + align + ']' + prepend;
append += '[/align]';
} else {
append += '\n';
}
}
return prepend + recursion(tagname, text, 'dstag') + append;
}
function ptag(options, text, tagname) {
if(trim(text) == '') {
return '\n';
}
if(trim(options) == '') {
return text + '\n';
}
var lineHeight = null;
var textIndent = null;
var align, re, matches;
re = /line-height\s?:\s?(\d{1,3})px/i;
matches = re.exec(options);
if(matches != null) {
lineHeight = matches[1];
}
re = /text-indent\s?:\s?(\d{1,3})em/i;
matches = re.exec(options);
if(matches != null) {
textIndent = matches[1];
}
re = /text-align\s?:\s?(left|center|right)/i;
matches = re.exec(options);
if(matches != null) {
align = matches[1];
} else {
align = getoptionvalue('align', options);
}
align = in_array(align, ['left', 'center', 'right']) ? align : 'left';
style = getoptionvalue('style', options);
style = preg_replace(['line-height\\\s?:\\\s?(\\\d{1,3})px', 'text-indent\\\s?:\\\s?(\\\d{1,3})em', 'text-align\\\s?:\\\s?(left|center|right)'], '', style);
if(lineHeight === null && textIndent === null) {
return '[align=' + align + ']' + (style ? '<span style="' + style + '">' : '') + text + (style ? '</span>' : '') + '[/align]';
} else {
return '[p=' + lineHeight + ', ' + textIndent + ', ' + align + ']' + (style ? '<span style="' + style + '">' : '') + text + (style ? '</span>' : '') + '[/p]';
}
}
function fetchCheckbox(cbn) {
return $(cbn) && $(cbn).checked == true ? 1 : 0;
}
function fetchoptionvalue(option, text) {
if((position = strpos(text, option)) !== false) {
delimiter = position + option.length;
if(text.charAt(delimiter) == '"') {
delimchar = '"';
} else if(text.charAt(delimiter) == '\'') {
delimchar = '\'';
} else {
delimchar = ' ';
}
delimloc = strpos(text, delimchar, delimiter + 1);
if(delimloc === false) {
delimloc = text.length;
} else if(delimchar == '"' || delimchar == '\'') {
delimiter++;
}
return trim(text.substr(delimiter, delimloc - delimiter));
} else {
return '';
}
}
function fonttag(fontoptions, text) {
var prepend = '';
var append = '';
var tags = new Array();
tags = {'font' : 'face=', 'size' : 'size=', 'color' : 'color='};
for(bbcode in tags) {
optionvalue = fetchoptionvalue(tags[bbcode], fontoptions);
if(optionvalue) {
prepend += '[' + bbcode + '=' + optionvalue + ']';
append = '[/' + bbcode + ']' + append;
}
}
var pend = parsestyle(fontoptions, prepend, append);
return pend['prepend'] + recursion('font', text, 'fonttag') + pend['append'];
}
function getoptionvalue(option, text) {
re = new RegExp(option + "(\s+?)?\=(\s+?)?[\"']?(.+?)([\"']|$|>)", "ig");
var matches = re.exec(text);
if(matches != null) {
return trim(matches[3]);
}
return '';
}
function html2bbcode(str) {
if((allowhtml && fetchCheckbox('htmlon')) || trim(str) == '') {
for(i in EXTRAFUNC['html2bbcode']) {
EXTRASTR = str;
try {
eval('str = ' + EXTRAFUNC['html2bbcode'][i] + '()');
} catch(e) {}
}
str = str.replace(/<img[^>]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smileycode($3);});
str = str.replace(/<img([^>]*aid=[^>]*)>/ig, function($1, $2) {return imgtag($2);});
return str;
}
if(navigator.userAgent.indexOf('Chrome') > -1){
str = str.replace(/<div><br><\/div>/ig, '<br>');
str = str.replace(/<div>/ig, '<br><div>');
str = str.replace(/<\/div>((<br[^>]*>){1,})<div>/ig, '$1');
}
str = str.replace(/<div\sclass=["']?blockcode["']?>[\s\S]*?<blockquote>([\s\S]+?)<\/blockquote>[\s\S]*?<\/div>/ig, function($1, $2) {return codetag($2);});
if(!fetchCheckbox('bbcodeoff') && allowbbcode) {
var postbg = '';
str = str.replace(/<style[^>]+name="editorpostbg"[^>]*>body{background-image:url\("([^\[\<\r\n;'\"\?\(\)]+?)"\);}<\/style>/ig, function($1, $4) {
$4 = $4.replace(STATICURL+'image/postbg/', '');
return '[postbg]'+$4+'[/postbg]';
});
str = str.replace(/\[postbg\]\s*([^\[\<\r\n;'\"\?\(\)]+?)\s*\[\/postbg\]/ig, function($1, $2) {
postbg = $2;
return '';
});
if(postbg) {
str = '[postbg]'+postbg+'[/postbg]' + str;
}
}
str = preg_replace(['<style.*?>[\\\s\\\S]*?<\/style>', '<script.*?>[\\\s\\\S]*?<\/script>', '<noscript.*?>[\\\s\\\S]*?<\/noscript>', '<select.*?>[\s\S]*?<\/select>', '<object.*?>[\s\S]*?<\/object>', '<!--[\\\s\\\S]*?-->', ' on[a-zA-Z]{3,16}\\\s?=\\\s?"[\\\s\\\S]*?"'], '', str);
str= str.replace(/(\r\n|\n|\r)/ig, '');
str= str.replace(/&((#(32|127|160|173))|shy|nbsp);/ig, ' ');
if(fetchCheckbox('allowimgurl')) {
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|webp))/ig, '$1[img]$2[/img]');
}
if(!fetchCheckbox('parseurloff')) {
str = parseurl(str, 'bbcode', false);
}
for(i in EXTRAFUNC['html2bbcode']) {
EXTRASTR = str;
try {
eval('str = ' + EXTRAFUNC['html2bbcode'][i] + '()');
} catch(e) {}
}
str = str.replace(/<br\s+?style=(["']?)clear: both;?(\1)[^\>]*>/ig, '');
str = str.replace(/<br[^\>]*>/ig, "\n");
if(!fetchCheckbox('bbcodeoff') && allowbbcode) {
str = preg_replace([
'<table[^>]*float:\\\s*(left|right)[^>]*><tbody><tr><td>\\\s*([\\\s\\\S]+?)\\\s*<\/td><\/tr></tbody><\/table>',
'<table([^>]*(width|background|background-color|backcolor)[^>]*)>',
'<table[^>]*>',
'<tr[^>]*(?:background|background-color|backcolor)[:=]\\\s*(["\']?)([\(\)\\\s%,#\\\w]+)(\\1)[^>]*>',
'<tr[^>]*>',
'(<t[dh]([^>]*(left|center|right)[^>]*)>)\\\s*([\\\s\\\S]+?)\\\s*(<\/t[dh]>)',
'<t[dh]([^>]*(width|colspan|rowspan)[^>]*)>',
'<t[dh][^>]*>',
'<\/t[dh]>',
'<\/tr>',
'<\/table>',
'<h\\\d[^>]*>',
'<\/h\\\d>'
], [
function($1, $2, $3) {return '[float=' + $2 + ']' + $3 + '[/float]';},
function($1, $2) {return tabletag($2);},
'[table]\n',
function($1, $2, $3) {return '[tr=' + $3 + ']';},
'[tr]',
function($1, $2, $3, $4, $5, $6) {return $2 + '[align=' + $4 + ']' + $5 + '[/align]' + $6},
function($1, $2) {return tdtag($2);},
'[td]',
'[/td]',
'[/tr]\n',
'[/table]',
'[b]',
'[/b]'
], str);
str = str.replace(/<h([0-9]+)[^>]*>([\s\S]*?)<\/h\1>/ig, function($1, $2, $3) {return "[size=" + (7 - $2) + "]" + $3 + "[/size]\n\n";});
str = str.replace(/<hr[^>]*>/ig, "[hr]");
str = str.replace(/<img[^>]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smileycode($3);});
str = str.replace(/<img([^>]*src[^>]*)>/ig, function($1, $2) {return imgtag($2);});
str = str.replace(/<a\s+?name=(["']?)(.+?)(\1)[\s\S]*?>([\s\S]*?)<\/a>/ig, '$4');
str = str.replace(/<div[^>]*quote[^>]*><blockquote>([\s\S]*?)<\/blockquote><\/div>([\s\S]*?)(<br[^>]*>)?/ig, "[quote]$1[/quote]");
str = str.replace(/<div[^>]*blockcode[^>]*><blockquote>([\s\S]*?)<\/blockquote><\/div>([\s\S]*?)(<br[^>]*>)?/ig, "[code]$1[/code]");
str = recursion('b', str, 'simpletag', 'b');
str = recursion('strong', str, 'simpletag', 'b');
str = recursion('i', str, 'simpletag', 'i');
str = recursion('em', str, 'simpletag', 'i');
str = recursion('u', str, 'simpletag', 'u');
str = recursion('strike', str, 'simpletag', 's');
str = recursion('a', str, 'atag');
str = recursion('font', str, 'fonttag');
str = recursion('blockquote', str, 'simpletag', 'indent');
str = recursion('ol', str, 'listtag');
str = recursion('ul', str, 'listtag');
str = recursion('div', str, 'dstag');
str = recursion('p', str, 'ptag');
str = recursion('span', str, 'fonttag');
}
str = str.replace(/<[\/\!]*?[^<>]*?>/ig, '');
for(var i = 0; i <= DISCUZCODE['num']; i++) {
str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]);
}
str = clearcode(str);
return preg_replace(['&nbsp;', '&lt;', '&gt;', '&amp;'], [' ', '<', '>', '&'], str);
}
function tablesimple(s, table, str) {
if(strpos(str, '[tr=') || strpos(str, '[td=')) {
return s;
} else {
return '[table=' + table + ']\n' + preg_replace(['\\\[tr\\\]', '\\\[\\\/td\\\]\\\s?\\\[td\\\]', '\\\[\\\/tr\\\]\s?', '\\\[td\\\]', '\\\[\\\/td\\\]', '\\\[\\\/td\\\]\\\[\\\/tr\\\]'], ['', '|', '', '', '', '', ''], str) + '[/table]';
}
}
function imgtag(attributes) {
var width = '';
var height = '';
re = /src=(["']?)([\s\S]*?)(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
var src = matches[2];
} else {
return '';
}
re = /(max-)?width\s?:\s?(\d{1,4})(px)?/i;
var matches = re.exec(attributes);
if(matches != null && !matches[1]) {
width = matches[2];
}
re = /height\s?:\s?(\d{1,4})(px)?/i;
var matches = re.exec(attributes);
if(matches != null) {
height = matches[1];
}
if(!width) {
re = /width=(["']?)(\d+)(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
width = matches[2];
}
}
if(!height) {
re = /height=(["']?)(\d+)(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
height = matches[2];
}
}
re = /aid=(["']?)attachimg_(\d+)(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
return '[attachimg]' + matches[2] + '[/attachimg]';
}
width = width > 0 ? width : 0;
height = height > 0 ? height : 0;
return width > 0 || height > 0 ?
'[img=' + width + ',' + height + ']' + src + '[/img]' :
'[img]' + src + '[/img]';
}
function listtag(listoptions, text, tagname) {
text = text.replace(/<li>(([\s\S](?!<\/li))*?)(?=<\/?ol|<\/?ul|<li|\[list|\[\/list)/ig, '<li>$1</li>') + (BROWSER.opera ? '</li>' : '');
text = recursion('li', text, 'litag');
var opentag = '[list]';
var listtype = fetchoptionvalue('type=', listoptions);
listtype = listtype != '' ? listtype : (tagname == 'ol' ? '1' : '');
if(in_array(listtype, ['1', 'a', 'A'])) {
opentag = '[list=' + listtype + ']';
}
return text ? opentag + '\n' + recursion(tagname, text, 'listtag') + '[/list]' : '';
}
function litag(listoptions, text) {
return '[*]' + text.replace(/(\s+)$/g, '') + '\n';
}
function parsecode(text) {
DISCUZCODE['num']++;
text = text.replace(/\$/ig, '$$$$');
DISCUZCODE['html'][DISCUZCODE['num']] = '<div class="blockcode"><blockquote>' + htmlspecialchars(text) + '</blockquote></div>';
return "[\tDISCUZ_CODE_" + DISCUZCODE['num'] + "\t]";
}
function parsestyle(tagoptions, prepend, append) {
var searchlist = [
['align', true, 'text-align:\\s*(left|center|right);?', 1],
['float', true, 'float:\\s*(left|right);?', 1],
['color', true, '(^|[;\\s])color:\\s*([^;]+);?', 2],
['backcolor', true, '(^|[;\\s])background-color:\\s*([^;]+);?', 2],
['font', true, 'font-family:\\s*([^;]+);?', 1],
['size', true, 'font-size:\\s*(\\d+(\\.\\d+)?(px|pt|in|cm|mm|pc|em|ex|%|));?', 1],
['size', true, 'font-size:\\s*(x\\-small|small|medium|large|x\\-large|xx\\-large|\\-webkit\\-xxx\\-large);?', 1, 'size'],
['b', false, 'font-weight:\\s*(bold);?'],
['i', false, 'font-style:\\s*(italic);?'],
['u', false, 'text-decoration:\\s*(underline);?'],
['s', false, 'text-decoration:\\s*(line-through);?']
];
var sizealias = {'x-small':1,'small':2,'medium':3,'large':4,'x-large':5,'xx-large':6,'-webkit-xxx-large':7};
var style = getoptionvalue('style', tagoptions);
re = /^(?:\s|)color:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)(;?)/i;
style = style.replace(re, function($1, $2, $3, $4, $5) {return("color:#" + parseInt($2).toString(16) + parseInt($3).toString(16) + parseInt($4).toString(16) + $5);});
var len = searchlist.length;
for(var i = 0; i < len; i++) {
searchlist[i][4] = !searchlist[i][4] ? '' : searchlist[i][4];
re = new RegExp(searchlist[i][2], "ig");
match = re.exec(style);
if(match != null) {
opnvalue = match[searchlist[i][3]];
if(searchlist[i][4] == 'size') {
opnvalue = sizealias[opnvalue];
}
prepend += '[' + searchlist[i][0] + (searchlist[i][1] == true ? '=' + opnvalue + ']' : ']');
append = '[/' + searchlist[i][0] + ']' + append;
}
}
return {'prepend' : prepend, 'append' : append};
}
function parsetable(width, bgcolor, str) {
if(isUndefined(width)) {
var width = '';
} else {
try {
width = width.substr(width.length - 1, width.length) == '%' ? (width.substr(0, width.length - 1) <= 98 ? width : '98%') : (width <= 560 ? width : '98%');
} catch(e) { width = ''; }
}
if(isUndefined(str)) {
return;
}
if(strpos(str, '[/tr]') === false && strpos(str, '[/td]') === false) {
var rows = str.split('\n');
var s = '';
for(i = 0;i < rows.length;i++) {
s += '<tr><td>' + preg_replace(['\r', '\\\\\\\|', '\\\|', '\\\\n'], ['', '&#124;', '</td><td>', '\n'], rows[i]) + '</td></tr>';
}
str = s;
simple = ' simpletable';
} else {
simple = '';
str = str.replace(/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,4}%?))?\]/ig, function($1, $2, $3) {
return '<tr' + ($2 ? ' style="background-color: ' + $2 + '"' : '') + '><td' + ($3 ? ' width="' + $3 + '"' : '') + '>';
});
str = str.replace(/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4, $5) {
return '<tr' + ($2 ? ' style="background-color: ' + $2 + '"' : '') + '><td' + ($3 ? ' colspan="' + $3 + '"' : '') + ($4 ? ' rowspan="' + $4 + '"' : '') + ($5 ? ' width="' + $5 + '"' : '') + '>';
});
str = str.replace(/\[\/td\]\s*\[td(?:=(\d{1,4}%?))?\]/ig, function($1, $2) {
return '</td><td' + ($2 ? ' width="' + $2 + '"' : '') + '>';
});
str = str.replace(/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4) {
return '</td><td' + ($2 ? ' colspan="' + $2 + '"' : '') + ($3 ? ' rowspan="' + $3 + '"' : '') + ($4 ? ' width="' + $4 + '"' : '') + '>';
});
str = str.replace(/\[\/td\]\s*\[\/tr\]\s*/ig, '</td></tr>');
str = str.replace(/<td> <\/td>/ig, '<td>&nbsp;</td>');
}
return '<table ' + (width == '' ? '' : 'width="' + width + '" ') + 'class="t_table"' + (isUndefined(bgcolor) ? '' : ' style="background-color: ' + bgcolor + '"') + simple +'>' + str + '</table>';
}
function preg_quote(str) {
return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1");
}
function recursion(tagname, text, dofunction, extraargs) {
if(extraargs == null) {
extraargs = '';
}
tagname = tagname.toLowerCase();
var open_tag = '<' + tagname;
var open_tag_len = open_tag.length;
var close_tag = '</' + tagname + '>';
var close_tag_len = close_tag.length;
var beginsearchpos = 0;
do {
var textlower = text.toLowerCase();
var tagbegin = textlower.indexOf(open_tag, beginsearchpos);
if(tagbegin == -1) {
break;
}
var strlen = text.length;
var inquote = '';
var found = false;
var tagnameend = false;
var optionend = 0;
var t_char = '';
for(optionend = tagbegin; optionend <= strlen; optionend++) {
t_char = text.charAt(optionend);
if((t_char == '"' || t_char == "'") && inquote == '') {
inquote = t_char;
} else if((t_char == '"' || t_char == "'") && inquote == t_char) {
inquote = '';
} else if(t_char == '>' && !inquote) {
found = true;
break;
} else if((t_char == '=' || t_char == ' ') && !tagnameend) {
tagnameend = optionend;
}
}
if(!found) {
break;
}
if(!tagnameend) {
tagnameend = optionend;
}
var offset = optionend - (tagbegin + open_tag_len);
var tagoptions = text.substr(tagbegin + open_tag_len, offset);
var acttagname = textlower.substr(tagbegin * 1 + 1, tagnameend - tagbegin - 1);
if(acttagname != tagname) {
beginsearchpos = optionend;
continue;
}
var tagend = textlower.indexOf(close_tag, optionend);
if(tagend == -1) {
break;
}
var nestedopenpos = textlower.indexOf(open_tag, optionend);
while(nestedopenpos != -1 && tagend != -1) {
if(nestedopenpos > tagend) {
break;
}
tagend = textlower.indexOf(close_tag, tagend + close_tag_len);
nestedopenpos = textlower.indexOf(open_tag, nestedopenpos + open_tag_len);
}
if(tagend == -1) {
beginsearchpos = optionend;
continue;
}
var localbegin = optionend + 1;
var localtext = eval(dofunction)(tagoptions, text.substr(localbegin, tagend - localbegin), tagname, extraargs);
text = text.substring(0, tagbegin) + localtext + text.substring(tagend + close_tag_len);
beginsearchpos = tagbegin + localtext.length;
} while(tagbegin != -1);
return text;
}
function simpletag(options, text, tagname, parseto) {
if(trim(text) == '') {
return '';
}
text = recursion(tagname, text, 'simpletag', parseto);
return '[' + parseto + ']' + text + '[/' + parseto + ']';
}
function smileycode(smileyid) {
if(typeof smilies_type != 'object') return;
for(var typeid in smilies_array) {
for(var page in smilies_array[typeid]) {
for(var i in smilies_array[typeid][page]) {
if(smilies_array[typeid][page][i][0] == smileyid) {
return smilies_array[typeid][page][i][1];
break;
}
}
}
}
}
function strpos(haystack, needle, _offset) {
if(isUndefined(_offset)) {
_offset = 0;
}
var _index = haystack.toLowerCase().indexOf(needle.toLowerCase(), _offset);
return _index == -1 ? false : _index;
}
function tabletag(attributes) {
var width = '';
re = /width=(["']?)(\d{1,4}%?)(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
width = matches[2].substr(matches[2].length - 1, matches[2].length) == '%' ?
(matches[2].substr(0, matches[2].length - 1) <= 98 ? matches[2] : '98%') :
(matches[2] <= 560 ? matches[2] : '98%');
} else {
re = /width\s?:\s?(\d{1,4})([px|%])/i;
var matches = re.exec(attributes);
if(matches != null) {
width = matches[2] == '%' ? (matches[1] <= 98 ? matches[1] + '%' : '98%') : (matches[1] <= 560 ? matches[1] : '98%');
}
}
var bgcolor = '';
re = /(?:background|background-color|bgcolor)[:=]\s*(["']?)((rgb\(\d{1,3}%?,\s*\d{1,3}%?,\s*\d{1,3}%?\))|(#[0-9a-fA-F]{3,6})|([a-zA-Z]{1,20}))(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
bgcolor = matches[2];
width = width ? width : '98%';
}
return bgcolor ? '[table=' + width + ',' + bgcolor + ']\n' : (width ? '[table=' + width + ']\n' : '[table]\n');
}
function tdtag(attributes) {
var colspan = 1;
var rowspan = 1;
var width = '';
re = /colspan=(["']?)(\d{1,2})(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
colspan = matches[2];
}
re = /rowspan=(["']?)(\d{1,2})(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
rowspan = matches[2];
}
re = /width=(["']?)(\d{1,4}%?)(\1)/i;
var matches = re.exec(attributes);
if(matches != null) {
width = matches[2];
}
return in_array(width, ['', '0', '100%']) ?
(colspan == 1 && rowspan == 1 ? '[td]' : '[td=' + colspan + ',' + rowspan + ']') :
(colspan == 1 && rowspan == 1 ? '[td=' + width + ']' : '[td=' + colspan + ',' + rowspan + ',' + width + ']');
}
if(typeof jsloaded == 'function') {
jsloaded('bbcode');
}

249
static/js/calendar.js Normal file
View File

@@ -0,0 +1,249 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: calendar.js 33082 2013-04-18 11:13:53Z zhengqingpeng $
*/
var controlid = null;
var currdate = null;
var startdate = null;
var enddate = null;
var halfhour = false;
var yy = null;
var mm = null;
var hh = null;
var ii = null;
var currday = null;
var addtime = false;
var today = new Date();
var lastcheckedyear = false;
var lastcheckedmonth = false;
var calendarrecall = null;
function loadcalendar() {
s = '';
s += '<div id="calendar" style="display:none; position:absolute; z-index:100000;" onclick="doane(event)">';
s += '<div style="width: 260px;"><table cellspacing="0" cellpadding="0" width="100%" style="text-align: center;">';
s += '<tr align="center" id="calendar_week"><td onclick="refreshcalendar(yy, mm-1)" title="上一月" style="cursor: pointer;"><a href="javascript:;">&laquo;</a></td><td colspan="5" style="text-align: center"><a href="javascript:;" onclick="showdiv(\'year\');doane(event)" class="dropmenu" title="点击选择年份" id="year"></a>&nbsp; - &nbsp;<a id="month" class="dropmenu" title="点击选择月份" href="javascript:;" onclick="showdiv(\'month\');doane(event)"></a></td><td onclick="refreshcalendar(yy, mm+1)" title="下一月" style="cursor: pointer;"><a href="javascript:;">&raquo;</a></td></tr>';
s += '<tr id="calendar_header"><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>';
for(var i = 0; i < 6; i++) {
s += '<tr>';
for(var j = 1; j <= 7; j++)
s += "<td id=d" + (i * 7 + j) + " height=\"19\">0</td>";
s += "</tr>";
}
s += '<tr id="hourminute" class="pns"><td colspan="4" align="left"><input type="text" size="1" value="" id="hour" class="px vm" style="width: 40px;margin-right: 5px;" onKeyUp=\'this.value=this.value > 23 ? 23 : zerofill(this.value);controlid.value=controlid.value.replace(/\\d+(\:\\d+)/ig, this.value+"$1")\'>点';
s += '<span id="fullhourselector"><input type="text" size="1" value="" id="minute" class="px vm" style="width: 40px;margin: 0px 5px;" onKeyUp=\'this.value=this.value > 59 ? 59 : zerofill(this.value);controlid.value=controlid.value.replace(/(\\d+\:)\\d+/ig, "$1"+this.value)\'>分</span>';
s += '<span id="halfhourselector"><select id="minutehalfhourly" onchange=\'this.value=this.value > 59 ? 59 : zerofill(this.value);controlid.value=controlid.value.replace(/(\\d+\:)\\d+/ig, "$1"+this.value)\'><option value="00">00</option><option value="30">30</option></select>分</span>';
s += '</td><td align="right" colspan="3"><button class="pn" onclick="confirmcalendar();"><em>确定</em></button></td></tr>';
s += '</table></div></div>';
s += '<div id="calendar_year" onclick="doane(event)" style="display: none;z-index:100001;"><div class="col">';
for(var k = 2090; k >= 2001; k--) {
s += k != 2090 && k % 10 == 0 ? '</div><div class="col">' : '';
s += '<a href="javascript:;" onclick="refreshcalendar(' + k + ', mm);$(\'calendar_year\').style.display=\'none\'"><span' + (today.getFullYear() == k ? ' class="calendar_today"' : '') + ' id="calendar_year_' + k + '">' + k + '</span></a><br />';
}
s += '</div></div>';
s += '<div id="calendar_month" onclick="doane(event)" style="display: none;z-index:100001;">';
for(var k = 1; k <= 12; k++) {
s += '<a href="javascript:;" onclick="refreshcalendar(yy, ' + (k - 1) + ');$(\'calendar_month\').style.display=\'none\'"><span' + (today.getMonth()+1 == k ? ' class="calendar_today"' : '') + ' id="calendar_month_' + k + '">' + k + ( k < 10 ? '&nbsp;' : '') + ' 月</span></a><br />';
}
s += '</div>';
if(BROWSER.ie && BROWSER.ie < 7) {
s += '<iframe id="calendariframe" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
s += '<iframe id="calendariframe_year" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
s += '<iframe id="calendariframe_month" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
}
var div = document.createElement('div');
div.innerHTML = s;
$('append_parent').appendChild(div);
document.onclick = function(event) {
closecalendar(event);
};
$('calendar').onclick = function(event) {
doane(event);
$('calendar_year').style.display = 'none';
$('calendar_month').style.display = 'none';
if(BROWSER.ie && BROWSER.ie < 7) {
$('calendariframe_year').style.display = 'none';
$('calendariframe_month').style.display = 'none';
}
};
}
function closecalendar(event) {
$('calendar').style.display = 'none';
$('calendar_year').style.display = 'none';
$('calendar_month').style.display = 'none';
if(BROWSER.ie && BROWSER.ie < 7) {
$('calendariframe').style.display = 'none';
$('calendariframe_year').style.display = 'none';
$('calendariframe_month').style.display = 'none';
}
}
function parsedate(s) {
/(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec(s);
var m1 = (RegExp.$1 && RegExp.$1 > 1899 && RegExp.$1 < 2101) ? parseFloat(RegExp.$1) : today.getFullYear();
var m2 = (RegExp.$2 && (RegExp.$2 > 0 && RegExp.$2 < 13)) ? parseFloat(RegExp.$2) : today.getMonth() + 1;
var m3 = (RegExp.$3 && (RegExp.$3 > 0 && RegExp.$3 < 32)) ? parseFloat(RegExp.$3) : today.getDate();
var m4 = (RegExp.$4 && (RegExp.$4 > -1 && RegExp.$4 < 24)) ? parseFloat(RegExp.$4) : 0;
var m5 = (RegExp.$5 && (RegExp.$5 > -1 && RegExp.$5 < 60)) ? parseFloat(RegExp.$5) : 0;
/(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec("0000-00-00 00\:00");
return new Date(m1, m2 - 1, m3, m4, m5);
}
function settime(d) {
if(!addtime) {
$('calendar').style.display = 'none';
$('calendar_month').style.display = 'none';
if(BROWSER.ie && BROWSER.ie < 7) {
$('calendariframe').style.display = 'none';
}
}
controlid.value = yy + "-" + zerofill(mm + 1) + "-" + zerofill(d) + (addtime ? ' ' + zerofill($('hour').value) + ':' + zerofill($((halfhour) ? 'minutehalfhourly' : 'minute').value) : '');
if(typeof calendarrecall == 'function') {
calendarrecall();
} else {
eval(calendarrecall);
}
}
function confirmcalendar() {
if(addtime && controlid.value === '') {
controlid.value = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate() + ' ' + zerofill($('hour').value) + ':' + zerofill($((halfhour) ? 'minutehalfhourly' : 'minute').value);
}
closecalendar();
}
function initclosecalendar() {
var e = getEvent();
var aim = e.target || e.srcElement;
while (aim.parentNode != document.body) {
if (aim.parentNode.id == 'append_parent') {
aim.onclick = function () {closecalendar(e);};
}
aim = aim.parentNode;
}
}
function showcalendar(event, controlid1, addtime1, startdate1, enddate1, halfhour1, recall) {
controlid = controlid1;
addtime = addtime1;
startdate = startdate1 ? parsedate(startdate1) : false;
enddate = enddate1 ? parsedate(enddate1) : false;
currday = controlid.value ? parsedate(controlid.value) : today;
hh = currday.getHours();
ii = currday.getMinutes();
halfhour = halfhour1 ? true : false;
calendarrecall = recall ? recall : null;
var p = fetchOffset(controlid);
$('calendar').style.display = 'block';
$('calendar').style.left = p['left']+'px';
$('calendar').style.top = (p['top'] + 20)+'px';
doane(event);
refreshcalendar(currday.getFullYear(), currday.getMonth());
if(lastcheckedyear != false) {
$('calendar_year_' + lastcheckedyear).className = 'calendar_default';
$('calendar_year_' + today.getFullYear()).className = 'calendar_today';
}
if(lastcheckedmonth != false) {
$('calendar_month_' + lastcheckedmonth).className = 'calendar_default';
$('calendar_month_' + (today.getMonth() + 1)).className = 'calendar_today';
}
$('calendar_year_' + currday.getFullYear()).className = 'calendar_checked';
$('calendar_month_' + (currday.getMonth() + 1)).className = 'calendar_checked';
$('hourminute').style.display = addtime ? '' : 'none';
lastcheckedyear = currday.getFullYear();
lastcheckedmonth = currday.getMonth() + 1;
if(halfhour) {
$('halfhourselector').style.display = '';
$('fullhourselector').style.display = 'none';
} else {
$('halfhourselector').style.display = 'none';
$('fullhourselector').style.display = '';
}
if(BROWSER.ie && BROWSER.ie < 7) {
$('calendariframe').style.top = $('calendar').style.top;
$('calendariframe').style.left = $('calendar').style.left;
$('calendariframe').style.width = $('calendar').offsetWidth;
$('calendariframe').style.height = $('calendar').offsetHeight;
$('calendariframe').style.display = 'block';
}
initclosecalendar();
}
function refreshcalendar(y, m) {
var x = new Date(y, m, 1);
var mv = x.getDay();
var d = x.getDate();
var dd = null;
yy = x.getFullYear();
mm = x.getMonth();
$("year").innerHTML = yy;
$("month").innerHTML = mm + 1 > 9 ? (mm + 1) : '0' + (mm + 1);
for(var i = 1; i <= mv; i++) {
dd = $("d" + i);
dd.innerHTML = "&nbsp;";
dd.className = "";
}
while(x.getMonth() == mm) {
dd = $("d" + (d + mv));
dd.style.cursor = 'pointer';
dd.onclick = function () {
settime(this.childNodes[0].innerHTML);
doane();
};
dd.innerHTML = '<a href="javascript:;">' + d + '</a>';
if(x.getTime() < today.getTime() || (enddate && x.getTime() > enddate.getTime()) || (startdate && x.getTime() < startdate.getTime())) {
dd.className = 'calendar_expire';
} else {
dd.className = 'calendar_default';
}
if(x.getFullYear() == today.getFullYear() && x.getMonth() == today.getMonth() && x.getDate() == today.getDate()) {
dd.className = 'calendar_today';
dd.firstChild.title = '今天';
}
if(x.getFullYear() == currday.getFullYear() && x.getMonth() == currday.getMonth() && x.getDate() == currday.getDate()) {
dd.className = 'calendar_checked';
}
x.setDate(++d);
}
while(d + mv <= 42) {
dd = $("d" + (d + mv));
dd.innerHTML = "&nbsp;";
d++;
}
if(addtime) {
$('hour').value = zerofill(hh);
$('minute').value = zerofill(ii);
}
}
function showdiv(id) {
var p = fetchOffset($(id));
$('calendar_' + id).style.left = p['left']+'px';
$('calendar_' + id).style.top = (p['top'] + 16)+'px';
$('calendar_' + id).style.display = 'block';
if(BROWSER.ie && BROWSER.ie < 7) {
$('calendariframe_' + id).style.top = $('calendar_' + id).style.top;
$('calendariframe_' + id).style.left = $('calendar_' + id).style.left;
$('calendariframe_' + id).style.width = $('calendar_' + id).offsetWidth;
$('calendariframe_' + id ).style.height = $('calendar_' + id).offsetHeight;
$('calendariframe_' + id).style.display = 'block';
}
}
function zerofill(s) {
var s = parseFloat(s.toString().replace(/(^[\s0]+)|(\s+$)/g, ''));
s = isNaN(s) ? 0 : s;
return (s < 10 ? '0' : '') + s.toString();
}
if(!BROWSER.other) {
loadcss('forum_calendar');
loadcalendar();
}

2329
static/js/common.js Normal file

File diff suppressed because it is too large Load Diff

1899
static/js/common_diy.js Normal file

File diff suppressed because it is too large Load Diff

1256
static/js/common_extra.js Normal file

File diff suppressed because it is too large Load Diff

45
static/js/echarts/echarts.common.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

1791
static/js/editor.js Normal file

File diff suppressed because it is too large Load Diff

191
static/js/fileprogress.js Normal file
View File

@@ -0,0 +1,191 @@
/*
A simple class for displaying file information and progress
Note: This is a demonstration only and not part of SWFUpload.
Note: Some have had problems adapting this class in IE7. It may not be suitable for your application.
*/
function FileProgress(file, targetID) {
this.fileProgressID = file.id;
this.opacity = 100;
this.height = 0;
this.fileProgressWrapper = document.getElementById(this.fileProgressID);
if (!this.fileProgressWrapper) {
this.fileProgressWrapper = document.createElement("div");
this.fileProgressWrapper.className = "progressWrapper";
this.fileProgressWrapper.id = this.fileProgressID;
this.fileProgressElement = document.createElement("div");
this.fileProgressElement.className = "progressContainer";
var progressCancel = document.createElement("a");
progressCancel.className = "progressCancel";
progressCancel.href = "#";
progressCancel.style.visibility = "hidden";
progressCancel.appendChild(document.createTextNode(" "));
var progressText = document.createElement("div");
progressText.className = "progressName";
progressText.appendChild(document.createTextNode(file.name));
var progressBar = document.createElement("div");
progressBar.className = "progressBarInProgress";
var progressStatus = document.createElement("div");
progressStatus.className = "progressBarStatus";
progressStatus.innerHTML = "&nbsp;";
this.fileProgressElement.appendChild(progressCancel);
this.fileProgressElement.appendChild(progressText);
this.fileProgressElement.appendChild(progressStatus);
this.fileProgressElement.appendChild(progressBar);
this.fileProgressWrapper.appendChild(this.fileProgressElement);
document.getElementById(targetID).appendChild(this.fileProgressWrapper);
} else {
this.fileProgressElement = this.fileProgressWrapper.firstChild;
this.reset();
}
this.height = this.fileProgressWrapper.offsetHeight;
this.setTimer(null);
}
FileProgress.prototype.setTimer = function (timer) {
this.fileProgressElement["FP_TIMER"] = timer;
};
FileProgress.prototype.getTimer = function (timer) {
return this.fileProgressElement["FP_TIMER"] || null;
};
FileProgress.prototype.reset = function () {
this.fileProgressElement.className = "progressContainer";
this.fileProgressElement.childNodes[2].innerHTML = "&nbsp;";
this.fileProgressElement.childNodes[2].className = "progressBarStatus";
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
this.fileProgressElement.childNodes[3].style.width = "0%";
this.appear();
};
FileProgress.prototype.setProgress = function (percentage) {
this.fileProgressElement.className = "progressContainer green";
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
this.appear();
};
FileProgress.prototype.setComplete = function () {
this.fileProgressElement.className = "progressContainer blue";
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
this.fileProgressElement.childNodes[3].style.width = "";
};
FileProgress.prototype.setError = function () {
this.fileProgressElement.className = "progressContainer red";
this.fileProgressElement.childNodes[3].className = "progressBarError";
this.fileProgressElement.childNodes[3].style.width = "";
var oSelf = this;
this.setTimer(setTimeout(function () {
oSelf.disappear();
}, 5000));
};
FileProgress.prototype.setCancelled = function () {
this.fileProgressElement.className = "progressContainer";
this.fileProgressElement.childNodes[3].className = "progressBarError";
this.fileProgressElement.childNodes[3].style.width = "";
var oSelf = this;
this.setTimer(setTimeout(function () {
oSelf.disappear();
}, 2000));
};
FileProgress.prototype.setStatus = function (status) {
this.fileProgressElement.childNodes[2].innerHTML = status;
};
FileProgress.prototype.toggleCancel = function (show, swfUploadInstance) {
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
if (swfUploadInstance) {
var fileID = this.fileProgressID;
this.fileProgressElement.childNodes[0].onclick = function () {
swfUploadInstance.cancelUpload(fileID);
return false;
};
}
};
FileProgress.prototype.appear = function () {
if (this.getTimer() !== null) {
clearTimeout(this.getTimer());
this.setTimer(null);
}
if (this.fileProgressWrapper.filters) {
try {
this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100;
} catch (e) {
this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
}
} else {
this.fileProgressWrapper.style.opacity = 1;
}
this.fileProgressWrapper.style.height = "";
this.height = this.fileProgressWrapper.offsetHeight;
this.opacity = 100;
this.fileProgressWrapper.style.display = "";
};
FileProgress.prototype.disappear = function () {
var reduceOpacityBy = 15;
var reduceHeightBy = 4;
var rate = 30; // 15 fps
if (this.opacity > 0) {
this.opacity -= reduceOpacityBy;
if (this.opacity < 0) {
this.opacity = 0;
}
if (this.fileProgressWrapper.filters) {
try {
this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity;
} catch (e) {
this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
}
} else {
this.fileProgressWrapper.style.opacity = this.opacity / 100;
}
}
if (this.height > 0) {
this.height -= reduceHeightBy;
if (this.height < 0) {
this.height = 0;
}
this.fileProgressWrapper.style.height = this.height + "px";
}
if (this.height > 0 || this.opacity > 0) {
var oSelf = this;
this.setTimer(setTimeout(function () {
oSelf.disappear();
}, rate));
} else {
this.fileProgressWrapper.style.display = "none";
this.setTimer(null);
}
};

748
static/js/forum.js Normal file
View File

@@ -0,0 +1,748 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forum.js 33824 2013-08-19 08:26:11Z nemohou $
*/
function saveData(ignoreempty) {
var ignoreempty = isUndefined(ignoreempty) ? 0 : ignoreempty;
var obj = $('postform') && (($('fwin_newthread') && $('fwin_newthread').style.display == '') || ($('fwin_reply') && $('fwin_reply').style.display == '')) ? $('postform') : ($('fastpostform') ? $('fastpostform') : $('postform'));
if(!obj) return;
var bbcode = (typeof wysiwyg != 'undefined' && wysiwyg == 1) ? html2bbcode(editdoc.body.innerHTML) : obj.message.value;
if(typeof isfirstpost != 'undefined') {
if(typeof wysiwyg != 'undefined' && wysiwyg == 1) {
var messageisnull = trim(bbcode) === '';
} else {
var messageisnull = bbcode === '';
}
if(isfirstpost && (messageisnull && $('postform').subject.value === '')) {
return;
}
if(!isfirstpost && messageisnull) {
return;
}
}
var data = subject = message = '';
for(var i = 0; i < obj.elements.length; i++) {
var el = obj.elements[i];
if(el.name != '' && (el.tagName == 'SELECT' || el.tagName == 'TEXTAREA' || el.tagName == 'INPUT' && (el.type == 'text' || el.type == 'checkbox' || el.type == 'radio' || el.type == 'hidden' || el.type == 'select')) && el.name.substr(0, 6) != 'attach') {
var elvalue = el.value;
if(el.name == 'subject') {
subject = trim(elvalue);
} else if(el.name == 'message') {
if(typeof wysiwyg != 'undefined' && wysiwyg == 1) {
elvalue = bbcode;
}
message = trim(elvalue);
}
if((el.type == 'checkbox' || el.type == 'radio') && !el.checked) {
continue;
} else if(el.tagName == 'SELECT') {
elvalue = el.value;
} else if(el.type == 'hidden') {
if(el.id) {
eval('var check = typeof ' + el.id + '_upload == \'function\'');
if(check) {
elvalue = elvalue;
if($(el.id + '_url')) {
elvalue += String.fromCharCode(1) + $(el.id + '_url').value;
}
} else {
continue;
}
} else {
continue;
}
}
if(trim(elvalue)) {
data += el.name + String.fromCharCode(9) + el.tagName + String.fromCharCode(9) + el.type + String.fromCharCode(9) + elvalue + String.fromCharCode(9, 9);
}
}
}
if(!subject && !message && !ignoreempty) {
return;
}
saveUserdata('forum_'+discuz_uid, data);
}
function fastUload() {
appendscript(JSPATH + 'forum_post.js?' + VERHASH);
safescript('forum_post_js', function () { uploadWindow(function (aid, url) {updatefastpostattach(aid, url)}, 'file') }, 100, 50);
}
function switchAdvanceMode(url) {
var obj = $('postform') && (($('fwin_newthread') && $('fwin_newthread').style.display == '') || ($('fwin_reply') && $('fwin_reply').style.display == '')) ? $('postform') : $('fastpostform');
if(obj && obj.message.value != '') {
saveData();
url += (url.indexOf('?') != -1 ? '&' : '?') + 'cedit=yes';
}
location.href = url;
return false;
}
function sidebar_collapse(lang) {
if(lang[0]) {
toggle_collapse('sidebar', null, null, lang);
$('wrap').className = $('wrap').className == 'wrap with_side s_clear' ? 'wrap s_clear' : 'wrap with_side s_clear';
} else {
var collapsed = getcookie('collapse');
collapsed = updatestring(collapsed, 'sidebar', 1);
setcookie('collapse', collapsed, (collapsed ? 2592000 : -2592000));
location.reload();
}
}
function keyPageScroll(e, prev, next, url, page) {
if(loadUserdata('is_blindman')) {
return true;
}
e = e ? e : window.event;
var tagname = BROWSER.ie ? e.srcElement.tagName : e.target.tagName;
if(tagname == 'INPUT' || tagname == 'TEXTAREA') return;
actualCode = e.keyCode ? e.keyCode : e.charCode;
if(next && actualCode == 39) {
window.location = url + '&page=' + (page + 1);
}
if(prev && actualCode == 37) {
window.location = url + '&page=' + (page - 1);
}
}
function announcement() {
var ann = new Object();
ann.anndelay = 3000;
ann.annst = 0;
ann.annstop = 0;
ann.annrowcount = 0;
ann.anncount = 0;
ann.annScrollTopBegin = 0;
ann.annlis = $('anc').getElementsByTagName("li");
ann.annrows = new Array();
ann.announcementScroll = function() {
if (this.annstop) {
this.annst = setTimeout(function() {
ann.announcementScroll();
}, this.anndelay);
return;
}
if (!this.annst) {
var lasttop = -1;
for (i = 0; i < this.annlis.length; i++) {
if (lasttop != this.annlis[i].offsetTop) {
this.annrows[this.annrowcount] = this.annlis[i].offsetTop - this.annlis[0].offsetTop;
this.annrowcount++;
}
lasttop = this.annlis[i].offsetTop;
}
if (this.annrows.length == 1) {
$('an').onmouseover = $('an').onmouseout = null;
} else {
$('ancl').innerHTML += $('ancl').innerHTML;
this.annst = setTimeout(function() {
ann.announcementScroll();
}, this.anndelay);
$('an').onmouseover = function() {
ann.annstop = 1;
};
$('an').onmouseout = function() {
ann.annstop = 0;
};
}
this.annrowcount = 1;
return;
}
if (this.annrowcount >= this.annrows.length) {
$('anc').scrollTop = 0;
this.annrowcount = 1;
this.annst = setTimeout(function() {
ann.announcementScroll();
}, this.anndelay);
} else {
this.anncount = 0;
this.annScrollTopBegin = $('anc').scrollTop;
this.announcementScrollnext(this.annrows[this.annrowcount]);
}
}
;
ann.announcementScrollnext = function(targetTop) {
$('anc').scrollTop = this.annScrollTopBegin + this.anncount;
this.anncount++;
if ($('anc').scrollTop < targetTop) {
this.annst = setTimeout(function() {
ann.announcementScrollnext(targetTop);
}, 10);
} else {
this.annrowcount++;
this.annst = setTimeout(function() {
ann.announcementScroll();
}, this.anndelay);
}
}
;
ann.announcementScroll();
}
function removeindexheats() {
return confirm('您确认要把此主题从热点主题中移除么?');
}
function showTypes(id, mod) {
var o = $(id);
if(!o) return false;
var s = o.className;
mod = isUndefined(mod) ? 1 : mod;
var baseh = o.getElementsByTagName('li')[0].offsetHeight * 2;
var tmph = o.offsetHeight;
var lang = ['展开', '收起'];
var cls = ['unfold', 'fold'];
if(tmph > baseh) {
var octrl = document.createElement('li');
octrl.className = cls[mod];
octrl.innerHTML = lang[mod];
o.insertBefore(octrl, o.firstChild);
o.className = s + ' cttp';
mod && (o.style.height = 'auto');
octrl.onclick = function () {
if(this.className == cls[0]) {
o.style.height = 'auto';
this.className = cls[1];
this.innerHTML = lang[1];
} else {
o.style.height = '';
this.className = cls[0];
this.innerHTML = lang[0];
}
}
}
}
var postpt = 0;
function fastpostvalidate(theform, noajaxpost) {
if(postpt) {
return false;
}
postpt = 1;
setTimeout(function() {postpt = 0}, 2000);
noajaxpost = !noajaxpost ? 0 : noajaxpost;
s = '';
if(typeof fastpostvalidateextra == 'function') {
var v = fastpostvalidateextra();
if(!v) {
return false;
}
}
if(theform.message.value == '' || theform.subject.value == '') {
s = '抱歉,您尚未输入标题或内容';
theform.message.focus();
} else if(dstrlen(theform.subject.value) > 255) {
s = '您的标题超过 255 个字符的限制';
theform.subject.focus();
}
if(!disablepostctrl && dstrlen(trim(theform.subject.value)) && ((postminsubjectchars != 0 && dstrlen(theform.subject.value) < postminsubjectchars) || (postminsubjectchars != 0 && dstrlen(theform.subject.value) > postmaxsubjectchars))) {
showError('您的标题长度不符合要求。\n\n当前长度: ' + dstrlen(theform.subject.value) + ' 字\n系统限制: ' + postminsubjectchars + ' 到 ' + postmaxsubjectchars + ' 字');
return false;
}
if(!disablepostctrl && ((postminchars != 0 && mb_strlen(theform.message.value) < postminchars) || (postmaxchars != 0 && mb_strlen(theform.message.value) > postmaxchars))) {
s = '您的文章长度不符合要求。\n\n当前长度: ' + mb_strlen(theform.message.value) + ' ' + '字节\n系统限制: ' + postminchars + ' 到 ' + postmaxchars + ' 字节';
}
if(s) {
showError(s);
doane();
$('fastpostsubmit').disabled = false;
return false;
}
$('fastpostsubmit').disabled = true;
theform.message.value = theform.message.value.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(jpg|gif|png|bmp))/ig, '$1[img]$2[/img]');
theform.message.value = parseurl(theform.message.value);
if(!noajaxpost) {
ajaxpost('fastpostform', 'fastpostreturn', 'fastpostreturn', 'onerror', $('fastpostsubmit'));
return false;
} else {
return true;
}
}
function checkpostrule(showid, extra) {
var x = new Ajax();
x.get('forum.php?mod=ajax&action=checkpostrule&inajax=yes&' + extra, function(s) {
ajaxinnerhtml($(showid), s);evalscript(s);
});
}
function updatefastpostattach(aid, url) {
ajaxget('forum.php?mod=ajax&action=attachlist&posttime=' + $('posttime').value + (!fid ? '' : '&fid=' + fid), 'attachlist');
$('attach_tblheader').style.display = '';
}
function succeedhandle_fastnewpost(locationhref, message, param) {
location.href = locationhref;
}
function errorhandle_fastnewpost() {
$('fastpostsubmit').disabled = false;
}
function atarget(obj) {
obj.target = getcookie('atarget') > 0 ? '_blank' : '';
}
function setatarget(v) {
$('atarget').className = 'y atarget_' + v;
$('atarget').onclick = function() {setatarget(v == 1 ? -1 : 1);};
setcookie('atarget', v, 2592000);
}
function loadData(quiet, formobj) {
var evalevent = function (obj) {
var script = obj.parentNode.innerHTML;
var re = /onclick="(.+?)["|>]/ig;
var matches = re.exec(script);
if(matches != null) {
matches[1] = matches[1].replace(/this\./ig, 'obj.');
eval(matches[1]);
}
};
var data = '';
data = loadUserdata('forum_'+discuz_uid);
var formobj = !formobj ? $('postform') : formobj;
if(in_array((data = trim(data)), ['', 'null', 'false', null, false])) {
if(!quiet) {
showDialog('没有可以恢复的数据!', 'notice');
}
return;
}
if(!quiet && !confirm('此操作将覆盖当前文章内容,确定要恢复数据吗?')) {
return;
}
var data = data.split(/\x09\x09/);
for(var i = 0; i < formobj.elements.length; i++) {
var el = formobj.elements[i];
if(el.name != '' && (el.tagName == 'SELECT' || el.tagName == 'TEXTAREA' || el.tagName == 'INPUT' && (el.type == 'text' || el.type == 'checkbox' || el.type == 'radio' || el.type == 'hidden'))) {
for(var j = 0; j < data.length; j++) {
var ele = data[j].split(/\x09/);
if(ele[0] == el.name) {
elvalue = !isUndefined(ele[3]) ? ele[3] : '';
if(ele[1] == 'INPUT') {
if(ele[2] == 'text') {
el.value = elvalue;
} else if((ele[2] == 'checkbox' || ele[2] == 'radio') && ele[3] == el.value) {
el.checked = true;
evalevent(el);
} else if(ele[2] == 'hidden') {
eval('var check = typeof ' + el.id + '_upload == \'function\'');
if(check) {
var v = elvalue.split(/\x01/);
el.value = v[0];
if(el.value) {
if($(el.id + '_url') && v[1]) {
$(el.id + '_url').value = v[1];
}
eval(el.id + '_upload(\'' + v[0] + '\', \'' + v[1] + '\')');
if($('unused' + v[0])) {
var attachtype = $('unused' + v[0]).parentNode.parentNode.parentNode.parentNode.id.substr(11);
$('unused' + v[0]).parentNode.parentNode.outerHTML = '';
$('unusednum_' + attachtype).innerHTML = parseInt($('unusednum_' + attachtype).innerHTML) - 1;
if($('unusednum_' + attachtype).innerHTML == 0 && $('attachnotice_' + attachtype)) {
$('attachnotice_' + attachtype).style.display = 'none';
}
}
}
}
}
} else if(ele[1] == 'TEXTAREA') {
if(ele[0] == 'message') {
if(!wysiwyg) {
textobj.value = elvalue;
} else {
editdoc.body.innerHTML = bbcode2html(elvalue);
}
} else {
el.value = elvalue;
}
} else if(ele[1] == 'SELECT') {
if($(el.id + '_ctrl_menu')) {
var lis = $(el.id + '_ctrl_menu').getElementsByTagName('li');
for(var k = 0; k < lis.length; k++) {
if(ele[3] == lis[k].k_value) {
lis[k].onclick();
break;
}
}
} else {
for(var k = 0; k < el.options.length; k++) {
if(ele[3] == el.options[k].value) {
el.options[k].selected = true;
break;
}
}
}
}
break;
}
}
}
}
if($('rstnotice')) {
$('rstnotice').style.display = 'none';
}
extraCheckall();
}
var checkForumcount = 0, checkForumtimeout = 30000, checkForumnew_handle;
function checkForumnew(fid, lasttime) {
var timeout = checkForumtimeout;
var x = new Ajax();
x.get('forum.php?mod=ajax&action=forumchecknew&fid=' + fid + '&time=' + lasttime + '&inajax=yes', function(s){
if(s > 0) {
var table = $('separatorline').parentNode;
if(!isUndefined(checkForumnew_handle)) {
clearTimeout(checkForumnew_handle);
}
removetbodyrow(table, 'forumnewshow');
var colspan = table.getElementsByTagName('tbody')[0].rows[0].children.length;
var checknew = {'tid':'', 'thread':{'common':{'className':'', 'val':'<a href="javascript:void(0);" onclick="ajaxget(\'forum.php?mod=ajax&action=forumchecknew&fid=' + fid+ '&time='+lasttime+'&uncheck=1&inajax=yes\', \'forumnew\');">有新回复的主题,点击查看', 'colspan': colspan }}};
addtbodyrow(table, ['tbody'], ['forumnewshow'], 'separatorline', checknew);
} else {
if(checkForumcount < 50) {
if(checkForumcount > 0) {
var multiple = Math.ceil(50 / checkForumcount);
if(multiple < 5) {
timeout = checkForumtimeout * (5 - multiple + 1);
}
}
checkForumnew_handle = setTimeout(function () {checkForumnew(fid, lasttime);}, timeout);
}
}
checkForumcount++;
});
}
function checkForumnew_btn(fid) {
if(isUndefined(fid)) return;
ajaxget('forum.php?mod=ajax&action=forumchecknew&fid=' + fid+ '&time='+lasttime+'&uncheck=2&inajax=yes', 'forumnew', 'ajaxwaitid');
lasttime = parseInt(Date.parse(new Date()) / 1000);
}
function display_blocked_thread() {
var table = $('threadlisttableid');
if(!table) {
return;
}
var tbodys = table.getElementsByTagName('tbody');
for(i = 0;i < tbodys.length;i++) {
var tbody = tbodys[i];
if(tbody.style.display == 'none') {
table.appendChild(tbody);
tbody.style.display = '';
}
}
$('hiddenthread').style.display = 'none';
}
function addtbodyrow(table, insertID, changename, separatorid, jsonval) {
if(isUndefined(table) || isUndefined(insertID[0])) {
return;
}
var insertobj = document.createElement(insertID[0]);
var thread = jsonval.thread;
var tid = !isUndefined(jsonval.tid) ? jsonval.tid : '' ;
if(!isUndefined(changename[1])) {
removetbodyrow(table, changename[1] + tid);
}
insertobj.id = changename[0] + tid;
if(!isUndefined(insertID[1])) {
insertobj.className = insertID[1];
}
if($(separatorid)) {
table.insertBefore(insertobj, $(separatorid).nextSibling);
} else {
table.insertBefore(insertobj, table.firstChild);
}
var newTH = insertobj.insertRow(-1);
for(var value in thread) {
if(value != 0) {
var cell = newTH.insertCell(-1);
if(isUndefined(thread[value]['val'])) {
cell.innerHTML = thread[value];
} else {
cell.innerHTML = thread[value]['val'];
}
if(!isUndefined(thread[value]['className'])) {
cell.className = thread[value]['className'];
}
if(!isUndefined(thread[value]['colspan'])) {
cell.colSpan = thread[value]['colspan'];
}
}
}
if(!isUndefined(insertID[2])) {
_attachEvent(insertobj, insertID[2], function() {insertobj.className = '';});
}
}
function removetbodyrow(from, objid) {
if(!isUndefined(from) && $(objid)) {
from.removeChild($(objid));
}
}
function leftside(id) {
$(id).className = $(id).className == 'a' ? '' : 'a';
if(id == 'lf_fav') {
setcookie('leftsidefav', $(id).className == 'a' ? 0 : 1, 2592000);
}
}
var DTimers = new Array();
var DItemIDs = new Array();
var DTimers_exists = false;
function settimer(timer, itemid) {
if(timer && itemid) {
DTimers.push(timer);
DItemIDs.push(itemid);
}
if(!DTimers_exists) {
setTimeout("showtime()", 1000);
DTimers_exists = true;
}
}
function showtime() {
for(i=0; i<=DTimers.length; i++) {
if(DItemIDs[i]) {
if(DTimers[i] == 0) {
$(DItemIDs[i]).innerHTML = '已结束';
DItemIDs[i] = '';
continue;
}
var timestr = '';
var timer_day = Math.floor(DTimers[i] / 86400);
var timer_hour = Math.floor((DTimers[i] % 86400) / 3600);
var timer_minute = Math.floor(((DTimers[i] % 86400) % 3600) / 60);
var timer_second = (((DTimers[i] % 86400) % 3600) % 60);
if(timer_day > 0) {
timestr += timer_day + '天';
}
if(timer_hour > 0) {
timestr += timer_hour + '小时'
}
if(timer_minute > 0) {
timestr += timer_minute + '分'
}
if(timer_second > 0) {
timestr += timer_second + '秒'
}
DTimers[i] = DTimers[i] - 1;
$(DItemIDs[i]).innerHTML = timestr;
}
}
setTimeout("showtime()", 1000);
}
function fixed_top_nv(eleid, disbind) {
this.nv = eleid && $(eleid) || $('nv');
this.openflag = this.nv && BROWSER.ie != 6;
this.nvdata = {};
this.init = function (disattachevent) {
if(this.openflag) {
if(!disattachevent) {
var obj = this;
_attachEvent(window, 'resize', function(){obj.reset();obj.init(1);obj.run();});
var switchwidth = $('switchwidth');
if(switchwidth) {
_attachEvent(switchwidth, 'click', function(){obj.reset();obj.openflag=false;});
}
}
var next = this.nv;
try {
if(this.nv.parentNode.id.substr(-3) != '_ph') {
var nvparent = document.createElement('div');
nvparent.id = this.nv.id + '_ph';
this.nv.parentNode.insertBefore(nvparent,this.nv);
nvparent.appendChild(this.nv);
}
this.nvdata.next = this.nv.parentNode;
this.nvdata.height = parseInt(this.nv.offsetHeight, 10);
this.nvdata.width = parseInt(this.nv.offsetWidth, 10);
this.nvdata.left = this.nv.getBoundingClientRect().left - document.documentElement.clientLeft;
this.nvdata.position = this.nv.style.position;
this.nvdata.opacity = this.nv.style.opacity;
} catch (e) {
this.nvdata.next = null;
}
}
};
this.run = function () {
var fixedheight = 0;
if(this.openflag && this.nvdata.next){
var nvnexttop = document.body.scrollTop || document.documentElement.scrollTop;
var dofixed = nvnexttop !== 0 && document.documentElement.clientHeight >= 15 && this.nvdata.next.getBoundingClientRect().top < 0;
if(dofixed) {
if(this.nv.style.position != 'fixed') {
this.nv.style.borderLeftWidth = '0';
this.nv.style.borderRightWidth = '0';
this.nv.style.height = this.nvdata.height + 'px';
this.nv.style.width = this.nvdata.width + 'px';
this.nv.style.top = '0';
this.nv.style.left = this.nvdata.left + 'px';
this.nv.style.position = 'fixed';
this.nv.style.zIndex = '199';
this.nv.style.opacity = 0.85;
this.nv.parentNode.style.height = this.nvdata.height + 'px';
}
} else {
if(this.nv.style.position != this.nvdata.position) {
this.reset();
}
}
if(this.nv.style.position == 'fixed') {
fixedheight = this.nvdata.height;
}
}
return fixedheight;
};
this.reset = function () {
if(this.nv) {
this.nv.style.position = this.nvdata.position;
this.nv.style.borderLeftWidth = '';
this.nv.style.borderRightWidth = '';
this.nv.style.height = '';
this.nv.style.width = '';
this.nv.style.opacity = this.nvdata.opacity;
this.nv.parentNode.style.height = '';
}
};
if(!disbind && this.openflag) {
this.init();
_attachEvent(window, 'scroll', this.run);
}
}
var previewTbody = null, previewTid = null, previewDiv = null;
function previewThread(tid, tbody) {
if(!$('threadPreviewTR_'+tid)) {
appendscript(JSPATH + 'forum_viewthread.js?' + VERHASH);
newTr = document.createElement('tr');
newTr.id = 'threadPreviewTR_'+tid;
newTr.className = 'threadpre';
$(tbody).appendChild(newTr);
newTd = document.createElement('td');
newTd.colSpan = listcolspan;
newTd.className = 'threadpretd';
newTr.appendChild(newTd);
newTr.style.display = 'none';
previewTbody = tbody;
previewTid = tid;
if(BROWSER.ie) {
previewDiv = document.createElement('div');
previewDiv.id = 'threadPreview_'+tid;
previewDiv.style.id = 'none';
var x = Ajax();
x.get('forum.php?mod=viewthread&tid='+tid+'&inajax=1&from=preview', function(ret) {
var evaled = false;
if(ret.indexOf('ajaxerror') != -1) {
evalscript(ret);
evaled = true;
}
previewDiv.innerHTML = ret;
newTd.appendChild(previewDiv);
if(!evaled) evalscript(ret);
newTr.style.display = '';
});
} else {
newTd.innerHTML += '<div id="threadPreview_'+tid+'"></div>';
ajaxget('forum.php?mod=viewthread&tid='+tid+'&from=preview', 'threadPreview_'+tid, null, null, null, function() {newTr.style.display = '';});
}
} else {
$(tbody).removeChild($('threadPreviewTR_'+tid));
previewTbody = previewTid = null;
}
}
function hideStickThread(tid) {
var pre = 'stickthread_';
var tids = (new Function("return ("+(loadUserdata('sticktids') || '[]')+")"))();
var format = function (data) {
var str = '{';
for (var i in data) {
if(data[i] instanceof Array) {
str += i + ':' + '[';
for (var j = data[i].length - 1; j >= 0; j--) {
str += data[i][j] + ',';
};
str = str.substr(0, str.length -1);
str += '],';
}
}
str = str.substr(0, str.length -1);
str += '}';
return str;
};
if(!tid) {
if(tids.length > 0) {
for (var i = tids.length - 1; i >= 0; i--) {
var ele = $(pre+tids[i]);
if(ele) {
ele.parentNode.removeChild(ele);
}
};
}
} else {
var eletbody = $(pre+tid);
if(eletbody) {
eletbody.parentNode.removeChild(eletbody);
tids.push(tid);
saveUserdata('sticktids', '['+tids.join(',')+']');
}
}
var clearstickthread = $('clearstickthread');
if(clearstickthread) {
if(tids.length > 0) {
$('clearstickthread').style.display = '';
} else {
$('clearstickthread').style.display = 'none';
}
}
var separatorline = $('separatorline');
if(separatorline) {
try {
if(typeof separatorline.previousElementSibling === 'undefined') {
var findele = separatorline.previousSibling;
while(findele && findele.nodeType != 1){
findele = findele.previousSibling;
}
if(findele === null) {
separatorline.parentNode.removeChild(separatorline);
}
} else {
if(separatorline.previousElementSibling === null) {
separatorline.parentNode.removeChild(separatorline);
}
}
} catch(e) {
}
}
}
function viewhot() {
var obj = $('hottime');
window.location.href = "forum.php?mod=forumdisplay&filter=hot&fid="+obj.getAttribute('fid')+"&time="+obj.value;
}
function clearStickThread () {
saveUserdata('sticktids', '[]');
location.reload();
}

146
static/js/forum_moderate.js Normal file
View File

@@ -0,0 +1,146 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forum_moderate.js 26484 2011-12-14 02:08:03Z svn_project_zhangjie $
*/
function modaction(action, pid, extra, mod) {
if(!action) {
return;
}
var mod = mod ? mod : 'forum.php?mod=topicadmin';
var extra = !extra ? '' : '&' + extra;
if(!pid && in_array(action, ['delpost', 'banpost'])) {
var checked = 0;
var pid = '';
for(var i = 0; i < $('modactions').elements.length; i++) {
if($('modactions').elements[i].name.match('topiclist')) {
checked = 1;
break;
}
}
} else {
var checked = 1;
}
if(!checked) {
alert('请选择需要操作的文章');
} else {
$('modactions').action = mod + '&action='+ action +'&fid=' + fid + '&tid=' + tid + '&handlekey=mods&infloat=yes&nopost=yes' + (!pid ? '' : '&topiclist[]=' + pid) + extra + '&r' + Math.random();
showWindow('mods', 'modactions', 'post');
if(BROWSER.ie) {
doane(event);
}
hideMenu();
}
}
function modthreads(optgroup, operation) {
var operation = !operation ? '' : operation;
$('modactions').action = 'forum.php?mod=topicadmin&action=moderate&fid=' + fid + '&moderate[]=' + tid + '&handlekey=mods&infloat=yes&nopost=yes' + (optgroup != 3 && optgroup != 2 ? '&from=' + tid : '');
$('modactions').optgroup.value = optgroup;
$('modactions').operation.value = operation;
hideWindow('mods');
showWindow('mods', 'modactions', 'post', 0);
if(BROWSER.ie) {
doane(event);
}
}
function pidchecked(obj) {
if(obj.checked) {
try {
var inp = document.createElement('<input name="topiclist[]" />');
} catch(e) {
try {
var inp = document.createElement('input');
inp.name = 'topiclist[]';
} catch(e) {
return;
}
}
inp.id = 'topiclist_' + obj.value;
inp.value = obj.value;
inp.type = 'hidden';
$('modactions').appendChild(inp);
} else {
$('modactions').removeChild($('topiclist_' + obj.value));
}
}
var modclickcount = 0;
function modclick(obj, pid) {
if(obj.checked) {
modclickcount++;
} else {
modclickcount--;
}
$('mdct').innerHTML = modclickcount;
if(modclickcount > 0) {
var offset = fetchOffset(obj);
$('mdly').style.top = offset['top'] - 65 + 'px';
$('mdly').style.left = offset['left'] - 215 + 'px';
$('mdly').style.display = '';
} else {
$('mdly').style.display = 'none';
}
}
function resetmodcount() {
modclickcount = 0;
$('mdly').style.display = 'none';
}
function tmodclick(obj) {
if(obj.checked) {
modclickcount++;
} else {
modclickcount--;
}
$('mdct').innerHTML = modclickcount;
if(modclickcount > 0) {
var top_offset = obj.offsetTop;
while((obj = obj.offsetParent).id != 'threadlist') {
top_offset += obj.offsetTop;
}
$('mdly').style.top = top_offset - 7 + 'px';
$('mdly').style.display = '';
} else {
$('mdly').style.display = 'none';
}
}
function tmodthreads(optgroup, operation) {
var checked = 0;
var operation = !operation ? '' : operation;
for(var i = 0; i < $('moderate').elements.length; i++) {
if($('moderate').elements[i].name.match('moderate') && $('moderate').elements[i].checked) {
checked = 1;
break;
}
}
if(!checked) {
alert('请选择需要操作的文章');
} else {
$('moderate').optgroup.value = optgroup;
$('moderate').operation.value = operation;
hideWindow('mods');
showWindow('mods', 'moderate', 'post', 0);
}
}
function getthreadclass() {
var fid = $('fid');
if(fid) {
ajaxget('forum.php?mod=ajax&action=getthreadclass&fid=' + fid.value, 'threadclass', null, null, null, showthreadclass);
}
}
function showthreadclass() {
try{
$('append_parent').removeChild($('typeid_ctrl_menu'));
}catch(e) {}
simulateSelect('typeid');
}
loadcss('forum_moderator');

873
static/js/forum_post.js Normal file
View File

@@ -0,0 +1,873 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forum_post.js 33695 2013-08-03 04:39:22Z nemohou $
*/
var forum_post_inited = true;
var postSubmited = false;
var AID = {0:1,1:1};
var UPLOADSTATUS = -1;
var UPLOADFAILED = UPLOADCOMPLETE = AUTOPOST = 0;
var CURRENTATTACH = '0';
var FAILEDATTACHS = '';
var UPLOADWINRECALL = null;
var imgexts = typeof imgexts == 'undefined' ? 'jpg, jpeg, gif, png, bmp' : imgexts;
var ATTACHORIMAGE = '0';
var STATUSMSG = {
'-1' : '内部服务器错误',
'0' : '上传成功',
'1' : '不支持此类扩展名',
'2' : '服务器限制无法上传那么大的附件',
'3' : '用户组限制无法上传那么大的附件',
'4' : '不支持此类扩展名',
'5' : '文件类型限制无法上传那么大的附件',
'6' : '今日您已无法上传更多的附件',
'7' : '请选择图片文件(' + imgexts + ')',
'8' : '附件文件无法保存',
'9' : '没有合法的文件被上传',
'10' : '非法操作',
'11' : '今日您已无法上传那么大的附件',
'12' : '因文件名包含敏感词而无法提交',
'13' : '服务器限制无法上传分辨率过高的附件'
};
EXTRAFUNC['validator'] = [];
function checkFocus() {
var obj = wysiwyg ? editwin : textobj;
if(!obj.hasfocus) {
obj.focus();
}
}
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']) && !validate($('postform'))) {
doane(event);
return;
}
postSubmited = true;
$('postsubmit').disabled = true;
$('postform').submit();
}
if(event.keyCode == 9) {
doane(event);
}
}
function checklength(theform) {
var message = wysiwyg ? html2bbcode(getEditorContents()) : theform.message.value;
if(!theform.parseurloff.checked) {
message = parseurl(message);
}
showDialog('当前长度: ' + mb_strlen(message) + ' 字节,' + (postmaxchars != 0 ? '系统限制: ' + postminchars + ' 到 ' + postmaxchars + ' 字节。' : ''), 'notice', '字数检查');
}
if(!tradepost) {
var tradepost = 0;
}
function validate(theform) {
var message = wysiwyg ? html2bbcode(getEditorContents()) : theform.message.value;
if(!theform.parseurloff.checked) {
message = parseurl(message);
}
if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && trim(message) == "") {
showError('抱歉,您尚未输入标题或内容');
return false;
} else if(dstrlen(theform.subject.value) > 255) {
showError('您的标题超过 255 个字符的限制');
return false;
}
if(!disablepostctrl && theform.subject.value != "" && ((postminsubjectchars != 0 && dstrlen(theform.subject.value) < postminsubjectchars) || (postminsubjectchars != 0 && dstrlen(theform.subject.value) > postmaxsubjectchars))) {
showError('您的标题长度不符合要求。\n\n当前长度: ' + dstrlen(theform.subject.value) + ' 字\n系统限制: ' + postminsubjectchars + ' 到 ' + postmaxsubjectchars + ' 字');
return false;
}
if(in_array($('postsubmit').name, ['topicsubmit', 'editsubmit'])) {
if(theform.typeid && (theform.typeid.options && theform.typeid.options[theform.typeid.selectedIndex].value == 0) && typerequired) {
showError('请选择主题对应的分类');
return false;
}
if(theform.sortid && (theform.sortid.options && theform.sortid.options[theform.sortid.selectedIndex].value == 0) && sortrequired) {
showError('请选择主题对应的分类信息');
return false;
}
}
for(i in EXTRAFUNC['validator']) {
try {
eval('var v = ' + EXTRAFUNC['validator'][i] + '()');
if(!v) {
return false;
}
} catch(e) {}
}
if(!disablepostctrl && !sortid && !special && ((postminchars != 0 && mb_strlen(message) < postminchars) || (postmaxchars != 0 && mb_strlen(message) > postmaxchars))) {
showError('您的文章长度不符合要求。\n\n当前长度: ' + mb_strlen(message) + ' 字节\n系统限制: ' + postminchars + ' 到 ' + postmaxchars + ' 字节');
return false;
}
if(UPLOADSTATUS == 0) {
if(!confirm('您有等待上传的附件,确认不上传这些附件吗?')) {
return false;
}
} else if(UPLOADSTATUS == 1) {
showDialog('您有正在上传的附件,请稍候,上传完成后文章将会自动发表...', 'notice');
AUTOPOST = 1;
return false;
}
if(isfirstpost && $('adddynamic') != null && $('adddynamic').checked && $('postsave') != null && isNaN(parseInt($('postsave').value)) && ($('readperm') != null && $('readperm').value || $('price') != null && $('price').value)) {
if(confirm('由于您设置了阅读权限或出售帖,您确认还转播给您的听众看吗?') == false) {
return false;
}
}
theform.message.value = message;
if($('postsubmit').name == 'editsubmit') {
checkpostrule_post(theform);
return false;
} else if(in_array($('postsubmit').name, ['topicsubmit', 'replysubmit'])) {
if(seccodecheck || secqaacheck) {
var chk = 1, chkv = '';
if(secqaacheck) {
chkv = $('checksecqaaverify_' + theform.secqaahash.value).innerHTML;
if(chkv.indexOf('loading') != -1) {
setTimeout(function () { validate(theform); }, 100);
chk = 0;
} else if(chkv.indexOf('check_right') == -1) {
if($('secqaaverify_' + theform.secqaahash.value) == document.activeElement) {
$('postsubmit').focus();
setTimeout(function () { validate(theform); }, 100);
} else {
showError('验证问答错误,请重新填写');
}
chk = 0;
}
}
if(seccodecheck) {
chkv = $('checkseccodeverify_' + theform.seccodehash.value).innerHTML;
if(chkv.indexOf('loading') !== -1) {
setTimeout(function () { validate(theform); }, 100);
chk = 0;
} else if(chkv.indexOf('check_right') === -1) {
if($('seccodeverify_' + theform.seccodehash.value) == document.activeElement) {
$('postsubmit').focus();
setTimeout(function () { validate(theform); }, 100);
} else {
showError('验证码错误,请重新填写');
}
chk = 0;
}
}
if(chk) {
checkpostrule_post(theform);
}
} else {
checkpostrule_post(theform);
}
return false;
}
}
function checkpostrule_post(theform) {
if(!seccodecheck && !secqaacheck && !theform.sechash) {
var x = new Ajax();
x.get('forum.php?mod=ajax&action=checkpostrule&ac=' + postaction + '&inajax=yes', function(s) {
if(s) {
ajaxinnerhtml($('seccheck'), s);
evalscript(s);
seccodecheck = true;
} else {
postsubmit(theform);
}
});
} else {
postsubmit(theform);
}
}
function postsubmit(theform) {
if($(editorid + '_attachlist')) {
$('postbox').appendChild($(editorid + '_attachlist'));
$(editorid + '_attachlist').style.display = 'none';
}
if($(editorid + '_imgattachlist')) {
$('postbox').appendChild($(editorid + '_imgattachlist'));
$(editorid + '_imgattachlist').style.display = 'none';
}
hideMenu();
theform.replysubmit ? theform.replysubmit.disabled = true : (theform.editsubmit ? theform.editsubmit.disabled = true : theform.topicsubmit.disabled = true);
theform.submit();
}
function switchicon(iconid, obj) {
$('iconid').value = iconid;
$('icon_img').src = obj.src;
hideMenu();
}
function clearContent() {
if(wysiwyg) {
editdoc.body.innerHTML = BROWSER.firefox ? '<br />' : '';
} else {
textobj.value = '';
}
}
function uploadNextAttach() {
var str = $('attachframe').contentWindow.document.body.innerHTML;
if(str == '') return;
var arr = str.split('|');
var att = CURRENTATTACH.split('|');
var sizelimit = '';
if(arr[4] == 'ban') {
sizelimit = '(附件类型被禁止)';
} else if(arr[4] == 'perday') {
sizelimit = '(不能超过 ' + arr[5] + ' 字节)';
} else if(arr[4] > 0) {
sizelimit = '(不能超过 ' + arr[4] + ' 字节)';
}
uploadAttach(parseInt(att[0]), arr[0] == 'DISCUZUPLOAD' ? parseInt(arr[1]) : -1, att[1], sizelimit);
}
function uploadAttach(curId, statusid, prefix, sizelimit) {
prefix = isUndefined(prefix) ? '' : prefix;
var nextId = 0;
for(var i = 0; i < AID[prefix ? 1 : 0] - 1; i++) {
if($(prefix + 'attachform_' + i)) {
nextId = i;
if(curId == 0) {
break;
} else {
if(i > curId) {
break;
}
}
}
}
if(nextId == 0) {
return;
}
CURRENTATTACH = nextId + '|' + prefix;
if(curId > 0) {
if(statusid == 0) {
UPLOADCOMPLETE++;
} else {
FAILEDATTACHS += '<br />' + mb_cutstr($(prefix + 'attachnew_' + curId).value.substr($(prefix + 'attachnew_' + curId).value.replace(/\\/g, '/').lastIndexOf('/') + 1), 25) + ': ' + STATUSMSG[statusid] + sizelimit;
UPLOADFAILED++;
}
$(prefix + 'cpdel_' + curId).innerHTML = '<i class="fico' + (statusid == 0 ? 'check_right fc-v' : 'error fc-i') + ' fic4" alt="' + STATUSMSG[statusid] + '"></i>';
if(nextId == curId || in_array(statusid, [6, 8])) {
if(prefix == 'img') {
updateImageList();
} else {
updateAttachList();
}
if(UPLOADFAILED > 0) {
showDialog('附件上传完成!成功 ' + UPLOADCOMPLETE + ' 个,失败 ' + UPLOADFAILED + ' 个:' + FAILEDATTACHS);
FAILEDATTACHS = '';
}
UPLOADSTATUS = 2;
for(var i = 0; i < AID[prefix ? 1 : 0] - 1; i++) {
if($(prefix + 'attachform_' + i)) {
reAddAttach(prefix, i)
}
}
$(prefix + 'uploadbtn').style.display = '';
$(prefix + 'uploading').style.display = 'none';
if(AUTOPOST) {
hideMenu();
validate($('postform'));
} else if(UPLOADFAILED == 0 && (prefix == 'img' || prefix == '')) {
showDialog('附件上传完成!', 'right', null, null, 0, null, null, null, null, 3);
}
UPLOADFAILED = UPLOADCOMPLETE = 0;
CURRENTATTACH = '0';
FAILEDATTACHS = '';
return;
}
} else {
$(prefix + 'uploadbtn').style.display = 'none';
$(prefix + 'uploading').style.display = '';
}
$(prefix + 'cpdel_' + nextId).innerHTML = '<div class="loadicon" title="上传中..."></div>';
UPLOADSTATUS = 1;
$(prefix + 'attachform_' + nextId).submit();
}
function addAttach(prefix) {
var id = AID[prefix ? 1 : 0];
var tags, newnode, i;
prefix = isUndefined(prefix) ? '' : prefix;
newnode = $(prefix + 'attachbtnhidden').firstChild.cloneNode(true);
tags = newnode.getElementsByTagName('input');
for(i = 0;i < tags.length;i++) {
if(tags[i].name == 'Filedata') {
tags[i].id = prefix + 'attachnew_' + id;
tags[i].onchange = function() {insertAttach(prefix, id);};
tags[i].unselectable = 'on';
} else if(tags[i].name == 'attachid') {
tags[i].value = id;
}
}
tags = newnode.getElementsByTagName('form');
tags[0].name = tags[0].id = prefix + 'attachform_' + id;
$(prefix + 'attachbtn').appendChild(newnode);
newnode = $(prefix + 'attachbodyhidden').firstChild.cloneNode(true);
tags = newnode.getElementsByTagName('input');
for(i = 0;i < tags.length;i++) {
if(tags[i].name == prefix + 'localid[]') {
tags[i].value = id;
}
}
tags = newnode.getElementsByTagName('span');
for(i = 0;i < tags.length;i++) {
if(tags[i].id == prefix + 'localfile[]') {
tags[i].id = prefix + 'localfile_' + id;
} else if(tags[i].id == prefix + 'cpdel[]') {
tags[i].id = prefix + 'cpdel_' + id;
} else if(tags[i].id == prefix + 'localno[]') {
tags[i].id = prefix + 'localno_' + id;
} else if(tags[i].id == prefix + 'deschidden[]') {
tags[i].id = prefix + 'deschidden_' + id;
}
}
AID[prefix ? 1 : 0]++;
newnode.style.display = 'none';
$(prefix + 'attachbody').appendChild(newnode);
}
function insertAttach(prefix, id) {
var path = $(prefix + 'attachnew_' + id).value;
var extpos = path.lastIndexOf('.');
var ext = extpos == -1 ? '' : path.substr(extpos + 1, path.length).toLowerCase();
var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
var localfile = $(prefix + 'attachnew_' + id).value.substr($(prefix + 'attachnew_' + id).value.replace(/\\/g, '/').lastIndexOf('/') + 1);
var filename = mb_cutstr(localfile, 30);
if(path == '') {
return;
}
if(extensions != '' && (re.exec(extensions) == null || ext == '')) {
reAddAttach(prefix, id);
showError('对不起,不支持上传此类扩展名的附件。');
return;
}
if(prefix == 'img' && imgexts.indexOf(ext) == -1) {
reAddAttach(prefix, id);
showError('请选择图片文件(' + imgexts + ')');
return;
}
$(prefix + 'cpdel_' + id).innerHTML = '<a href="javascript:;" class="d" onclick="reAddAttach(\'' + prefix + '\', ' + id + ')">删除</a>';
$(prefix + 'localfile_' + id).innerHTML = '<span>' + filename + '</span>';
$(prefix + 'attachnew_' + id).style.display = 'none';
$(prefix + 'deschidden_' + id).style.display = '';
$(prefix + 'deschidden_' + id).title = localfile;
$(prefix + 'localno_' + id).parentNode.parentNode.style.display = '';
addAttach(prefix);
UPLOADSTATUS = 0;
}
function reAddAttach(prefix, id) {
$(prefix + 'attachbody').removeChild($(prefix + 'localno_' + id).parentNode.parentNode);
$(prefix + 'attachbtn').removeChild($(prefix + 'attachnew_' + id).parentNode.parentNode);
$(prefix + 'attachbody').innerHTML == '' && addAttach(prefix);
$('localimgpreview_' + id) ? document.body.removeChild($('localimgpreview_' + id)) : null;
}
function delAttach(id, type) {
var ids = {};
if(typeof id == 'number') {
ids[id] = id;
} else {
ids = id;
}
for(id in ids) {
if($('attach_' + id)) {
$('attach_' + id).style.display = 'none';
ATTACHNUM['attach' + (type ? 'un' : '') + 'used']--;
updateattachnum('attach');
}
}
appendAttachDel(ids);
}
function delImgAttach(id, type) {
var ids = {};
if(typeof id == 'number') {
ids[id] = id;
} else {
ids = id;
}
for(id in ids) {
if($('image_td_' + id)) {
$('image_td_' + id).className = 'imgdeleted';
$('image_' + id).onclick = null;
$('image_desc_' + id).disabled = true;
ATTACHNUM['image' + (type ? 'un' : '') + 'used']--;
updateattachnum('image');
}
}
appendAttachDel(ids);
}
function appendAttachDel(ids) {
if(!ids) {
return;
}
var aids = '';
for(id in ids) {
aids += '&aids[]=' + id;
}
list = document.getElementsByTagName("input");
formhash = null;
for(i=0; i<list.length; i++) {
if(list[i].name == "formhash") {
formhash = list[i].value;
break;
}
}
if(formhash) {
var x = new Ajax();
x.get('forum.php?mod=ajax&action=deleteattach&inajax=yes&formhash=' + formhash + '&tid=' + (typeof tid == 'undefined' ? 0 : tid) + '&pid=' + (typeof pid == 'undefined' ? 0 : pid) + aids + ($('modthreadkey') ? '&modthreadkey=' + $('modthreadkey').value : ''), function() {});
if($('delattachop')) {
$('delattachop').value = 1;
}
} else {
showError('抱歉,删除操作失败,请刷新页面后重试。');
}
}
function updateAttach(aid) {
objupdate = $('attachupdate'+aid);
obj = $('attach' + aid);
if(!objupdate.innerHTML) {
obj.style.display = 'none';
objupdate.innerHTML = '<input type="file" name="attachupdate[paid' + aid + ']"><a href="javascript:;" onclick="updateAttach(' + aid + ')">取消</a>';
} else {
obj.style.display = '';
objupdate.innerHTML = '';
}
}
function updateattachnum(type) {
ATTACHNUM[type + 'used'] = ATTACHNUM[type + 'used'] >= 0 ? ATTACHNUM[type + 'used'] : 0;
ATTACHNUM[type + 'unused'] = ATTACHNUM[type + 'unused'] >= 0 ? ATTACHNUM[type + 'unused'] : 0;
var num = ATTACHNUM[type + 'used'] + ATTACHNUM[type + 'unused'];
if(num) {
if($(editorid + '_' + type)) {
$(editorid + '_' + type).title = '包含 ' + num + (type == 'image' ? ' 个图片附件' : ' 个附件');
}
if($(editorid + '_' + type + 'n')) {
$(editorid + '_' + type + 'n').style.display = '';
}
ATTACHORIMAGE = 1;
} else {
if($(editorid + '_' + type)) {
$(editorid + '_' + type).title = type == 'image' ? '图片' : '附件';
}
if($(editorid + '_' + type + 'n')) {
$(editorid + '_' + type + 'n').style.display = 'none';
}
}
}
function swfHandler(action, type) {
if(action == 2) {
if(type == 'image') {
updateImageList();
} else {
updateAttachList();
}
}
}
function updateAttachList(action, aids) {
ajaxget('forum.php?mod=ajax&action=attachlist' + (!action ? '&posttime=' + $('posttime').value : (!aids ? '' : '&aids=' + aids)) + (!fid ? '' : '&fid=' + fid), 'attachlist');
switchAttachbutton('attachlist');$('attach_tblheader').style.display = $('attach_notice').style.display = '';
}
function updateImageList(action, aids) {
ajaxget('forum.php?mod=ajax&action=imagelist' + (!action ? '&pid=' + pid + '&posttime=' + $('posttime').value : (!aids ? '' : '&aids=' + aids)) + (!fid ? '' : '&fid=' + fid), 'imgattachlist');
switchImagebutton('imgattachlist');$('imgattach_notice').style.display = '';
}
function updateDownImageList(msg) {
hideMenu('fwin_dialog', 'dialog');
if(msg == '') {
showError('抱歉,暂无远程附件');
} else {
ajaxget('forum.php?mod=ajax&action=imagelist&pid=' + pid + '&posttime=' + $('posttime').value + (!fid ? '' : '&fid=' + fid), 'imgattachlist', null, null, null, function(){if(wysiwyg) {editdoc.body.innerHTML = msg;switchEditor(0);switchEditor(1)} else {textobj.value = msg;}});
switchImagebutton('imgattachlist');$('imgattach_notice').style.display = '';
showDialog('远程附件下载完成!', 'right', null, null, 0, null, null, null, null, 3);
}
}
function switchButton(btn, type) {
var btnpre = editorid + '_btn_';
if(!$(btnpre + btn) || !$(editorid + '_' + btn)) {
return;
}
var tabs = $(editorid + '_' + type + '_ctrl').getElementsByTagName('LI');
$(btnpre + btn).style.display = '';
$(editorid + '_' + btn).style.display = '';
$(btnpre + btn).className = 'current';
var btni = '';
for(i = 0;i < tabs.length;i++) {
if(tabs[i].id.indexOf(btnpre) !== -1) {
btni = tabs[i].id.substr(btnpre.length);
}
if(btni != btn) {
if(!$(editorid + '_' + btni) || !$(editorid + '_btn_' + btni)) {
continue;
}
$(editorid + '_' + btni).style.display = 'none';
$(editorid + '_btn_' + btni).className = '';
}
}
}
function uploadWindowstart() {
$('uploadwindowing').style.visibility = 'visible';
}
function uploadWindowload() {
$('uploadwindowing').style.visibility = 'hidden';
var str = $('uploadattachframe').contentWindow.document.body.innerHTML;
if(str == '') return;
var arr = str.split('|');
if(arr[0] == 'DISCUZUPLOAD' && arr[2] == 0) {
UPLOADWINRECALL(arr[3], arr[5], arr[6]);
hideWindow('upload', 0);
} else {
var sizelimit = '';
if(arr[7] == 'ban') {
sizelimit = '(附件类型被禁止)';
} else if(arr[7] == 'perday') {
sizelimit = '(不能超过 ' + arr[8] + ' 字节)';
} else if(arr[7] > 0) {
sizelimit = '(不能超过 ' + arr[7] + ' 字节)';
}
showError(STATUSMSG[arr[2]] + sizelimit);
}
if($('attachlimitnotice')) {
ajaxget('forum.php?mod=ajax&action=updateattachlimit&fid=' + fid, 'attachlimitnotice');
}
}
function uploadWindow(recall, type) {
var type = isUndefined(type) ? 'image' : type;
UPLOADWINRECALL = recall;
showWindow('upload', 'forum.php?mod=misc&action=upload&fid=' + fid + '&type=' + type, 'get', 0, {'zindex':601});
}
function updatetradeattach(aid, url, attachurl) {
$('tradeaid').value = aid;
$('tradeattach_image').innerHTML = '<img src="' + attachurl + '/' + url + '" class="spimg" />';
ATTACHORIMAGE = 1;
}
function updateactivityattach(aid, url, attachurl) {
$('activityaid').value = aid;
$('activityattach_image').innerHTML = '<img src="' + attachurl + '/' + url + '" class="spimg" />';
ATTACHORIMAGE = 1;
}
function updatesortattach(aid, url, attachurl, identifier) {
$('sortaid_' + identifier).value = aid;
$('sortattachurl_' + identifier).value = attachurl + '/' + url;
$('sortattach_image_' + identifier).innerHTML = '<img src="' + attachurl + '/' + url + '" class="spimg" />';
ATTACHORIMAGE = 1;
}
function switchpollm(swt) {
t = $('pollchecked').checked && swt ? 2 : 1;
var v = '';
for(var i = 0; i < $('postform').elements.length; i++) {
var e = $('postform').elements[i];
if(!isUndefined(e.name)) {
if(e.name.match('^polloption')) {
if(t == 2 && e.tagName == 'INPUT') {
v += e.value + '\n';
} else if(t == 1 && e.tagName == 'TEXTAREA') {
v += e.value;
}
}
}
}
if(t == 1) {
var a = v.split('\n');
var pcount = 0;
for(var i = 0; i < $('postform').elements.length; i++) {
var e = $('postform').elements[i];
if(!isUndefined(e.name)) {
if(e.name.match('^polloption')) {
pcount++;
if(e.tagName == 'INPUT') e.value = '';
}
}
}
for(var i = 0; i < a.length - pcount + 2; i++) {
addpolloption();
}
var ii = 0;
for(var i = 0; i < $('postform').elements.length; i++) {
var e = $('postform').elements[i];
if(!isUndefined(e.name)) {
if(e.name.match('^polloption') && e.tagName == 'INPUT' && a[ii]) {
e.value = a[ii++];
}
}
}
} else if(t == 2) {
$('postform').polloptions.value = trim(v);
}
$('postform').tpolloption.value = t;
if(swt) {
display('pollm_c_1');
display('pollm_c_2');
}
}
function addpolloption() {
if(curoptions < maxoptions) {
var imgid = 'newpoll_'+curnumber;
var proid = 'pollUploadProgress_'+curnumber;
var pollstr = $('polloption_hidden').innerHTML.replace('newpoll', imgid);
pollstr = pollstr.replace('pollUploadProgress', proid);
$('polloption_new').outerHTML = '<p>' + pollstr + '</p>' + $('polloption_new').outerHTML;
curoptions++;
curnumber++;
addUploadEvent(imgid, proid)
} else {
$('polloption_new').innerHTML = '已达到最大投票数' + maxoptions;
}
}
function delpolloption(obj) {
obj.parentNode.parentNode.removeChild(obj.parentNode);
curoptions--;
if (curoptions < maxoptions) {
$('polloption_new').innerHTML = '';
}
}
function insertsave(pid) {
var x = new Ajax();
x.get('forum.php?mod=misc&action=loadsave&inajax=yes&pid=' + pid + '&type=' + wysiwyg, function(str, x) {
insertText(str, str.length, 0);
});
}
function userdataoption(op) {
if(!op) {
saveUserdata('forum_'+discuz_uid, '');
display('rstnotice');
} else {
loadData();
checkFocus();
}
doane();
}
function attachoption(type, op) {
if(!op) {
if(type == 'attach') {
delAttach(ATTACHUNUSEDAID, 1);
ATTACHNUM['attachunused'] = 0;
display('attachnotice_attach');
} else {
delImgAttach(IMGUNUSEDAID, 1);
ATTACHNUM['imageunused'] = 0;
display('attachnotice_img');
}
} else if(op == 1) {
var obj = $('unusedwin') ? $('unusedwin') : $('unusedlist_' + type);
list = obj.getElementsByTagName('INPUT'), aids = '';
for(i = 0;i < list.length;i++) {
if(list[i].name.match('unused') && list[i].checked) {
aids += '|' + list[i].value;
}
}
if(aids) {
if(type == 'attach') {
updateAttachList(1, aids);
} else {
list = $('imgattachlist').getElementsByTagName('TD');
re = /^image\_td\_(\d+)$/;
for(i = 0;i < list.length;i++) {
var matches = re.exec(list[i].id);
if(matches != null) {
aids += '|' + matches[1];
}
}
updateImageList(1, aids);
}
}
display('attachnotice_' + type);
} else if(op == 2) {
showDialog('<div id="unusedwin" class="c altw" style="overflow:auto;height:100px;">' + $('unusedlist_' + type).innerHTML + '</div>' +
'<p class="o pns"><span class="z xg1"><label for="unusedwinchkall"><input id="unusedwinchkall" type="checkbox" onclick="attachoption(\'' + type + '\', 3)" checked="checked" />全选</label></span>' +
'<button onclick="attachoption(\'' + type + '\', 1);hideMenu(\'fwin_dialog\', \'dialog\')" class="pn pnc"><strong>使用</strong></button></p>', 'info', '未使用的' + (type == 'attach' ? '附件' : '图片'));
} else if(op == 3) {
list = $('unusedwin').getElementsByTagName('INPUT');
for(i = 0;i < list.length;i++) {
if(list[i].name.match('unused')) {
list[i].checked = $('unusedwinchkall').checked;
}
}
return;
}
doane();
}
function insertAttachTag(aid) {
var txt = '[attach]' + aid + '[/attach]';
seditor_insertunit('fastpost', txt);
}
function insertAttachimgTag(aid) {
var txt = '[attachimg]' + aid + '[/attachimg]';
seditor_insertunit('fastpost', txt);
}
function insertText(str) {
seditor_insertunit('fastpost', str);
}
function insertAllAttachTag() {
var attachListObj = $('e_attachlist').getElementsByTagName("tbody");
for(var i in attachListObj) {
if(typeof attachListObj[i] == "object") {
var attach = attachListObj[i];
var ids = attach.id.split('_');
if(ids[0] == 'attach') {
if($('attachname'+ids[1]) && attach.style.display != 'none') {
if(parseInt($('attachname'+ids[1]).getAttribute('isimage'))) {
insertAttachimgTag(ids[1]);
} else {
insertAttachTag(ids[1]);
}
var txt = wysiwyg ? '\r\n<br/><br/>\r\n' : '\r\n\r\n';
insertText(txt, strlen(txt), 0);
}
}
}
}
doane();
}
function selectAllSaveImg(state) {
var inputListObj = $('imgattachlist').getElementsByTagName("input");
for(i in inputListObj) {
if(typeof inputListObj[i] == "object" && inputListObj[i].id) {
var inputObj = inputListObj[i];
var ids = inputObj.id.split('_');
if(ids[0] == 'albumaidchk' && $('image_td_' + ids[1]).className != 'imgdeleted' && inputObj.checked != state) {
inputObj.click();
}
}
}
}
function showExtra(id) {
if ($(id+'_c').style.display == 'block') {
$(id+'_b').className = 'pn z';
$(id+'_c').style.display = 'none';
} else {
var extraButton = $('post_extra_tb').getElementsByTagName('label');
var extraForm = $('post_extra_c').getElementsByTagName('div');
for (i=0;i<extraButton.length;i++) {
extraButton[i].className = '';
}
for (i=0;i<extraForm.length;i++) {
if(hasClass(extraForm[i],'exfm')) {
extraForm[i].style.display = 'none';
}
}
for (i=0;i<extraForm.length;i++) {
if(hasClass(extraForm[i],'exfm')) {
extraForm[i].style.display = 'none';
}
}
$(id+'_b').className = 'a';
$(id+'_c').style.display = 'block';
}
}
function extraCheck(op) {
if(!op && $('extra_replycredit_chk')) {
$('extra_replycredit_chk').className = $('replycredit_extcredits').value > 0 && $('replycredit_times').value > 0 ? 'a' : '';
} else if(op == 1 && $('readperm')) {
$('extra_readperm_chk').className = $('readperm').value !== '' ? 'a' : '';
} else if(op == 2 && $('price')) {
$('extra_price_chk').className = $('price').value > 0 ? 'a' : '';
} else if(op == 3 && $('rushreply')) {
$('extra_rushreplyset_chk').className = $('rushreply').checked ? 'a' : '';
} else if(op == 4 && $('tags')) {
$('extra_tag_chk').className = $('tags').value !== '' ? 'a' : '';
} else if(op == 5 && $('cronpublish')) {
$('extra_pubdate_chk').className = $('cronpublish').checked ? 'a' : '';
}
}
function hidenFollowBtn(flag) {
var fobj = $('adddynamicspan');
if(fobj) {
if(flag) {
$('adddynamic').checked = !flag;
fobj.style.display = 'none';
} else {
fobj.style.display = '';
}
}
}
function getreplycredit() {
var replycredit_extcredits = $('replycredit_extcredits');
var replycredit_times = $('replycredit_times');
var credit_once = parseInt(replycredit_extcredits.value) > 0 ? parseInt(replycredit_extcredits.value) : 0;
var times = parseInt(replycredit_times.value) > 0 ? parseInt(replycredit_times.value) : 0;
if(parseInt(credit_once * times) - have_replycredit > 0) {
var real_reply_credit = Math.ceil(parseInt(credit_once * times) - have_replycredit + ((parseInt(credit_once * times) - have_replycredit) * creditstax));
} else {
var real_reply_credit = Math.ceil(parseInt(credit_once * times) - have_replycredit);
}
var reply_credits_sum = Math.ceil(parseInt(credit_once * times));
$('replycredit_sum').innerHTML = reply_credits_sum > 0 ? reply_credits_sum : 0 ;
if(real_reply_credit > userextcredit) {
$('replycredit').innerHTML = '<b class="xi1">回帖奖励积分总额过大('+real_reply_credit+')</b>';
} else {
if(have_replycredit > 0 && real_reply_credit < 0) {
$('replycredit').innerHTML = "<font class='xi1'>返还"+Math.abs(real_reply_credit)+"</font>";
} else {
$('replycredit').innerHTML = replycredit_result_lang + (real_reply_credit > 0 ? real_reply_credit : 0 );
}
}
}
function extraCheckall() {
for(i = 0;i < 5;i++) {
extraCheck(i);
}
}
function deleteThread() {
if(confirm('确定要删除该文章吗?') != 0){
$('delete').value = '1';
$('postform').submit();
}
}
function hideAttachMenu(id) {
if($(editorid + '_' + id + '_menu')) {
$(editorid + '_' + id + '_menu').style.visibility = 'hidden';
}
}

145
static/js/forum_slide.js Normal file
View File

@@ -0,0 +1,145 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forum_slide.js 23838 2011-08-11 06:51:58Z monkey $
*/
if(isUndefined(sliderun)) {
var sliderun = 1;
function slide() {
var s = new Object();
s.slideId = Math.random();
s.slideSpeed = slideSpeed;
s.size = slideImgsize;
s.imgs = slideImgs;
s.imgLoad = new Array();
s.imgnum = slideImgs.length;
s.imgLinks = slideImgLinks;
s.imgTexts = slideImgTexts;
s.slideBorderColor = slideBorderColor;
s.slideBgColor = slideBgColor;
s.slideSwitchColor = slideSwitchColor;
s.slideSwitchbgColor = slideSwitchbgColor;
s.slideSwitchHiColor = slideSwitchHiColor;
s.currentImg = 0;
s.prevImg = 0;
s.imgLoaded = 0;
s.st = null;
s.loadImage = function () {
if(!s.imgnum) {
return;
}
s.size[0] = parseInt(s.size[0]);
s.size[1] = parseInt(s.size[1]);
document.write('<div class="slideouter" id="outer_'+s.slideId+'" style="cursor:pointer;position:absolute;width:'+(s.size[0]-2)+'px;height:'+(s.size[1]-2)+'px;border:1px solid '+s.slideBorderColor+'"></div>');
document.write('<table cellspacing="0" cellpadding="0" style="cursor:pointer;width:'+s.size[0]+'px;height:'+s.size[1]+'px;table-layout:fixed;overflow:hidden;background:'+s.slideBgColor+';text-align:center"><tr><td valign="middle" style="padding:0" class="slideimage" id="slide_'+s.slideId+'">');
document.write((typeof IMGDIR == 'undefined' ? '' : '<div class="loadicon"></div>') + '<br /><span id="percent_'+s.slideId+'">0%</span></td></tr></table>');
document.write('<div id="switch_'+s.slideId+'" style="position:absolute;margin-left:1px;margin-top:-18px"></div>');
$('outer_' + s.slideId).onclick = s.imageLink;
for(i = 1;i < s.imgnum;i++) {
switchdiv = document.createElement('div');
switchdiv.id = 'switch_' + i + '_' + s.slideId;
switchdiv.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=70)';
switchdiv.style.opacity = 0.7;
switchdiv.style.styleFloat = 'left';
switchdiv.style.cssFloat = 'left';
switchdiv.style.cursor = 'pointer';
switchdiv.style.width = '17px';
switchdiv.style.height = '17px';
switchdiv.style.overflow = 'hidden';
switchdiv.style.fontWeight = 'bold';
switchdiv.style.textAlign = 'center';
switchdiv.style.fontSize = '9px';
switchdiv.style.color = s.slideSwitchColor;
switchdiv.style.borderRight = '1px solid ' + s.slideBorderColor;
switchdiv.style.borderTop = '1px solid ' + s.slideBorderColor;
switchdiv.style.backgroundColor = s.slideSwitchbgColor;
switchdiv.className = 'slideswitch';
switchdiv.i = i;
switchdiv.onclick = function () {
s.switchImage(this);
};
switchdiv.innerHTML = i;
$('switch_'+s.slideId).appendChild(switchdiv);
s.imgLoad[i] = new Image();
s.imgLoad[i].src = s.imgs[i];
s.imgLoad[i].onerror = function () { s.imgLoaded++; };
}
s.loadCheck();
};
s.imageLink = function () {
window.open(s.imgLinks[s.currentImg]);
};
s.switchImage = function (obj) {
s.showImage(obj.i);
s.interval();
};
s.loadCheck = function () {
for(i = 1;i < s.imgnum;i++) {
if(s.imgLoad[i].complete && !s.imgLoad[i].status) {
s.imgLoaded++;
s.imgLoad[i].status = 1;
if(s.imgLoad[i].width > s.size[0] || s.imgLoad[i].height > s.size[1]) {
zr = s.imgLoad[i].width / s.imgLoad[i].height;
if(zr > 1) {
s.imgLoad[i].height = s.size[1];
s.imgLoad[i].width = s.size[1] * zr;
} else {
s.imgLoad[i].width = s.size[0];
s.imgLoad[i].height = s.size[0] / zr;
if(s.imgLoad[i].height > s.size[1]) {
s.imgLoad[i].height = s.size[1];
s.imgLoad[i].width = s.size[1] * zr;
}
}
}
}
}
if(s.imgLoaded < s.imgnum - 1) {
$('percent_' + s.slideId).innerHTML = (parseInt(s.imgLoad.length / s.imgnum * 100)) + '%';
setTimeout(function () { s.loadCheck(); }, 100);
} else {
for(i = 1;i < s.imgnum;i++) {
s.imgLoad[i].onclick = s.imageLink;
s.imgLoad[i].title = s.imgTexts[i];
}
s.showImage();
s.interval();
}
};
s.interval = function () {
clearInterval(s.st);
s.st = setInterval(function () { s.showImage(); }, s.slideSpeed);
};
s.showImage = function (i) {
if(!i) {
s.currentImg++;
s.currentImg = s.currentImg < s.imgnum ? s.currentImg : 1;
} else {
s.currentImg = i;
}
if(s.prevImg) {
$('switch_' + s.prevImg + '_' + s.slideId).style.backgroundColor = s.slideSwitchbgColor;
}
$('switch_' + s.currentImg + '_' + s.slideId).style.backgroundColor = s.slideSwitchHiColor;
$('slide_' + s.slideId).innerHTML = '';
$('slide_' + s.slideId).appendChild(s.imgLoad[s.currentImg]);
s.prevImg = s.currentImg;
};
s.loadImage();
}
}
slide();

View File

@@ -0,0 +1,773 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forum_viewthread.js 35221 2015-02-27 08:24:39Z nemohou $
*/
var replyreload = '', attachimgST = new Array(), zoomgroup = new Array(), zoomgroupinit = new Array();
function attachimggroup(pid) {
if(!zoomgroupinit[pid]) {
for(i = 0;i < aimgcount[pid].length;i++) {
zoomgroup['aimg_' + aimgcount[pid][i]] = pid;
}
zoomgroupinit[pid] = true;
}
}
function attachimgshow(pid, onlyinpost) {
onlyinpost = !onlyinpost ? false : onlyinpost;
aimgs = aimgcount[pid];
aimgcomplete = 0;
loadingcount = 0;
for(i = 0;i < aimgs.length;i++) {
obj = $('aimg_' + aimgs[i]);
if(!obj) {
aimgcomplete++;
continue;
}
if(onlyinpost && !obj.getAttribute('inpost')) {
aimgcomplete++;
continue;
}
if(onlyinpost && obj.getAttribute('inpost') || !onlyinpost) {
if(!obj.status) {
obj.status = 1;
if(obj.getAttribute('file')) obj.src = obj.getAttribute('file');
loadingcount++;
} else if(obj.status == 1) {
if(obj.complete) {
obj.status = 2;
} else {
loadingcount++;
}
} else if(obj.status == 2) {
aimgcomplete++;
if(obj.getAttribute('thumbImg')) {
thumbImg(obj);
}
}
if(loadingcount >= 10) {
break;
}
}
}
if(aimgcomplete < aimgs.length) {
setTimeout(function () {
attachimgshow(pid, onlyinpost);
}, 100);
}
}
function attachimglstshow(pid, islazy, fid, showexif) {
var aimgs = aimgcount[pid];
var s = '';
if(fid) {
s = ' onmouseover="showMenu({\'ctrlid\':this.id, \'pos\': \'12!\'});"';
}
if(typeof aimgcount == 'object' && $('imagelistthumb_' + pid)) {
for(pid in aimgcount) {
var imagelist = '';
for(i = 0;i < aimgcount[pid].length;i++) {
if(!$('aimg_' + aimgcount[pid][i]) || $('aimg_' + aimgcount[pid][i]).getAttribute('inpost') || parseInt(aimgcount[pid][i]) != aimgcount[pid][i]) {
continue;
}
if(fid) {
imagelist += '<div id="pattimg_' + aimgcount[pid][i] + '_menu" class="tip tip_4" style="display: none;"><div class="tip_horn"></div><div class="tip_c"><a href="forum.php?mod=ajax&action=setthreadcover&aid=' + aimgcount[pid][i] + '&fid=' + fid + '" class="xi2" onclick="showWindow(\'setcover' + aimgcount[pid][i] + '\', this.href)">设为封面</a></div></div>';
}
imagelist += '<div class="pattimg">' +
'<a id="pattimg_' + aimgcount[pid][i] + '" class="pattimg_zoom" href="javascript:;"' + s + ' onclick="zoom($(\'aimg_' + aimgcount[pid][i] + '\'), attachimggetsrc(\'aimg_' + aimgcount[pid][i] + '\'), 0, 0, ' + (parseInt(showexif) ? 1 : 0) + ')" title="点击放大">点击放大</a>' +
'<img ' + (islazy ? 'file' : 'src') + '="forum.php?mod=image&aid=' + aimgcount[pid][i] + '&size=100x100&key=' + imagelistkey + '&atid=' + tid + '" width="100" height="100" /></div>';
}
if($('imagelistthumb_' + pid)) {
$('imagelistthumb_' + pid).innerHTML = imagelist;
}
}
}
}
function attachimggetsrc(img) {
return $(img).getAttribute('zoomfile') ? $(img).getAttribute('zoomfile') : $(img).getAttribute('file');
}
function attachimglst(pid, op, islazy) {
if(!op) {
$('imagelist_' + pid).style.display = 'none';
$('imagelistthumb_' + pid).style.display = '';
} else {
$('imagelistthumb_' + pid).style.display = 'none';
$('imagelist_' + pid).style.display = '';
if(islazy) {
o = new lazyload();
o.showImage();
} else {
attachimgshow(pid);
}
}
doane();
}
function attachimginfo(obj, infoobj, show, event) {
objinfo = fetchOffset(obj);
if(show) {
$(infoobj).style.left = objinfo['left'] + 'px';
$(infoobj).style.top = obj.offsetHeight < 40 ? (objinfo['top'] + obj.offsetHeight) + 'px' : objinfo['top'] + 'px';
$(infoobj).style.display = '';
} else {
if(BROWSER.ie) {
$(infoobj).style.display = 'none';
return;
} else {
var mousex = document.body.scrollLeft + event.clientX;
var mousey = document.documentElement.scrollTop + event.clientY;
if(mousex < objinfo['left'] || mousex > objinfo['left'] + objinfo['width'] || mousey < objinfo['top'] || mousey > objinfo['top'] + objinfo['height']) {
$(infoobj).style.display = 'none';
}
}
}
}
function signature(obj) {
if(obj.style.maxHeightIE != '') {
var height = (obj.scrollHeight > parseInt(obj.style.maxHeightIE)) ? obj.style.maxHeightIE : obj.scrollHeight + 'px';
if(obj.innerHTML.indexOf('<IMG ') == -1) {
obj.style.maxHeightIE = '';
}
return height;
}
}
function tagshow(event) {
var obj = BROWSER.ie ? event.srcElement : event.target;
ajaxmenu(obj, 0, 1, 2);
}
function parsetag(pid) {
if(!$('postmessage_'+pid) || $('postmessage_'+pid).innerHTML.match(/<script[^\>]*?>/i)) {
return;
}
var havetag = false;
var tagfindarray = new Array();
var str = $('postmessage_'+pid).innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3, $4) {
for(i in tagarray) {
if(tagarray[i] && $3.indexOf(tagarray[i]) != -1) {
havetag = true;
$3 = $3.replace(tagarray[i], '<h_ ' + i + '>');
tmp = $3.replace(/&[a-z]*?<h_ \d+>[a-z]*?;/ig, '');
if(tmp != $3) {
$3 = tmp;
} else {
tagfindarray[i] = tagarray[i];
tagarray[i] = '';
}
}
}
return $2 + $3;
});
if(havetag) {
$('postmessage_'+pid).innerHTML = str.replace(/<h_ (\d+)>/ig, function($1, $2) {
return '<span href=\"forum.php?mod=tag&name=' + tagencarray[$2] + '\" onclick=\"tagshow(event)\" class=\"t_tag\">' + tagfindarray[$2] + '</span>';
});
}
}
function setanswer(pid, from){
if(confirm('您确认要把该回复选为“最佳答案”吗?')){
if(BROWSER.ie) {
doane(event);
}
$('modactions').action='forum.php?mod=misc&action=bestanswer&tid=' + tid + '&pid=' + pid + '&from=' + from + '&bestanswersubmit=yes';
$('modactions').submit();
}
}
var authort;
function showauthor(ctrlObj, menuid) {
authort = setTimeout(function () {
showMenu({'menuid':menuid});
if($(menuid + '_ma').innerHTML == '') $(menuid + '_ma').innerHTML = ctrlObj.innerHTML;
}, 500);
if(!ctrlObj.onmouseout) {
ctrlObj.onmouseout = function() {
clearTimeout(authort);
}
}
}
function fastpostappendreply() {
if($('fastpostrefresh') != null) {
setcookie('fastpostrefresh', $('fastpostrefresh').checked ? 1 : 0, 2592000);
if($('fastpostrefresh').checked) {
location.href = 'forum.php?mod=redirect&tid='+tid+'&goto=lastpost&random=' + Math.random() + '#lastpost';
return;
}
}
newpos = fetchOffset($('post_new'));
document.documentElement.scrollTop = newpos['top'];
$('post_new').style.display = '';
$('post_new').id = '';
div = document.createElement('div');
div.id = 'post_new';
div.style.display = 'none';
div.className = '';
$('postlistreply').appendChild(div);
$('fastpostsubmit').disabled = false;
if($('fastpostmessage')) {
$('fastpostmessage').value = '';
} else {
editdoc.body.innerHTML = BROWSER.firefox ? '<br />' : '';
}
if($('fastpostform').seccodehash){
updateseccode($('fastpostform').seccodehash.value);
$('fastpostform').seccodeverify.value = '';
}
if($('fastpostform').secqaahash){
updatesecqaa($('fastpostform').secqaahash.value);
$('fastpostform').secanswer.value = '';
}
showCreditPrompt();
}
function succeedhandle_fastpost(locationhref, message, param) {
var pid = param['pid'];
var tid = param['tid'];
var from = param['from'];
var reply_mod = param['reply_mod'];
if(!reply_mod) {
ajaxget('forum.php?mod=viewthread&tid=' + tid + '&viewpid=' + pid + '&from=' + from, 'post_new', 'ajaxwaitid', '', null, 'fastpostappendreply()');
if(replyreload) {
var reloadpids = replyreload.split(',');
for(var i = 1;i < reloadpids.length;i++) {
ajaxget('forum.php?mod=viewthread&tid=' + tid + '&viewpid=' + reloadpids[i] + '&from=' + from, 'post_' + reloadpids[i], 'ajaxwaitid');
}
}
$('fastpostreturn').className = '';
} else {
if(!message) {
message = '本版回帖需要审核,您的文章将在通过审核后显示';
}
$('post_new').style.display = $('fastpostmessage').value = $('fastpostreturn').className = '';
$('fastpostreturn').innerHTML = message;
}
if(param['sechash']) {
updatesecqaa(param['sechash']);
updateseccode(param['sechash']);
}
if($('attach_tblheader')) {
$('attach_tblheader').style.display = 'none';
}
if($('attachlist')) {
$('attachlist').innerHTML = '';
}
}
function errorhandle_fastpost() {
$('fastpostsubmit').disabled = false;
}
function succeedhandle_comment(locationhref, message, param) {
ajaxget('forum.php?mod=misc&action=commentmore&tid=' + param['tid'] + '&pid=' + param['pid'], 'comment_' + param['pid']);
hideWindow('comment');
showCreditPrompt();
}
function succeedhandle_postappend(locationhref, message, param) {
ajaxget('forum.php?mod=viewthread&tid=' + param['tid'] + '&viewpid=' + param['pid'], 'post_' + param['pid'], 'ajaxwaitid');
hideWindow('postappend');
}
function recommendupdate(n) {
if(getcookie('recommend')) {
var objv = n > 0 ? $('recommendv_add') : $('recommendv_subtract');
objv.style.display = '';
objv.innerHTML = parseInt(objv.innerHTML) + 1;
setTimeout(function () {
$('recommentc').innerHTML = parseInt($('recommentc').innerHTML) + n;
$('recommentv').style.display = 'none';
}, 1000);
setcookie('recommend', '');
}
}
function postreviewupdate(pid, n) {
var objv = n > 0 ? $('review_support_'+pid) : $('review_against_'+pid);
objv.innerHTML = parseInt(objv.innerHTML ? objv.innerHTML : 0) + 1;
}
function favoriteupdate() {
var obj = $('favoritenumber');
obj.style.display = '';
obj.innerHTML = parseInt(obj.innerHTML) + 1;
}
function switchrecommendv() {
display('recommendv');
display('recommendav');
}
function appendreply() {
newpos = fetchOffset($('post_new'));
document.documentElement.scrollTop = newpos['top'];
$('post_new').style.display = '';
$('post_new').id = '';
div = document.createElement('div');
div.id = 'post_new';
div.style.display = 'none';
div.className = '';
$('postlistreply').appendChild(div);
if($('postform')) {
$('postform').replysubmit.disabled = false;
}
showCreditPrompt();
}
function poll_checkbox(obj) {
if(obj.checked) {
p++;
for (var i = 0; i < $('poll').elements.length; i++) {
var e = $('poll').elements[i];
if(p == max_obj) {
if(e.name.match('pollanswers') && !e.checked) {
e.disabled = true;
}
}
}
} else {
p--;
for (var i = 0; i < $('poll').elements.length; i++) {
var e = $('poll').elements[i];
if(e.name.match('pollanswers') && e.disabled) {
e.disabled = false;
}
}
}
$('pollsubmit').disabled = p <= max_obj && p > 0 ? false : true;
}
function itemdisable(i) {
if($('itemt_' + i).className == 'z') {
$('itemt_' + i).className = 'z xg1';
$('itemc_' + i).value = '';
itemset(i);
} else {
$('itemt_' + i).className = 'z';
$('itemc_' + i).value = $('itemc_' + i).value > 0 ? $('itemc_' + i).value : 0;
}
}
function itemop(i, v) {
$('item_' + i).className = 'z cmstar cmstv_' + v;
}
function itemclk(i, v) {
$('itemc_' + i).value = v;
$('itemt_' + i).className = 'z';
}
function itemset(i) {
var v = $('itemc_' + i).value;
v = v ? v : 0;
$('item_' + i).className = 'z cmstar cmstv_' + v;
}
function checkmgcmn(id) {
if($('mgc_' + id) && !$('mgc_' + id + '_menu').getElementsByTagName('li').length) {
$('mgc_' + id).innerHTML = '';
$('mgc_' + id).style.display = 'none';
}
}
function toggleRatelogCollapse(tarId, ctrlObj) {
if($(tarId).className == 'rate') {
$(tarId).className = 'rate rate_collapse';
setcookie('ratecollapse', 1, 2592000);
ctrlObj.innerHTML = '展开';
} else {
$(tarId).className = 'rate';
setcookie('ratecollapse', 0, -2592000);
ctrlObj.innerHTML = '收起';
}
}
function copyThreadUrl(obj, bbname) {
bbname = bbname || SITEURL;
setCopy($('thread_subject').innerHTML.replace(/&amp;/g, '&') + '\n' + obj.href + '\n' + '(出处: '+bbname+')' + '\n', '文章地址已经复制到剪贴板');
return false;
}
function replyNotice() {
var newurl = 'forum.php?mod=misc&action=replynotice&tid=' + tid + '&op=';
var replynotice = $('replynotice');
var status = replynotice.getAttribute("status");
if(status == 1) {
replynotice.href = newurl + 'receive';
replynotice.innerHTML = '接收回复通知';
replynotice.setAttribute("status", 0);
} else {
replynotice.href = newurl + 'ignore';
replynotice.innerHTML = '取消回复通知';
replynotice.setAttribute("status", 1);
}
}
function lazyload(className) {
var obj = this;
lazyload.className = className;
this.getOffset = function (el, isLeft) {
var retValue = 0 ;
while (el != null ) {
retValue += el["offset" + (isLeft ? "Left" : "Top" )];
el = el.offsetParent;
}
return retValue;
};
this.initImages = function (ele) {
lazyload.imgs = [];
var eles = lazyload.className ? $C(lazyload.className, ele) : [document.body];
for (var i = 0; i < eles.length; i++) {
var imgs = eles[i].getElementsByTagName('IMG');
for(var j = 0; j < imgs.length; j++) {
if(imgs[j].getAttribute('file') && !imgs[j].getAttribute('lazyloaded')) {
if(this.getOffset(imgs[j]) > document.documentElement.clientHeight) {
lazyload.imgs.push(imgs[j]);
} else {
imgs[j].onload = function(){thumbImg(this);};
imgs[j].setAttribute('src', imgs[j].getAttribute('file'));
imgs[j].setAttribute('lazyloaded', 'true');
}
}
}
}
};
this.showImage = function() {
this.initImages();
if(!lazyload.imgs.length) return false;
var imgs = [];
var scrollTop = Math.max(document.documentElement.scrollTop , document.body.scrollTop);
for (var i=0; i<lazyload.imgs.length; i++) {
var img = lazyload.imgs[i];
var offsetTop = this.getOffset(img);
if (!img.getAttribute('lazyloaded') && offsetTop > document.documentElement.clientHeight && (offsetTop - scrollTop < document.documentElement.clientHeight)) {
var dom = document.createElement('div');
var width = img.getAttribute('width') ? img.getAttribute('width') : 100;
var height = img.getAttribute('height') ? img.getAttribute('height') : 100;
dom.innerHTML = '<div style="width: '+width+'px; height: '+height+'px;background: url('+IMGDIR + '/loading.gif) no-repeat center center;"></div>';
img.parentNode.insertBefore(dom.childNodes[0], img);
img.onload = function () {
if(!this.getAttribute('_load')) {
this.setAttribute('_load', 1);
this.style.width = this.style.height = '';
this.parentNode.removeChild(this.previousSibling);
if(this.getAttribute('lazyloadthumb')) {
thumbImg(this);
}
}
};
img.style.width = img.style.height = '1px';
img.setAttribute('src', img.getAttribute('file') ? img.getAttribute('file') : img.getAttribute('src'));
img.setAttribute('lazyloaded', true);
} else {
imgs.push(img);
}
}
lazyload.imgs = imgs;
return true;
};
this.showImage();
_attachEvent(window, 'scroll', function(){obj.showImage();});
}
function update_collection(){
var obj = $('collectionnumber');
sum = 1;
obj.style.display = '';
obj.innerText = parseInt(obj.innerText)+sum;
}
function display_blocked_post() {
var movehiddendiv = (!$('hiddenposts').innerHTML) ? true : false;
for (var i = 0; i < blockedPIDs.length; i++) {
if(movehiddendiv) {
$('hiddenposts').appendChild($("post_"+blockedPIDs[i]));
}
display("post_"+blockedPIDs[i]);
}
var postlistreply = $('postlistreply').innerHTML;
$('hiddenpoststip').parentNode.removeChild($('postlistreply'));
$('hiddenpoststip').parentNode.removeChild($('hiddenpoststip'));
$('hiddenposts').innerHTML+='<div id="postlistreply" class="pl">'+postlistreply+'</div>';
}
function show_threadpage(pid, current, maxpage, ispreview) {
if(!$('threadpage') || typeof tid == 'undefined') {
return;
};
var clickvalue = function (page) {
return 'ajaxget(\'forum.php?mod=viewthread&tid=' + tid + '&viewpid=' + pid + '&cp=' + page + (ispreview ? '&from=preview' : '') + '\', \'post_' + pid + '\', \'ajaxwaitid\');';
};
var pstart = current - 1;
pstart = pstart < 1 ? 1 : pstart;
var pend = current + 1;
pend = pend > maxpage ? maxpage : pend;
var s = '<div class="cm pgs mtm mbm cl"><div class="pg">';
if(pstart > 1) {
s += '<a href="javascript:;" onclick="' + clickvalue(1) + '">1 ...</a>';
}
for(i = pstart;i <= pend;i++) {
s += i == current ? '<strong>' + i + '</strong>' : '<a href="javascript:;" onclick="' + clickvalue(i)+ '">' + i + '</a>';
}
if(pend < maxpage) {
s += '<a href="javascript:;" onclick="' + clickvalue(maxpage)+ '">... ' + maxpage + '</a>';
}
if(current < maxpage) {
s += '<a href="javascript:;" onclick="' + clickvalue(current + 1) + '" class="nxt">下一页</a>';
}
s += '<a href="javascript:;" onclick="' + clickvalue('all') + '">查看所有</a>';
s += '</div></div>';
$('threadpage').innerHTML = s;
}
var show_threadindex_data = '';
function show_threadindex(pid, ispreview) {
if(!show_threadindex_data) {
var s = '<div class="tindex"><h3>目录</h3><ul>';
for(i in $('threadindex').childNodes) {
o = $('threadindex').childNodes[i];
if(o.tagName == 'A') {
var sub = o.getAttribute('sub').length * 2;
o.href = "javascript:;";
if(o.getAttribute('page')) {
s += '<li style="margin-left:' + sub + 'em" onclick="ajaxget(\'forum.php?mod=viewthread&threadindex=yes&tid=' + tid + '&viewpid=' + pid + '&cp=' + o.getAttribute('page') + (ispreview ? '&from=preview' : '') + '\', \'post_' + pid + '\', \'ajaxwaitid\')">' + o.innerHTML + '</li>';
} else if(o.getAttribute('tid') && o.getAttribute('pid')) {
s += '<li style="margin-left:' + sub + 'em" onclick="ajaxget(\'forum.php?mod=viewthread&threadindex=yes&tid=' + o.getAttribute('tid') + '&viewpid=' + o.getAttribute('pid') + (ispreview ? '&from=preview' : '') + '\', \'post_' + pid + '\', \'ajaxwaitid\')">' + o.innerHTML + '</li>';
}
}
}
s += '</ul></div>';
$('threadindex').innerHTML = s;
show_threadindex_data = s;
} else {
$('threadindex').innerHTML = show_threadindex_data;
}
}
function ctrlLeftInfo(sli_staticnum) {
var sli = $('scrollleftinfo');
var postlist_bottom = parseInt($('postlist').getBoundingClientRect().bottom);
var sli_bottom = parseInt(sli.getBoundingClientRect().bottom);
if(postlist_bottom < sli_staticnum && postlist_bottom != sli_bottom) {
sli.style.top = (postlist_bottom - sli.offsetHeight - 5)+'px';
} else{
sli.style.top = 'auto';
}
}
function fixed_avatar(pids, fixednv) {
var fixedtopnv = fixednv ? new fixed_top_nv('nv', true) : false;
if(fixednv) {
fixedtopnv.init();
}
function fixedavatar(e) {
var avatartop = fixednv ? fixedtopnv.run() : 0;
for(var i = 0; i < pids.length; i++) {
var pid = pids[i];
var posttable = $('pid'+pid);
var postavatar = $('favatar'+pid);
if(!$('favatar'+pid)) {
return;
}
var nextpost = $('_postposition'+pid);
if(!postavatar || !nextpost || posttable.offsetHeight - 100 < postavatar.offsetHeight) {
if(postavatar.style.position == 'fixed') {
postavatar.style.position = '';
}
continue;
}
var avatarstyle = postavatar.style;
posttabletop = parseInt(posttable.getBoundingClientRect().top);
nextposttop = parseInt(nextpost.getBoundingClientRect().top);
if(nextposttop > avatartop && nextposttop <= postavatar.offsetHeight + avatartop) {
if(avatarstyle.position != 'absolute') {
postavatar.parentNode.style.position = 'relative';
avatarstyle.top = '';
avatarstyle.bottom = '0px';
avatarstyle.position = 'absolute';
}
} else if(posttabletop < avatartop && nextposttop > avatartop) {
if(postavatar.parentNode.style.position != '') {
postavatar.parentNode.style.position = '';
}
if(avatarstyle.position != 'fixed' || parseInt(avatarstyle.top) != avatartop) {
avatarstyle.bottom = '';
avatarstyle.top = avatartop + 'px';
avatarstyle.position = 'fixed';
}
} else if(avatarstyle.position != '') {
avatarstyle.position = '';
}
}
}
if(!(BROWSER.ie && BROWSER.ie < 7)) {
_attachEvent(window, 'load', function(){_attachEvent(window, 'scroll', fixedavatar);});
}
}
function submitpostpw(pid, tid) {
var obj = $('postpw_' + pid);
appendscript(JSPATH + 'md5.js?' + VERHASH);
safescript('md5_js', function () {
setcookie('postpw_' + pid, hex_md5(obj.value));
if(!tid) {
location.href = location.href;
} else {
location.href = 'forum.php?mod=viewthread&tid='+tid;
}
}, 100, 50);
}
function threadbegindisplay(type, w, h, s) {
$('begincloseid').onclick = function() {
$('threadbeginid').style.display = 'none';
};
var imgobj = $('threadbeginid');
imgobj.style.left = (document.body.clientWidth - w)/2 + 'px';
imgobj.style.top = (document.body.clientHeight - h)/2 + 'px';
if(type == 1) {
autozoom(w, h, s);
} else if(type == 2) {
autofade(w, h, s);
} else {
setTimeout(function() {
$('threadbeginid').style.display = 'none';
}, s);
}
}
function autofade(w, h, s) {
this.imgobj = $('threadbeginid');
this.opacity = 0;
this.fadein = function() {
if(BROWSER.ie) {
this.imgobj.filters.alpha.opacity = this.opacity;
} else {
this.imgobj.style.opacity = this.opacity/100;
}
if(this.opacity >= 100) {
setTimeout(this.fadeout, s);
return;
}
this.opacity++;
setTimeout(this.fadein, 50);
};
this.fadeout = function() {
if(BROWSER.ie) {
this.imgobj.filters.alpha.opacity = this.opacity;
} else {
this.imgobj.style.opacity = this.opacity/100;
}
if(this.opacity <= 0) {
this.imgobj.style.display = 'none';
return;
}
this.opacity--;
setTimeout(this.fadeout, 50);
};
this.fadein();
}
function autozoom(w, h, s) {
this.height = 0;
this.imgobj = $('threadbeginid');
this.imgobj.style.overflow = 'hidden';
this.imgobj.style.display = '';
this.autozoomin = function() {
this.height += 5;
if(this.height >= h) {
this.imgobj.style.height = h + 'px';
setTimeout(this.autozoomout, s);
return;
}
this.imgobj.style.height = this.height + 'px';
setTimeout(this.autozoomin, 50);
};
this.autozoomout = function() {
this.height -= 5;
if(this.height <= 0) {
this.imgobj.style.height = 0 + 'px';
this.imgobj.style.display = 'none';
return;
}
this.imgobj.style.height = this.height + 'px';
setTimeout(this.autozoomout, 50);
};
this.autozoomin();
}
function readmode(title, pid) {
var imagelist = '';
if(aimgcount[pid]) {
for(var i = 0; i < aimgcount[pid].length;i++) {
var aimgObj = $('aimg_'+aimgcount[pid][i]);
if(aimgObj.parentElement.className!="mbn") {
var src = aimgObj.getAttribute('file');
imagelist += '<div class="mbn"><img src="' + src + '" width="600" /></div>';
}
}
}
msg = $('postmessage_'+pid).innerHTML+imagelist;
msg = '<div style="width:800px;max-height:500px; overflow-y:auto; padding: 10px;" class="pcb">'+msg+'</div>';
showDialog(msg, 'info', title, null, 1);
var coverObj = $('fwin_dialog_cover');
coverObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=90)';
coverObj.style.opacity = 0.9;
}
function changecontentdivid(tid) {
if($('postlistreply')) {
objtid = $('postlistreply').getAttribute('tid');
if(objtid == tid) {
return;
}
$('postlistreply').id = 'postlistreply_'+objtid;
postnewdiv = $('postlistreply_'+objtid).childNodes;
postnewdiv[postnewdiv.length-1].id = 'post_new_'+objtid;
}
$('postlistreply_'+tid).id = 'postlistreply';
postnewdiv = $('postlistreply').childNodes;
postnewdiv[postnewdiv.length-1].id = 'post_new';
}
function showmobilebbs(obj) {
var content = '<h3 class="flb" style="cursor:move;"><em>下载掌上论坛</em><span><a href="javascript:;" class="flbc" onclick="hideWindow(\'mobilebbs\')" title="{lang close}">{lang close}</a></span></h3><div class="c"><h4>Andriod版本扫描二维码可以直接下载到手机</h4><p class="mtm mbm vm"><span class="code_bg"><img src="'+ STATICURL +'image/common/zslt_andriod.png" alt="" /></span><img src="'+ STATICURL +'image/common/andriod.png" alt="适用于装有安卓系统的三星/HTC/小米等手机" /></p><h4>iPhone版本扫描二维码可以直接下载到手机</h4><p class="mtm mbm vm"><span class="code_bg"><img src="'+ STATICURL +'image/common/zslt_ios.png" alt="" /></span><img src="'+ STATICURL +'image/common/ios.png" alt="适用于苹果手机" /></p></div>';
showWindow('mobilebbs', content, 'html');
}
function succeedhandle_vfastpost(url, message, param) {
$('vmessage').value = '';
succeedhandle_fastpost(url, message, param);
showCreditPrompt();
}
function vmessage() {
var vf_tips = '#在这里快速回复#';
$('vmessage').value = vf_tips;
$('vmessage').style.color = '#CDCDCD';
$('vmessage').onclick = function() {
if($('vmessage').value==vf_tips) {
$('vmessage').value='';
$('vmessage').style.color="#000";
}
};
$('vmessage').onblur = function() {
if(!$('vmessage').value) {
$('vmessage').value=vf_tips;
$('vmessage').style.color="#CDCDCD";
}
};
$('vreplysubmit').onclick = function() {
if($('vmessage').value == vf_tips) {
return false;
}
};
$('vmessage').onfocus = function() {
ajaxget('forum.php?mod=ajax&action=checkpostrule&ac=reply', 'vfastpostseccheck');
$('vmessage').onfocus = null;
};
}

34
static/js/google.js Normal file
View File

@@ -0,0 +1,34 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: google.js 23838 2011-08-11 06:51:58Z monkey $
*/
document.writeln('<script type="text/javascript">');
document.writeln('function validate_google(theform) {');
document.writeln(' if(theform.site.value == 1) {');
document.writeln(' theform.q.value = \'site:' + google_host + ' \' + theform.q.value;');
document.writeln(' }');
document.writeln('}');
document.writeln('function submitFormWithChannel(channelname) {');
document.writeln(' document.gform.channel.value=channelname;');
document.writeln(' document.gform.submit();');
document.writeln(' return;');
document.writeln('}');
document.writeln('</script>');
document.writeln('<form name="gform" id="gform" method="get" autocomplete="off" action="https://www.google.com/search?" target="_blank" onSubmit="validate_google(this);">');
document.writeln('<input type="hidden" name="client" value="' + (!google_client ? 'aff-discuz' : google_client) + '" />');
document.writeln('<input type="hidden" name="ie" value="' + google_charset + '" />');
document.writeln('<input type="hidden" name="oe" value="UTF-8" />');
document.writeln('<input type="hidden" name="hl" value="' + google_hl + '" />');
document.writeln('<input type="hidden" name="lr" value="' + google_lr + '" />');
document.writeln('<input type="hidden" name="channel" value="search" />');
document.write('<div onclick="javascript:submitFormWithChannel(\'logo\')" style="cursor:pointer;float: left;width:70px;height:23px;background: url(' + STATICURL + 'image/common/Google_small.png) !important;background: none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + STATICURL+ 'image/common/Google_small.png\', sizingMethod=\'scale\')"><img src="' + STATICURL + 'image/common/none.gif" border="0" alt="Google" /></div>');
document.writeln('&nbsp;&nbsp;<input type="text" class="txt" size="20" name="q" id="q" maxlength="255" value=""></input>');
document.writeln('<select name="site">');
document.writeln('<option value="0"' + google_default_0 + '>网页搜索</option>');
document.writeln('<option value="1"' + google_default_1 + '>站内搜索</option>');
document.writeln('</select>');
document.writeln('&nbsp;<button type="submit" name="sa" value="true">搜索</button>');
document.writeln('</form>');

470
static/js/handlers.js Normal file
View File

@@ -0,0 +1,470 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: handlers.js 31952 2012-10-25 09:20:40Z zhengqingpeng $
*/
var sdCloseTime = 2;
function preLoad() {
if(!this.support.loading) {
disableMultiUpload(this.customSettings);
return false;
}
}
function loadFailed() {
disableMultiUpload(this.customSettings);
}
function disableMultiUpload(obj) {
if(obj.uploadSource == 'forum' && obj.uploadFrom != 'fastpost') {
try{
obj.singleUpload.style.display = '';
var dIdStr = obj.singleUpload.getAttribute("did");
if(dIdStr != null) {
if(typeof forum_post_inited == 'undefined') {
appendscript(JSPATH + 'forum_post.js?' + VERHASH);
}
var idArr = dIdStr.split("|");
$(idArr[0]).style.display = 'none';
if(idArr[1] == 'local') {
switchImagebutton('local');
} else if(idArr[1] == 'upload') {
switchAttachbutton('upload');
}
}
} catch (e) {
}
}
}
function fileDialogStart() {
if(this.customSettings.uploadSource == 'forum') {
this.customSettings.alertType = 0;
if(this.customSettings.uploadFrom == 'fastpost') {
if(typeof forum_post_inited == 'undefined') {
appendscript(JSPATH + 'forum_post.js?' + VERHASH);
}
}
}
}
function fileQueued(file) {
try {
var createQueue = true;
if(this.customSettings.uploadSource == 'forum' && this.customSettings.uploadType == 'poll') {
var inputObj = $(this.customSettings.progressTarget+'_aid');
if(inputObj && parseInt(inputObj.value)) {
this.addPostParam('aid', inputObj.value);
}
} else if(this.customSettings.uploadSource == 'portal') {
var inputObj = $('catid');
if(inputObj && parseInt(inputObj.value)) {
this.addPostParam('catid', inputObj.value);
}
}
var progress = new FileProgress(file, this.customSettings.progressTarget);
if(this.customSettings.uploadSource == 'forum') {
if(this.customSettings.maxAttachNum != undefined) {
if(this.customSettings.maxAttachNum > 0) {
this.customSettings.maxAttachNum--;
} else {
this.customSettings.alertType = 6;
createQueue = false;
}
}
if(createQueue && this.customSettings.maxSizePerDay != undefined) {
if(this.customSettings.maxSizePerDay - file.size > 0) {
this.customSettings.maxSizePerDay = this.customSettings.maxSizePerDay - file.size
} else {
this.customSettings.alertType = 11;
createQueue = false;
}
}
if(createQueue && this.customSettings.filterType != undefined) {
var fileSize = this.customSettings.filterType[file.type.substr(1).toLowerCase()];
if(fileSize != undefined && fileSize && file.size > fileSize) {
this.customSettings.alertType = 5;
createQueue = false;
}
}
}
if(createQueue) {
progress.setStatus("等待上传...");
} else {
this.cancelUpload(file.id);
progress.setCancelled();
}
progress.toggleCancel(true, this);
} catch (ex) {
this.debug(ex);
}
}
function fileQueueError(file, errorCode, message) {
try {
if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
message = parseInt(message);
showDialog("您选择的文件个数超过限制。\n"+(message === 0 ? "您已达到上传文件的上限了。" : "您还可以选择 " + message + " 个文件"), 'notice', null, null, 0, null, null, null, null, sdCloseTime);
return;
}
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setError();
progress.toggleCancel(false);
switch (errorCode) {
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
progress.setStatus("文件太大.");
this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
progress.setStatus("不能上传零字节文件.");
this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
progress.setStatus("禁止上传该类型的文件.");
this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
alert("You have selected too many files. " + (message > 1 ? "You may only add " + message + " more files" : "You cannot add any more files."));
break;
default:
if (file !== null) {
progress.setStatus("Unhandled Error");
}
this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
}
} catch (ex) {
this.debug(ex);
}
}
function fileDialogComplete(numFilesSelected, numFilesQueued) {
try {
if(this.customSettings.uploadSource == 'forum') {
if(this.customSettings.uploadType == 'attach') {
if(typeof switchAttachbutton == "function") {
switchAttachbutton('attachlist');
}
try {
if(this.getStats().files_queued) {
$('attach_tblheader').style.display = '';
$('attach_notice').style.display = '';
}
} catch (ex) {}
} else if(this.customSettings.uploadType == 'image') {
if(typeof switchImagebutton == "function") {
switchImagebutton('imgattachlist');
}
try {
$('imgattach_notice').style.display = '';
} catch (ex) {}
}
var objId = this.customSettings.uploadType == 'attach' ? 'attachlist' : 'imgattachlist';
var listObj = $(objId);
var tableObj = listObj.getElementsByTagName("table");
if(!tableObj.length) {
listObj.innerHTML = "";
}
} else if(this.customSettings.uploadType == 'blog') {
if(typeof switchImagebutton == "function") {
switchImagebutton('imgattachlist');
}
}
this.startUpload();
} catch (ex) {
this.debug(ex);
}
}
function uploadStart(file) {
try {
this.addPostParam('filetype', file.type);
if(this.customSettings.uploadSource == 'forum' && this.customSettings.uploadType == 'poll') {
var preObj = $(this.customSettings.progressTarget);
preObj.style.display = 'none';
preObj.innerHTML = '';
}
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus("上传中...");
progress.toggleCancel(true, this);
if(this.customSettings.uploadSource == 'forum') {
var objId = this.customSettings.uploadType == 'attach' ? 'attachlist' : 'imgattachlist';
var attachlistObj = $(objId).parentNode;
attachlistObj.scrollTop = $(file.id).offsetTop - attachlistObj.clientHeight;
}
} catch (ex) {
}
return true;
}
function uploadProgress(file, bytesLoaded, bytesTotal) {
try {
var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus("正在上传("+percent+"%)...");
} catch (ex) {
this.debug(ex);
}
}
function uploadSuccess(file, serverData) {
try {
var progress = new FileProgress(file, this.customSettings.progressTarget);
if(this.customSettings.uploadSource == 'forum') {
if(this.customSettings.uploadType == 'poll') {
var data = eval('('+serverData+')');
if(parseInt(data.aid)) {
var preObj = $(this.customSettings.progressTarget);
preObj.innerHTML = "";
preObj.style.display = '';
var img = new Image();
img.src = IMGDIR + '/attachimg_2.png';//data.smallimg;
var imgObj = document.createElement("img");
imgObj.src = img.src;
imgObj.className = "cur1";
imgObj.onmouseout = function(){hideMenu('poll_img_preview_'+data.aid+'_menu');};//"hideMenu('poll_img_preview_"+data.aid+"_menu');";
imgObj.onmouseover = function(){showMenu({'menuid':'poll_img_preview_'+data.aid+'_menu','ctrlclass':'a','duration':2,'timeout':0,'pos':'34'});};//"showMenu({'menuid':'poll_img_preview_"+data.aid+"_menu','ctrlclass':'a','duration':2,'timeout':0,'pos':'34'});";
preObj.appendChild(imgObj);
var inputObj = document.createElement("input");
inputObj.type = 'hidden';
inputObj.name = 'pollimage[]';
inputObj.id = this.customSettings.progressTarget+'_aid';
inputObj.value= data.aid;
preObj.appendChild(inputObj);
var preImgObj = document.createElement("span");
preImgObj.style.display = 'none';
preImgObj.id = 'poll_img_preview_'+data.aid+'_menu';
img = new Image();
img.src = data.smallimg;
imgObj = document.createElement("img");
imgObj.src = img.src;
preImgObj.appendChild(imgObj);
preObj.appendChild(preImgObj);
}
} else {
aid = parseInt(serverData);
if(aid > 0) {
if(this.customSettings.uploadType == 'attach') {
ajaxget('forum.php?mod=ajax&action=attachlist&aids=' + aid + (!fid ? '' : '&fid=' + fid)+(typeof resulttype == 'undefined' ? '' : '&result=simple'), file.id);
} else if(this.customSettings.uploadType == 'image') {
var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'image_td_'+aid);
ajaxget('forum.php?mod=ajax&action=imagelist&type=single&pid=' + pid + '&aids=' + aid + (!fid ? '' : '&fid=' + fid), tdObj.id);
$(file.id).style.display = 'none';
}
} else {
aid = aid < -1 ? Math.abs(aid) : aid;
if(typeof STATUSMSG[aid] == "string") {
progress.setStatus(STATUSMSG[aid]);
showDialog(STATUSMSG[aid], 'notice', null, null, 0, null, null, null, null, sdCloseTime);
} else {
progress.setStatus("取消上传");
}
this.cancelUpload(file.id);
progress.setCancelled();
progress.toggleCancel(true, this);
var stats = this.getStats();
var obj = {'successful_uploads':--stats.successful_uploads, 'upload_cancelled':++stats.upload_cancelled};
this.setStats(obj);
}
}
} else if(this.customSettings.uploadType == 'album') {
var data = eval('('+serverData+')');
if(parseInt(data.picid)) {
var newTr = document.createElement("TR");
var newTd = document.createElement("TD");
var img = new Image();
img.src = data.url;
var imgObj = document.createElement("img");
imgObj.src = img.src;
newTd.className = 'c';
newTd.appendChild(imgObj);
newTr.appendChild(newTd);
newTd = document.createElement("TD");
newTd.innerHTML = '<strong>'+file.name+'</strong>';
newTr.appendChild(newTd);
newTd = document.createElement("TD");
newTd.className = 'd';
newTd.innerHTML = '图片描述<br/><textarea name="title['+data.picid+']" cols="40" rows="2" class="pt"></textarea>';
newTr.appendChild(newTd);
this.customSettings.imgBoxObj.appendChild(newTr);
} else {
showDialog('图片上传失败', 'notice', null, null, 0, null, null, null, null, sdCloseTime);
}
$(file.id).style.display = 'none';
} else if(this.customSettings.uploadType == 'blog') {
var data = eval('('+serverData+')');
if(parseInt(data.picid)) {
var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'image_td_'+data.picid);
var img = new Image();
img.src = data.url;
var imgObj = document.createElement("img");
imgObj.src = img.src;
imgObj.className = "cur1";
imgObj.onclick = function() {insertImage(data.bigimg);};
tdObj.appendChild(imgObj);
var inputObj = document.createElement("input");
inputObj.type = 'hidden';
inputObj.name = 'picids['+data.picid+']';
inputObj.value= data.picid;
tdObj.appendChild(inputObj);
} else {
showDialog('图片上传失败', 'notice', null, null, 0, null, null, null, null, sdCloseTime);
}
$(file.id).style.display = 'none';
} else if(this.customSettings.uploadSource == 'portal') {
var data = eval('('+serverData+')');
if(data.aid) {
if(this.customSettings.uploadType == 'attach') {
ajaxget('portal.php?mod=attachment&op=getattach&type=attach&id=' + data.aid, file.id);
if($('attach_tblheader')) {
$('attach_tblheader').style.display = '';
}
} else {
var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'attach_list_'+data.aid);
ajaxget('portal.php?mod=attachment&op=getattach&id=' + data.aid, tdObj.id);
$(file.id).style.display = 'none';
}
} else {
showDialog('上传失败', 'notice', null, null, 0, null, null, null, null, sdCloseTime);
progress.setStatus("Cancelled");
this.cancelUpload(file.id);
progress.setCancelled();
progress.toggleCancel(true, this);
}
} else {
progress.setComplete();
progress.setStatus("上传完成.");
progress.toggleCancel(false);
}
} catch (ex) {
this.debug(ex);
}
}
function getInsertTdId(boxObj, tdId) {
var tableObj = boxObj.getElementsByTagName("table");
var tbodyObj, trObj, tdObj;
if(!tableObj.length) {
tableObj = document.createElement("table");
tableObj.className = "imgl";
tbodyObj = document.createElement("TBODY");
tableObj.appendChild(tbodyObj);
boxObj.appendChild(tableObj);
} else if(!tableObj[0].getElementsByTagName("tbody").length) {
tbodyObj = document.createElement("TBODY");
tableObj.appendChild(tbodyObj);
} else {
tableObj = tableObj[0];
tbodyObj = tableObj.getElementsByTagName("tbody")[0];
}
var createTr = true;
var inserID = 0;
if(tbodyObj.childNodes.length) {
trObj = tbodyObj.childNodes[tbodyObj.childNodes.length -1];
var findObj = trObj.getElementsByTagName("TD");
for(var j=0; j < findObj.length; j++) {
if(findObj[j].id == "") {
inserID = j;
tdObj = findObj[j];
break;
}
}
if(inserID) {
createTr = false;
}
}
if(createTr) {
trObj = document.createElement("TR");
for(var i=0; i < 4; i++) {
var newTd = document.createElement("TD");
newTd.width = "25%";
newTd.vAlign = "bottom";
newTd.appendChild(document.createTextNode(" "));
trObj.appendChild(newTd);
}
tdObj = trObj.childNodes[0];
tbodyObj.appendChild(trObj);
}
tdObj.id = tdId;
return tdObj;
}
function uploadComplete(file) {
try {
if (this.getStats().files_queued === 0) {
} else {
this.startUpload();
}
} catch (ex) {
this.debug(ex);
}
}
function uploadError(file, errorCode, message) {
try {
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setError();
progress.toggleCancel(false);
switch (errorCode) {
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
progress.setStatus("Upload Error: " + message);
this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
progress.setStatus("Configuration Error");
this.debug("Error Code: No backend file, File name: " + file.name + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
progress.setStatus("Upload Failed.");
this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.IO_ERROR:
progress.setStatus("Server (IO) Error");
this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
progress.setStatus("Security Error");
this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
progress.setStatus("Upload limit exceeded.");
this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
progress.setStatus("File not found.");
this.debug("Error Code: The file was not found, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
progress.setStatus("Failed Validation. Upload skipped.");
this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
if (this.getStats().files_queued === 0) {
}
progress.setStatus(this.customSettings.alertType ? STATUSMSG[this.customSettings.alertType] : "Cancelled");
progress.setCancelled();
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
progress.setStatus("Stopped");
break;
default:
progress.setStatus("Unhandled Error: " + error_code);
this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
}
} catch (ex) {
this.debug(ex);
}
}

1062
static/js/home.js Normal file

File diff suppressed because it is too large Load Diff

334
static/js/home_drag.js Normal file
View File

@@ -0,0 +1,334 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: home_drag.js 32655 2013-02-28 04:08:00Z zhengqingpeng $
*/
var Drags = [];
var nDrags = 1;
var mouseOffset = null;
var iMouseDown = false;
var lMouseState = false;
var dragObject = null;
var DragDrops = [];
var curTarget = null;
var lastTarget = null;
var dragHelper = null;
var tempDiv = null;
var rootParent = null;
var rootSibling = null;
var D1Target = null;
Number.prototype.NaN0=function(){return isNaN(this)?0:this;};
function CreateDragContainer(){
var cDrag = DragDrops.length;
DragDrops[cDrag] = [];
for(var i=0; i<arguments.length; i++){
var cObj = arguments[i];
DragDrops[cDrag].push(cObj);
cObj.setAttribute('DropObj', cDrag);
for(var j=0; j<cObj.childNodes.length; j++){
if(cObj.childNodes[j].nodeName=='#text') continue;
cObj.childNodes[j].setAttribute('DragObj', cDrag);
}
}
}
function getPosition(e){
var left = 0;
var top = 0;
while (e.offsetParent){
left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
top += e.offsetTop + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
e = e.offsetParent;
}
left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
top += e.offsetTop + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
return {x:left, y:top};
}
function mouseCoords(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
function writeHistory(object, message){
if(!object || !object.parentNode || typeof object.parentNode.getAttribute == 'unknown' || !object.parentNode.getAttribute) return;
var historyDiv = object.parentNode.getAttribute('history');
if(historyDiv){
historyDiv = document.getElementById(historyDiv);
historyDiv.appendChild(document.createTextNode(object.id+': '+message));
historyDiv.appendChild(document.createElement('BR'));
historyDiv.scrollTop += 50;
}
}
function getMouseOffset(target, ev){
ev = ev || window.event;
var docPos = getPosition(target);
var mousePos = mouseCoords(ev);
return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}
function mouseMove(ev){
ev = ev || window.event;
var target = ev.target || ev.srcElement;
var mousePos = mouseCoords(ev);
if(Drags[0]){
if(lastTarget && (target!==lastTarget)){
writeHistory(lastTarget, 'Mouse Out Fired');
var origClass = lastTarget.getAttribute('origClass');
if(origClass) lastTarget.className = origClass;
}
var dragObj = target.getAttribute('DragObj');
if(dragObj!=null){
if(target!=lastTarget){
writeHistory(target, 'Mouse Over Fired');
var oClass = target.getAttribute('overClass');
if(oClass){
target.setAttribute('origClass', target.className);
target.className = oClass;
}
}
if(iMouseDown && !lMouseState){
writeHistory(target, 'Start Dragging');
curTarget = target;
rootParent = curTarget.parentNode;
rootSibling = curTarget.nextSibling;
mouseOffset = getMouseOffset(target, ev);
for(var i=0; i<dragHelper.childNodes.length; i++) dragHelper.removeChild(dragHelper.childNodes[i]);
dragHelper.appendChild(curTarget.cloneNode(true));
dragHelper.style.display = 'block';
var dragClass = curTarget.getAttribute('dragClass');
if(dragClass){
dragHelper.firstChild.className = dragClass;
}
dragHelper.firstChild.removeAttribute('DragObj');
var dragConts = DragDrops[dragObj];
curTarget.setAttribute('startWidth', parseInt(curTarget.offsetWidth));
curTarget.setAttribute('startHeight', parseInt(curTarget.offsetHeight));
curTarget.style.display = 'none';
for(var i=0; i<dragConts.length; i++){
with(dragConts[i]){
var pos = getPosition(dragConts[i]);
setAttribute('startWidth', parseInt(offsetWidth));
setAttribute('startHeight', parseInt(offsetHeight));
setAttribute('startLeft', pos.x);
setAttribute('startTop', pos.y);
}
for(var j=0; j<dragConts[i].childNodes.length; j++){
with(dragConts[i].childNodes[j]){
if((nodeName=='#text') || (dragConts[i].childNodes[j]==curTarget)) continue;
var pos = getPosition(dragConts[i].childNodes[j]);
setAttribute('startWidth', parseInt(offsetWidth));
setAttribute('startHeight', parseInt(offsetHeight));
setAttribute('startLeft', pos.x);
setAttribute('startTop', pos.y);
}
}
}
}
}
if(curTarget){
dragHelper.style.top = (mousePos.y - mouseOffset.y)+"px";
dragHelper.style.left = (mousePos.x - mouseOffset.x)+"px";
var dragConts = DragDrops[curTarget.getAttribute('DragObj')];
var activeCont = null;
var xPos = mousePos.x - mouseOffset.x + (parseInt(curTarget.getAttribute('startWidth')) /2);
var yPos = mousePos.y - mouseOffset.y + (parseInt(curTarget.getAttribute('startHeight'))/2);
for(var i=0; i<dragConts.length; i++){
with(dragConts[i]){
if((parseInt(getAttribute('startLeft')) < xPos) &&
(parseInt(getAttribute('startTop')) < yPos) &&
((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)){
activeCont = dragConts[i];
break;
}
}
}
if(activeCont){
if(activeCont!=curTarget.parentNode){
writeHistory(curTarget, 'Moved into '+activeCont.id);
}
var beforeNode = null;
for(var i=activeCont.childNodes.length-1; i>=0; i--){
with(activeCont.childNodes[i]){
if(nodeName=='#text') continue;
if(curTarget != activeCont.childNodes[i] &&
((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)){
beforeNode = activeCont.childNodes[i];
}
}
}
if(beforeNode){
if(beforeNode!=curTarget.nextSibling){
writeHistory(curTarget, 'Inserted Before '+beforeNode.id);
activeCont.insertBefore(curTarget, beforeNode);
}
} else {
if((curTarget.nextSibling) || (curTarget.parentNode!=activeCont)){
writeHistory(curTarget, 'Inserted at end of '+activeCont.id);
activeCont.appendChild(curTarget);
}
}
setTimeout(function(){
var contPos = getPosition(activeCont);
activeCont.setAttribute('startWidth', parseInt(activeCont.offsetWidth));
activeCont.setAttribute('startHeight', parseInt(activeCont.offsetHeight));
activeCont.setAttribute('startLeft', contPos.x);
activeCont.setAttribute('startTop', contPos.y);}, 5);
if(curTarget.style.display!=''){
writeHistory(curTarget, 'Made Visible');
curTarget.style.display = '';
curTarget.style.visibility = 'hidden';
}
} else {
if(curTarget.style.display!='none'){
writeHistory(curTarget, 'Hidden');
curTarget.style.display = 'none';
}
}
}
lMouseState = iMouseDown;
lastTarget = target;
}
if(dragObject){
dragObject.style.position = 'absolute';
dragObject.style.top = mousePos.y - mouseOffset.y;
dragObject.style.left = mousePos.x - mouseOffset.x;
}
lMouseState = iMouseDown;
if(curTarget || dragObject) return false;
}
function mouseUp(ev){
if(Drags[0]){
if(curTarget){
writeHistory(curTarget, 'Mouse Up Fired');
dragHelper.style.display = 'none';
if(curTarget.style.display == 'none'){
if(rootSibling){
rootParent.insertBefore(curTarget, rootSibling);
} else {
rootParent.appendChild(curTarget);
}
}
curTarget.style.display = '';
curTarget.style.visibility = 'visible';
}
curTarget = null;
}
dragObject = null;
iMouseDown = false;
}
function mouseDown(ev){
mousedown(ev);
ev = ev || window.event;
var target = ev.target || ev.srcElement;
iMouseDown = true;
if(Drags[0]){
if(lastTarget){
writeHistory(lastTarget, 'Mouse Down Fired');
}
}
if(target.onmousedown || target.getAttribute('DragObj')){
return false;
}
}
function makeDraggable(item){
if(!item) return;
item.onmousedown = function(ev){
dragObject = this;
mouseOffset = getMouseOffset(this, ev);
return false;
}
}
function init_drag2(){
document.onmousemove = mouseMove;
document.onmousedown = mouseDown;
document.onmouseup = mouseUp;
Drags[0] = $('Drags0');
if(Drags[0]){
CreateDragContainer($('DragContainer0'));
}
if(Drags[0]){
var cObj = $('applistcontent');
dragHelper = document.createElement('div');
dragHelper.style.cssName = "apps dragable";
dragHelper.style.cssText = 'position:absolute;display:none;width:777px;';
cObj.parentNode.insertBefore(dragHelper, cObj);
}
}
function mousedown(evnt){
}

View File

@@ -0,0 +1,456 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: home_friendselector.js 26733 2011-12-21 07:18:01Z zhengqingpeng $
*/
(function() {
friendSelector = function(parameter) {
this.dataSource = {};
this.selectUser = {};
this.prompterUser = [];
this.showObj = $(isUndefined(parameter['showId']) ? 'selectorBox' : parameter['showId']);
if(!this.showObj) return;
this.handleObj = $(isUndefined(parameter['searchId']) ? 'valueId' : parameter['searchId']);
this.showType = isUndefined(parameter['showType']) ? 0 : parameter['showType'];
this.searchStr = null;
this.selectNumber = 0;
this.maxSelectNumber = isUndefined(parameter['maxSelectNumber']) ? 0 : parseInt(parameter['maxSelectNumber']);
this.allNumber = 0;
this.notInDataSourceNumber = 0;
this.handleKey = isUndefined(parameter['handleKey']) ? 'this' : parameter['handleKey'];
this.selectTabId = isUndefined(parameter['selectTabId']) ? 'selectTabId' : parameter['selectTabId'];
this.unSelectTabId = isUndefined(parameter['unSelectTabId']) ? 'unSelectTabId' : parameter['unSelectTabId'];
this.maxSelectTabId = isUndefined(parameter['maxSelectTabId']) ? 'maxSelectTabId' : parameter['maxSelectTabId'];
this.formId = isUndefined(parameter['formId']) ? '' : parameter['formId'];
this.filterUser = isUndefined(parameter['filterUser']) ? {} : parameter['filterUser'];
this.showAll = true;
this.newPMUser = {};
this.interlaced = true;
this.handover = true;
this.parentKeyCode = 0;
this.pmSelBoxState = 0;
this.selBoxObj = isUndefined(parameter['selBox']) ? null : $(parameter['selBox']);
this.containerBoxObj = isUndefined(parameter['selBoxMenu']) ? null : $(parameter['selBoxMenu']);
this.imgBtn = null;
this.initialize();
return this;
};
friendSelector.prototype = {
addDataSource : function(data, clear) {
if(typeof data == 'object') {
var userData = data['userdata'];
clear = isUndefined(clear) ? 0: clear;
if(clear) {
this.showObj.innerHTML = "";
if(this.showType == 3) {
this.selBoxObj.innerHTML = '';
}
this.allNumber = 0;
this.dataSource = {};
}
for(var i in userData) {
if(typeof this.filterUser[i] != 'undefined') {
continue;
}
var append = clear ? true : false;
if(typeof this.dataSource[i] == 'undefined') {
this.dataSource[i] = userData[i];
append = true;
this.allNumber++;
}
if(append) {
this.interlaced = !this.interlaced;
if(this.showType == 3) {
this.append(i, 0, 1);
} else {
this.append(i);
}
}
}
if(this.showType == 1) {
this.showSelectNumber();
} else if(this.showType == 2) {
if(this.newPMUser) {
window.setInterval(this.handleKey+".handoverCSS()", 400);
}
}
}
},
addFilterUser : function(data) {
var filterData = {};
if(typeof data != 'object') {
filterData[data] = data;
} else if(typeof data == 'object') {
filterData = data;
} else {
return false;
}
for(var id in filterData) {
this.filterUser[filterData[id]] = filterData[id];
}
return true;
},
handoverCSS : function() {
for(var uid in this.newPMUser) {
$('avt_'+uid).className = this.handover ? 'avt newpm' : 'avt';
}
this.handover = !this.handover;
},
handleEvent : function(key, event) {
var username = '';
this.searchStr = '';
if(key != '') {
if(event.keyCode == 188 || event.keyCode == 13 || event.keyCode == 59) {
if(this.showType == 3) {
if(event.keyCode == 13) {
var currentnum = this.getCurrentPrompterUser();
if(currentnum != -1) {
key = this.dataSource[this.prompterUser[currentnum]]['username'];
}
}
if(this.parentKeyCode != 229) {
this.selectUserName(this.trim(key));
this.showObj.style.display = 'none';
$(this.handleObj.id+'_menu').style.display = 'none';
this.showObj.innerHTML = "";
}
}
} else if(event.keyCode == 38 || event.keyCode == 40) {
} else {
if(this.showType == 3) {
this.showObj.innerHTML = "";
var result = false;
var reg = new RegExp(key, "ig");
this.searchStr = key;
this.prompterUser = [];
for(var uid in this.dataSource) {
username = this.dataSource[uid]['username'];
if(username.match(reg)) {
this.prompterUser.push(uid);
this.append(uid, 1);
result = true;
}
}
if(!result) {
$(this.handleObj.id+'_menu').style.display = 'none';
} else {
showMenu({'showid':this.showObj.id, 'duration':3, 'pos':'43'});
showMenu({'showid':this.handleObj.id, 'duration':3, 'pos':'43'});
}
}
}
} else if(this.showType != 3) {
this.showObj.innerHTML = "";
for(var uid in this.dataSource) {
this.append(uid);
}
} else {
$(this.handleObj.id+'_menu').style.display = 'none';
this.showObj.innerHTML = "";
}
},
selectUserName:function(userName) {
this.handleObj.value = '';
if(userName != '') {
var uid = this.isFriend(userName);
if(uid && typeof this.selectUser[uid] == 'undefined' || uid === 0 && typeof this.selectUser[userName] == 'undefined') {
var spanObj = document.createElement("span");
if(uid) {
this.selectUser[uid] = this.dataSource[uid];
spanObj.id = 'uid' + uid;
if($('chk'+uid) != null) {
$('chk'+uid).checked = true;
}
} else {
var id = 'str' + Math.floor(Math.random() * 10000);
spanObj.id = id;
this.selectUser[userName] = userName;
}
this.selectNumber++;
spanObj.innerHTML= '<a href="javascript:;" class="x" onclick="'+this.handleKey+'.delSelUser(\''+(spanObj.id)+'\');">删除</a><em class="z" title="' + userName + '">' + userName + '</em><input type="hidden" name="users[]" value="'+userName+'" uid="uid'+uid+'" />';
this.handleObj.parentNode.insertBefore(spanObj, this.handleObj);
this.showObj.style.display = 'none';
} else {
alert('已经存在'+userName);
}
}
},
delSelUser:function(id) {
id = isUndefined(id) ? 0 : id;
var uid = id.substring(0, 3) == 'uid' ? parseInt(id.substring(3)) : 0;
var spanObj;
if(uid) {
spanObj = $(id);
delete this.selectUser[uid];
if($('chk'+uid) != null) {
$('chk'+uid).checked = false;
}
} else if(id.substring(0, 3) == 'str') {
spanObj = $(id);
delete this.selectUser[spanObj.getElementsByTagName('input')[0].value];
}
if(spanObj != null) {
this.selectNumber--;
spanObj.parentNode.removeChild(spanObj);
}
},
trim:function(str) {
return str.replace(/\s|,|;/g, '');
},
isFriend:function(userName) {
var id = 0;
for(var uid in this.dataSource) {
if(this.dataSource[uid]['username'] === userName) {
id = uid;
break;
}
}
return id;
},
directionKeyDown : function(event) {},
clearDataSource : function() {
this.dataSource = {};
this.selectUser = {};
},
showUser : function(type) {
this.showObj.innerHTML = '';
type = isUndefined(type) ? 0 : parseInt(type);
this.showAll = true;
if(type == 1) {
for(var uid in this.selectUser) {
this.append(uid);
}
this.showAll = false;
} else {
for(var uid in this.dataSource) {
if(type == 2) {
if(typeof this.selectUser[uid] != 'undefined') {
continue;
}
this.showAll = false;
}
this.append(uid);
}
}
if(this.showType == 1) {
for(var i = 0; i < 3; i++) {
$('showUser_'+i).className = '';
}
$('showUser_'+type).className = 'a brs';
}
},
append : function(uid, filtrate, form) {
filtrate = isUndefined(filtrate) ? 0 : filtrate;
form = isUndefined(form) ? 0 : form;
var liObj = document.createElement("li");
var appendUserData = this.dataSource[uid] || this.selectUser[uid];
var username = appendUserData['username'];
liObj.userid = appendUserData['uid'];
if(typeof this.selectUser[uid] != 'undefined') {
liObj.className = "a";
}
if(filtrate) {
var reg = new RegExp("(" + this.searchStr + ")","ig");
username = username.replace(reg , "<strong>$1</strong>");
}
if(this.showType == 1) {
liObj.innerHTML = '<a href="javascript:;" id="' + liObj.userid + '" onclick="' + this.handleKey + '.select(this.id)" class="cl"><span class="avt brs"><span style="background-image: url(' + appendUserData['avatar'] + ');"></span></span><span class="d">' + username + '</span></a>';
} else if(this.showType == 2) {
if(appendUserData['new'] && typeof this.newPMUser[uid] == 'undefined') {
this.newPMUser[uid] = uid;
}
liObj.className = this.interlaced ? 'alt' : '';
liObj.innerHTML = '<div id="avt_' + liObj.userid + '" class="avt"><a href="home.php?mod=spacecp&ac=pm&op=showmsg&handlekey=showmsg_' + liObj.userid + '&touid=' + liObj.userid + '&pmid='+appendUserData['pmid']+'&daterange='+appendUserData['daterange']+'" title="'+username+'" id="avatarmsg_' + liObj.userid + '" onclick="'+this.handleKey+'.delNewFlag(' + liObj.userid + ');showWindow(\'showMsgBox\', this.href, \'get\', 0);"><img src="' + appendUserData['avatar'] + '" alt="'+username+'" /></a></div><p><a class="xg1" href="home.php?mod=spacecp&ac=pm&op=showmsg&handlekey=showmsg_' + liObj.userid + '&touid=' + liObj.userid + '&pmid='+appendUserData['pmid']+'&daterange='+appendUserData['daterange']+'" title="'+username+'" id="usernamemsg_' + liObj.userid + '" onclick="'+this.handleKey+'.delNewFlag(' + liObj.userid + ');showWindow(\'showMsgBox\', this.href, \'get\', 0);">'+username+'</a></p>';
} else {
if(form) {
var checkstate = typeof this.selectUser[uid] == 'undefined' ? '' : ' checked="checked" ';
liObj.innerHTML = '<label><input type="checkbox" name="selUsers[]" id="chk'+uid+'" value="'+ appendUserData['username'] +'" onclick="if(this.checked) {' + this.handleKey + '.selectUserName(this.value);} else {' + this.handleKey + '.delSelUser(\'uid'+uid+'\');}" '+checkstate+' class="pc" /> <span class="xi2">' + username + '</span></label>';
this.selBoxObj.appendChild(liObj);
return true;
} else {
liObj.innerHTML = '<a href="javascript:;" username="' + this.dataSource[uid]['username'] + '" onmouseover="' + this.handleKey + '.mouseOverPrompter(this);" onclick="' + this.handleKey + '.selectUserName(this.getAttribute(\'username\'));$(\'username\').focus();" class="cl" id="prompter_' + uid + '">' + username + '</a>';
}
}
this.showObj.appendChild(liObj);
},
select : function(uid) {
uid = parseInt(uid);
if(uid){
var select = false;
if(typeof this.selectUser[uid] == 'undefined') {
if(this.maxSelectNumber && this.selectNumber >= this.maxSelectNumber) {
alert('最多只允许选择'+this.maxSelectNumber+'个用户');
return false;
}
this.selectUser[uid] = this.dataSource[uid];
this.selectNumber++;
if(this.showType == '1') {
$(uid).parentNode.className = 'a';
}
select = true;
} else {
delete this.selectUser[uid];
this.selectNumber--;
$(uid).parentNode.className = '';
}
if(this.formId != '') {
var formObj = $(this.formId);
var opId = 'selUids_' + uid;
if(select) {
var inputObj = document.createElement("input");
inputObj.type = 'hidden';
inputObj.id = opId;
inputObj.name = 'uids[]';
inputObj.value = uid;
formObj.appendChild(inputObj);
} else {
formObj.removeChild($(opId));
}
}
if(this.showType == 1) {
this.showSelectNumber();
}
}
},
delNewFlag : function(uid) {
delete this.newPMUser[uid];
},
showSelectNumber:function() {
if($(this.selectTabId) != null && typeof $(this.selectTabId) != 'undefined') {
$(this.selectTabId).innerHTML = this.selectNumber;
}
if($(this.unSelectTabId) != null && typeof $(this.unSelectTabId) != 'undefined') {
this.notInDataSourceNumber = 0;
for(var i in this.selectUser) {
if(typeof this.dataSource[i] == 'undefined') {
this.notInDataSourceNumber++;
}
}
$(this.unSelectTabId).innerHTML = this.allNumber + this.notInDataSourceNumber - this.selectNumber;
}
if($(this.maxSelectTabId) != null && this.maxSelectNumber && typeof $(this.maxSelectTabId) != 'undefined') {
$(this.maxSelectTabId).innerHTML = this.maxSelectNumber - this.selectNumber;
}
},
getCurrentPrompterUser:function() {
var len = this.prompterUser.length;
var selectnum = -1;
if(len) {
for(var i = 0; i < len; i++) {
var obj = $('prompter_' + this.prompterUser[i]);
if(obj != null && obj.className == 'a') {
selectnum = i;
}
}
}
return selectnum;
},
mouseOverPrompter:function(obj) {
var len = this.prompterUser.length;
if(len) {
for(var i = 0; i < len; i++) {
$('prompter_' + this.prompterUser[i]).className = 'cl';
}
obj.className = 'a';
}
},
initialize:function() {
var instance = this;
this.handleObj.onkeyup = function(event) {
event = event ? event : window.event;
instance.handleEvent(this.value, event);
};
if(this.showType == 3) {
this.handleObj.onkeydown = function(event) {
event = event ? event : window.event;
instance.parentKeyCode = event.keyCode;
instance.showObj.style.display = '';
if(event.keyCode == 8 && this.value == '') {
var preNode = this.previousSibling;
if(preNode.tagName == 'SPAN') {
var uid = preNode.getElementsByTagName('input')[0].getAttribute('uid');
if(parseInt(uid.substring(3))) {
instance.delSelUser(uid);
} else {
delete instance.selectUser[preNode.getElementsByTagName('input')[0].value];
instance.selectNumber--;
this.parentNode.removeChild(preNode);
}
}
} else if(event.keyCode == 38) {
if(!instance.prompterUser.length) {
doane(event);
}
var currentnum = instance.getCurrentPrompterUser();
if(currentnum != -1) {
var nextnum = (currentnum == 0) ? (instance.prompterUser.length-1) : currentnum - 1;
$('prompter_' + instance.prompterUser[currentnum]).className = "cl";
$('prompter_' + instance.prompterUser[nextnum]).className = "a";
} else {
$('prompter_' + instance.prompterUser[0]).className = "a";
}
} else if(event.keyCode == 40) {
if(!instance.prompterUser.length) {
doane(event);
}
var currentnum = instance.getCurrentPrompterUser();
if(currentnum != -1) {
var nextnum = (currentnum == (instance.prompterUser.length - 1)) ? 0 : currentnum + 1;
$('prompter_' + instance.prompterUser[currentnum]).className = "cl";
$('prompter_' + instance.prompterUser[nextnum]).className = "a";
} else {
$('prompter_' + instance.prompterUser[0]).className = "a";
}
} else if(event.keyCode == 13) {
doane(event);
}
if(typeof instance != "undefined" && instance.pmSelBoxState) {
instance.pmSelBoxState = 0;
instance.changePMBoxImg(instance.imgBtn);
instance.containerBoxObj.style.display = 'none';
}
};
}
},
changePMBoxImg:function(obj) {
var btnImg = new Image();
btnImg.src = IMGDIR + '/' + (this.pmSelBoxState ? 'icon_top.gif' : 'icon_down.gif');
if(obj != null) {
obj.src = btnImg.src;
}
},
showPMFriend:function(boxId, listId, obj) {
this.pmSelBoxState = !this.pmSelBoxState;
this.imgBtn = obj;
this.changePMBoxImg(obj);
if(this.pmSelBoxState) {
this.selBoxObj.innerHTML = '';
for(var uid in this.dataSource) {
this.append(uid, 0, 1);
}
}
this.containerBoxObj.style.display = this.pmSelBoxState ? '' : 'none';
this.showObj.innerHTML = "";
},
showPMBoxUser:function() {
this.selBoxObj.innerHTML = '';
for(var uid in this.dataSource) {
this.append(uid, 0, 1);
}
},
extend:function (obj) {
for (var i in obj) {
this[i] = obj[i];
}
}
};
})();

188
static/js/home_uploadpic.js Normal file
View File

@@ -0,0 +1,188 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: home_uploadpic.js 32590 2013-02-22 09:42:48Z monkey $
*/
var attachexts = new Array();
var attachwh = new Array();
var insertType = 1;
var thumbwidth = parseInt(60);
var thumbheight = parseInt(60);
var extensions = 'jpg,jpeg,gif,png';
var forms;
var nowUid = 0;
var albumid = 0;
var uploadStat = 0;
var picid = 0;
var nowid = 0;
var mainForm;
var successState = false;
function delAttach(id) {
$('attachbody').removeChild($('attach_' + id).parentNode.parentNode.parentNode);
if($('attachbody').innerHTML == '') {
addAttach();
}
$('localimgpreview_' + id + '_menu') ? document.body.removeChild($('localimgpreview_' + id + '_menu')) : null;
}
function addAttach() {
newnode = $('attachbodyhidden').rows[0].cloneNode(true);
var id = nowid;
var tags;
tags = newnode.getElementsByTagName('form');
for(i = 0;i < tags.length;i++) {
if(tags[i].id == 'upload') {
tags[i].id = 'upload_' + id;
}
}
tags = newnode.getElementsByTagName('input');
for(i = 0;i < tags.length;i++) {
if(tags[i].name == 'attach') {
tags[i].id = 'attach_' + id;
tags[i].name = 'attach';
tags[i].onchange = function() {insertAttach(id)};
tags[i].unselectable = 'on';
}
if(tags[i].id == 'albumid') {
tags[i].id = 'albumid_' + id;
}
}
tags = newnode.getElementsByTagName('span');
for(i = 0;i < tags.length;i++) {
if(tags[i].id == 'localfile') {
tags[i].id = 'localfile_' + id;
}
}
nowid++;
$('attachbody').appendChild(newnode);
}
addAttach();
function insertAttach(id) {
var localimgpreview = '';
var path = $('attach_' + id).value;
var ext = getExt(path);
var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
var localfile = $('attach_' + id).value.substr($('attach_' + id).value.replace(/\\/g, '/').lastIndexOf('/') + 1);
if(path == '') {
return;
}
if(extensions != '' && (re.exec(extensions) == null || ext == '')) {
alert('对不起,不支持上传此类扩展名的图片');
return;
}
attachexts[id] = inArray(ext, ['gif', 'jpg', 'jpeg', 'png']) ? 2 : 1;
var inhtml = '<table cellspacing="0" cellpadding="0" class="up_row"><tr>';
if(typeof no_insert=='undefined') {
localfile += '&nbsp;<a href="javascript:;" class="xi2" title="点击这里插入内容中当前光标的位置" onclick="insertAttachimgTag(' + id + ');return false;">[插入]</a>';
}
inhtml += '<td><strong>' + localfile +'</strong>';
inhtml += '</td><td class="d">图片描述<br/><textarea name="pic_title" cols="40" rows="2" class="pt"></textarea>';
inhtml += '</td><td class="o"><span id="showmsg' + id + '"><a href="javascript:;" onclick="delAttach(' + id + ');return false;" class="xi2">[删除]</a></span>';
inhtml += '</td></tr></table>';
$('localfile_' + id).innerHTML = inhtml;
$('attach_' + id).style.display = 'none';
addAttach();
}
function getPath(obj){
if (obj) {
if (BROWSER.ie && BROWSER.ie < 7) {
obj.select();
return document.selection.createRange().text;
} else if(BROWSER.firefox) {
if (obj.files) {
return obj.files.item(0).getAsDataURL();
}
return obj.value;
} else {
return '';
}
return obj.value;
}
}
function inArray(needle, haystack) {
if(typeof needle == 'string') {
for(var i in haystack) {
if(haystack[i] == needle) {
return true;
}
}
}
return false;
}
function insertAttachimgTag(id) {
edit_insert('[imgid=' + id + ']');
}
function uploadSubmit(obj) {
obj.disabled = true;
mainForm = obj.form;
forms = $('attachbody').getElementsByTagName("FORM");
albumid = $('uploadalbum').value;
upload();
}
function start_upload() {
$('btnupload').disabled = true;
mainForm = $('albumresultform');
forms = $('attachbody').getElementsByTagName("FORM");
upload();
}
function upload() {
if(typeof(forms[nowUid]) == 'undefined') return false;
var nid = forms[nowUid].id.split('_');
nid = nid[1];
if(nowUid>0) {
var upobj = $('showmsg'+nowid);
if(uploadStat==1) {
upobj.innerHTML = '上传成功';
successState = true;
var InputNode;
try {
var InputNode = document.createElement("<input type=\"hidden\" id=\"picid_" + picid + "\" value=\""+ nowid +"\" name=\"picids["+picid+"]\">");
} catch(e) {
var InputNode = document.createElement("input");
InputNode.setAttribute("name", "picids["+picid+"]");
InputNode.setAttribute("type", "hidden");
InputNode.setAttribute("id", "picid_" + picid);
InputNode.setAttribute("value", nowid);
}
mainForm.appendChild(InputNode);
} else {
upobj.style.color = "#f00";
upobj.innerHTML = '上传失败 '+uploadStat;
}
}
if($('showmsg'+nid) != null) {
$('showmsg'+nid).innerHTML = '上传中,请等待(<a href="javascript:;" onclick="forms[nowUid].submit();">重试</a>)';
$('albumid_'+nid).value = albumid;
forms[nowUid].submit();
} else if(nowUid+1 == forms.length) {
if(typeof (no_insert) != 'undefined') {
var albumidcheck = parseInt(parent.albumid);
$('opalbumid').value = isNaN(albumidcheck)? 0 : albumid;
if(!successState) return false;
}
window.onbeforeunload = null;
mainForm.submit();
}
nowid = nid;
nowUid++;
uploadStat = 0;
}

125
static/js/html2dynamic.js Normal file
View File

@@ -0,0 +1,125 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: html2dynamic.js 32720 2013-03-04 10:21:58Z zhangguosheng $
*/
function htmlGetUserStatus () {
var x = new Ajax();
var type = '', typeid = 0, arr = [];
if(DYNAMICURL.indexOf('mod=topic') > -1) {
type = 'topic';
arr = DYNAMICURL.match(/topicid=(\d+)/);
typeid = arr ? arr[1] : 0;
} else if(DYNAMICURL.indexOf('mod=view') > -1) {
type = 'article';
arr = DYNAMICURL.match(/aid=(\d+)/);
typeid = arr ? arr[1] : 0;
}
x.getJSON('misc.php?mod=userstatus&r='+(+(new Date())+'&type='+type+'&typeid='+typeid), function (s) {
if(s) {
for(var key in s) {
switch(key) {
case 'userstatus' :
initUserstatus(s[key]);
break;
case 'qmenu' :
initQmenu(s[key]);
break;
case 'diynav' :
initDiynav(s[key]);
break;
case 'commentnum' :
case 'viewnum' :
initNum(key, s[key]);
break;
}
}
}
});
function initNum(name, val) {
var obj = null;
if(val > 0 && (obj = $('_'+name))) {
obj.innerHTML = parseInt(val);
}
}
function initUserstatus (code) {
try{
var lsform = $('lsform');
if(lsform) {
var i = 0, l = 0;
var parent = lsform.parentNode;
var dom = document.createElement('div');
dom.innerHTML = code;
var allNodes = dom.childNodes;
parent.removeChild(lsform);
for(i = 0,l = allNodes.length; i < l; i++) {
parent.appendChild(allNodes[0]);
}
evalscript(code);
}
} catch (e) {
debug('initUserstatus', e);
}
}
function initQmenu(code) {
try {
var qmenu = $('qmenu_menu');
if(qmenu) {
var dom = document.createElement('div');
dom.innerHTML = code;
qmenu.parentNode.replaceChild(dom.childNodes[0], qmenu);
evalscript(code);
}
} catch (e) {
debug('initQmenu', e);
}
}
function initDiynav(code) {
try {
var i = 0, l = 0;
var dom = document.createElement('div');
dom.innerHTML = code;
var allNodes = dom.childNodes;
var switchblind = $('switchblind');
var insertdom = '';
if(switchblind) {
insertdom = switchblind.parentNode;
for(i = 0,l = allNodes.length; i < l; i++) {
insertdom.appendChild(allNodes[0]);
}
} else {
var wp = $('wp');
if(wp) {
insertdom = wp.parentNode;
for(i = 0,l = allNodes.length; i < l; i++) {
insertdom.insertBefore(allNodes[0], wp);
}
}
}
} catch (e) {
debug('initDiynav', e);
}
}
function debug(name, e) {
if(console) {
console.log(name + ':' + e);
}
}
}
function htmlCheckUpdate() {
var timestamp = (+ new Date())/1000;
if(html_lostmodify && html_lostmodify < timestamp - 300) {
$F('make_html', [SITEURL + DYNAMICURL + (DYNAMICURL.indexOf('?') < 0 ? '?' : '&') + '_makehtml'], 'makehtml');
}
}

View File

@@ -0,0 +1,39 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: html5notification.js 31484 2012-09-03 03:49:21Z zhangjie $
*/
function Html5notification() {
var h5n = new Object();
h5n.issupport = function() {
return 'Notification' in window;
};
h5n.shownotification = function(replaceid, url, imgurl, subject, message) {
if (Notification.permission === 'granted') {
sendit();
} else if (Notification.permission !== 'denied') {
Notification.requestPermission().then(function (perm) {
if (perm === 'granted') {
sendit();
}
});
}
function sendit() {
var n = new Notification(subject, {
tag: replaceid,
icon: imgurl,
body: message
});
n.onclick = function (e) {
e.preventDefault();
window.open(url, '_blank');
};
}
};
return h5n;
}

627
static/js/imgcropper.js Normal file
View File

@@ -0,0 +1,627 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: imgcropper.js 30998 2012-07-06 07:22:08Z zhangguosheng $
*/
(function(){
ImgCropper = function() {
this.options = {
opacity: 50,
color: "",
width: 0,
height: 0,
resize: false,
right: "",
left: "",
up: "",
down: "",
rightDown: "",
leftDown: "",
rightUp: "",
leftUp: "",
min: false,
minWidth: 50,
minHeight: 50,
scale: false,
ratio: 0,
Preview: "",
viewWidth: 0,
viewHeight: 0
};
this.setParameter.apply(this, arguments);
};
ImgCropper.prototype = {
setParameter: function(container, handle, url, options) {
this._container = $(container);
this._layHandle = $(handle);
this.url = url;
this._layBase = this._container.appendChild(document.createElement("img"));
this._layCropper = this._container.appendChild(document.createElement("img"));
this._layCropper.onload = Util.bindApply(this, this.setPos);
this._tempImg = document.createElement("img");
this._tempImg.onload = Util.bindApply(this, this.setSize);
this.options = Util.setOptions(this.options, options || {});
this.opacity = Math.round(this.options.opacity);
this.color = this.options.color;
this.scale = !!this.options.scale;
this.ratio = Math.max(this.options.ratio, 0);
this.width = Math.round(this.options.width);
this.height = Math.round(this.options.height);
this.setLayHandle = true;
var oPreview = $(this.options.Preview);
if(oPreview){
oPreview.style.position = "relative";
oPreview.style.overflow = "hidden";
this.viewWidth = Math.round(this.options.viewWidth);
this.viewHeight = Math.round(this.options.viewHeight);
this._view = oPreview.appendChild(document.createElement("img"));
this._view.style.position = "absolute";
this._view.onload = Util.bindApply(this, this.SetPreview);
}
this._drag = new dzDrag(handle, {limit:true, container:container, onDragMove: Util.bindApply(this, this.setPos)});
this.resize = !!this.options.resize;
if(this.resize){
var op = this.options;
var _resize = new ImgCropperResize(container, {max: false, scale:true, min:true, minWidth:options.minWidth, minHeight:options.minHeight, onResize: Util.bindApply(this, this.scaleImg)});
op.rightDown && (_resize.set(op.rightDown, "right-down"));
op.leftDown && (_resize.set(op.leftDown, "left-down"));
op.rightUp && (_resize.set(op.rightUp, "right-up"));
op.leftUp && (_resize.set(op.leftUp, "left-up"));
op.right && (_resize.set(op.right, "right"));
op.left && (_resize.set(op.left, "left"));
op.down && (_resize.set(op.down, "down"));
op.up && (_resize.set(op.up, "up"));
this.min = !!this.options.min;
this.minWidth = Math.round(this.options.minWidth);
this.minHeight = Math.round(this.options.minHeight);
this._resize = _resize;
}
this._container.style.position = "relative";
this._container.style.overflow = "hidden";
this._layHandle.style.zIndex = 200;
this._layCropper.style.zIndex = 100;
this._layBase.style.position = this._layCropper.style.position = "absolute";
this._layBase.style.top = this._layBase.style.left = this._layCropper.style.top = this._layCropper.style.left = 0;
this.initialize();
},
initialize: function() {
this.color && (this._container.style.backgroundColor = this.color);
this._tempImg.src = this._layBase.src = this._layCropper.src = this.url;
if(BROWSER.ie){
this._layBase.style.filter = "alpha(opacity:" + this.opacity + ")";
this._layHandle.style.filter = "alpha(opacity:0)";
this._layHandle.style.backgroundColor = "#FFF";
} else {
this._layBase.style.opacity = this.opacity / 100;
}
this._view && (this._view.src = this.url);
if(this.resize){
with(this._resize){
Scale = this.scale; Ratio = this.ratio; Min = this.min; minWidth = this.minWidth; minHeight = this.minHeight;
}
}
},
setPos: function() {
if(BROWSER.ie == 6.0){ with(this._layHandle.style){ zoom = .9; zoom = 1; }; };
var p = this.getPos();
this._layCropper.style.clip = "rect(" + p.Top + "px " + (p.Left + p.Width) + "px " + (p.Top + p.Height) + "px " + p.Left + "px)";
this.SetPreview();
parent.resetHeight(this._container, this.getPos(), this._layBase);
},
scaleImg:function() {
this.height = this._resize._styleHeight;
this.width = this._resize._styleWidth;
this.initialize();
this.setSize();
this.setPos();
var maxRight = (parseInt(this._layHandle.style.left) || 0) + (parseInt(this._layHandle.offsetWidth) || 0);
var maxBottom = (parseInt(this._layHandle.style.top) || 0) + (parseInt(this._layHandle.offsetHeight) || 0);
if(this._container != null) {
if(maxRight > this._container.clientWidth) {
var nowLeft = this._container.clientWidth - this._layHandle.offsetWidth;
this._layHandle.style.left = (nowLeft < 0 ? 0 : nowLeft) + "px";
}
if(maxBottom > this._container.clientHeight) {
var nowTop = this._container.clientHeight - this._layHandle.offsetHeight;
this._layHandle.style.top = (nowTop < 0 ? 0 : nowTop) + "px";
}
}
parent.resetHeight(this._container, this.getPos(), this._layBase);
},
SetPreview: function() {
if(this._view){
var p = this.getPos(), s = this.getSize(p.Width, p.Height, this.viewWidth, this.viewHeight), scale = s.Height / p.Height;
var pHeight = this._layBase.height * scale, pWidth = this._layBase.width * scale, pTop = p.Top * scale, pLeft = p.Left * scale;
with(this._view.style){
width = pWidth + "px"; height = pHeight + "px"; top = - pTop + "px "; left = - pLeft + "px";
clip = "rect(" + pTop + "px " + (pLeft + s.Width) + "px " + (pTop + s.Height) + "px " + pLeft + "px)";
}
}
},
setSize: function() {
if(this.width > this._tempImg.width) {
this.width = this._tempImg.width;
}
if(this.height > this._tempImg.height) {
this.height = this._tempImg.height;
}
var s = this.getSize(this._tempImg.width, this._tempImg.height, this.width, this.height);
if(this.options.min && (s.Width <= this.options.minWidth || s.Height <= this.options.minHeight)) {
return false;
}
this._layBase.style.width = this._layCropper.style.width = s.Width + "px";
this._layBase.style.height = this._layCropper.style.height = s.Height + "px";
this._drag.maxRight = s.Width; this._drag.maxBottom = s.Height;
if(this.resize) {
this._container.style.width = this._layBase.style.width; this._container.style.height = this._layBase.style.height;
if(this.setLayHandle) {
this._layHandle.style.left = ((s.Width - this._layHandle.offsetWidth)/2)+"px";
this._layHandle.style.top = ((s.Height - this._layHandle.offsetHeight)/2)+"px";
this.setPos();
this.setLayHandle = false;
}
}
},
getPos: function() {
with(this._layHandle){
return { Top: offsetTop, Left: offsetLeft, Width: offsetWidth, Height: offsetHeight };
}
},
getSize: function(nowWidth, nowHeight, fixWidth, fixHeight) {
var iWidth = nowWidth, iHeight = nowHeight, scale = iWidth / iHeight;
if(fixHeight){ iWidth = (iHeight = fixHeight) * scale; }
if(fixWidth && (!fixHeight || iWidth > fixWidth)){ iHeight = (iWidth = fixWidth) / scale; }
return { Width: iWidth, Height: iHeight }
}
};
ImgCropperResize = function() {
this.options = {
max: false,
container: "",
maxLeft: 0,
maxRight: 9999,
maxTop: 0,
maxBottom: 9999,
min: false,
minWidth: 50,
minHeight: 50,
scale: false,
ratio: 0,
onResize: function(){}
};
this.initialize.apply(this, arguments);
};
ImgCropperResize.prototype = {
initialize: function(resizeObjId, options) {
this.options = Util.setOptions(this.options, options || {});
this._resizeObj = $(resizeObjId);
this._styleWidth = this._styleHeight = this._styleLeft = this._styleTop = 0;
this._sideRight = this._sideDown = this._sideLeft = this._sideUp = 0;
this._fixLeft = this._fixTop = 0;
this._scaleLeft = this._scaleTop = 0;
this._maxSet = function(){};
this._maxRightWidth = this._maxDownHeight = this._maxUpHeight = this._maxLeftWidth = 0;
this._maxScaleWidth = this._maxScaleHeight = 0;
this._fun = function(){};
var _style = Util.currentStyle(this._resizeObj);
this._borderX = (parseInt(_style.borderLeftWidth) || 0) + (parseInt(_style.borderRightWidth) || 0);
this._borderY = (parseInt(_style.borderTopWidth) || 0) + (parseInt(_style.borderBottomWidth) || 0);
this._resizeTranscript = Util.bindApply(this, this.resize);
this._stopTranscript = Util.bindApply(this, this.stop);
this.max = !!this.options.max;
this._container = $(this.options.container) || null;
this.maxLeft = Math.round(this.options.maxLeft);
this.maxRight = Math.round(this.options.maxRight);
this.maxTop = Math.round(this.options.maxTop);
this.maxBottom = Math.round(this.options.maxBottom);
this.min = !!this.options.min;
this.minWidth = Math.round(this.options.minWidth);
this.minHeight = Math.round(this.options.minHeight);
this.scale = !!this.options.scale;
this.ratio = Math.max(this.options.ratio, 0);
this.onResize = this.options.onResize;
this._resizeObj.style.position = "absolute";
!this._container || Util.currentStyle(this._container).position == "relative" || (this._container.style.position = "relative");
},
set: function(resize, side) {
var resize = $(resize), fun;
if(!resize) return;
switch(side.toLowerCase()) {
case "up":
fun = this.up;
break;
case "down":
fun = this.down;
break;
case "left":
fun = this.left;
break;
case "right":
fun = this.right;
break;
case "left-up":
fun = this.leftUp;
break;
case "right-up":
fun = this.rightUp;
break;
case "left-down":
fun = this.leftDown;
break;
case "right-down" :
default:
fun = this.rightDown;
break;
};
Util.addEventHandler(resize, "mousedown", Util.bindApply(this, this.start, fun));
},
start: function(oEvent, fun, touch) {
oEvent.stopPropagation ? oEvent.stopPropagation() : (oEvent.cancelBubble = true);
this._fun = fun;
this._styleWidth = this._resizeObj.clientWidth;
this._styleHeight = this._resizeObj.clientHeight;
this._styleLeft = this._resizeObj.offsetLeft;
this._styleTop = this._resizeObj.offsetTop;
this._sideLeft = oEvent.clientX - this._styleWidth;
this._sideRight = oEvent.clientX + this._styleWidth;
this._sideUp = oEvent.clientY - this._styleHeight;
this._sideDown = oEvent.clientY + this._styleHeight;
this._fixLeft = this._styleLeft + this._styleWidth;
this._fixTop = this._styleTop + this._styleHeight;
if(this.scale) {
this.ratio = Math.max(this.ratio, 0) || this._styleWidth / this._styleHeight;
this._scaleLeft = this._styleLeft + this._styleWidth / 2;
this._scaleTop = this._styleTop + this._styleHeight / 2;
};
if(this.max) {
var maxLeft = this.maxLeft, maxRight = this.maxRight, maxTop = this.maxTop, maxBottom = this.maxBottom;
if(!!this._container){
maxLeft = Math.max(maxLeft, 0);
maxTop = Math.max(maxTop, 0);
maxRight = Math.min(maxRight, this._container.clientWidth);
maxBottom = Math.min(maxBottom, this._container.clientHeight);
};
maxRight = Math.max(maxRight, maxLeft + (this.min ? this.minWidth : 0) + this._borderX);
maxBottom = Math.max(maxBottom, maxTop + (this.min ? this.minHeight : 0) + this._borderY);
this._mxSet = function() {
this._maxRightWidth = maxRight - this._styleLeft - this._borderX;
this._maxDownHeight = maxBottom - this._styleTop - this._borderY;
this._maxUpHeight = Math.max(this._fixTop - maxTop, this.min ? this.minHeight : 0);
this._maxLeftWidth = Math.max(this._fixLeft - maxLeft, this.min ? this.minWidth : 0);
};
this._mxSet();
if(this.scale) {
this._maxScaleWidth = Math.min(this._scaleLeft - maxLeft, maxRight - this._scaleLeft - this._borderX) * 2;
this._maxScaleHeight = Math.min(this._scaleTop - maxTop, maxBottom - this._scaleTop - this._borderY) * 2;
}
}
Util.addEventHandler(document, "mousemove", this._resizeTranscript);
Util.addEventHandler(document, "mouseup", this._stopTranscript);
if(BROWSER.ie){
Util.addEventHandler(this._resizeObj, "losecapture", this._stopTranscript);
this._resizeObj.setCapture();
}else{
Util.addEventHandler(window, "blur", this._stopTranscript);
oEvent.preventDefault();
};
},
resize: function(e) {
window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
this._fun(e);
if(this.options.min && (this._styleWidth <= this.options.minWidth || this._styleHeight <= this.options.minHeight)) {
return false;
}
with(this._resizeObj.style) {
width = this._styleWidth + "px"; height = this._styleHeight + "px";
top = this._styleTop + "px"; left = this._styleLeft + "px";
}
this.onResize();
},
up: function(e) {
this.repairY(this._sideDown - e.clientY, this._maxUpHeight);
this.repairTop();
this.turnDown(this.down);
},
down: function(e) {
this.repairY(e.clientY - this._sideUp, this._maxDownHeight);
this.turnUp(this.up);
},
right: function(e) {
this.repairX(e.clientX - this._sideLeft, this._maxRightWidth);
this.turnLeft(this.left);
},
left: function(e) {
this.repairX(this._sideRight - e.clientX, this._maxLeftWidth);
this.repairLeft();
this.turnRight(this.right);
},
rightDown: function(e) {
this.repairAngle(
e.clientX - this._sideLeft, this._maxRightWidth,
e.clientY - this._sideUp, this._maxDownHeight
);
this.turnLeft(this.leftDown) || this.scale || this.turnUp(this.rightUp);
},
rightUp: function(e) {
this.repairAngle(
e.clientX - this._sideLeft, this._maxRightWidth,
this._sideDown - e.clientY, this._maxUpHeight
);
this.repairTop();
this.turnLeft(this.leftUp) || this.scale || this.turnDown(this.rightDown);
},
leftDown: function(e) {
this.repairAngle(
this._sideRight - e.clientX, this._maxLeftWidth,
e.clientY - this._sideUp, this._maxDownHeight
);
this.repairLeft();
this.turnRight(this.rightDown) || this.scale || this.turnUp(this.leftUp);
},
leftUp: function(e) {
this.repairAngle(
this._sideRight - e.clientX, this._maxLeftWidth,
this._sideDown - e.clientY, this._maxUpHeight
);
this.repairTop();
this.repairLeft();
this.turnRight(this.rightUp) || this.scale || this.turnDown(this.leftDown);
},
repairX: function(iWidth, maxWidth) {
iWidth = this.repairWidth(iWidth, maxWidth);
if(this.scale){
var iHeight = this.repairScaleHeight(iWidth);
if(this.max && iHeight > this._maxScaleHeight){
iHeight = this._maxScaleHeight;
iWidth = this.repairScaleWidth(iHeight);
}else if(this.min && iHeight < this.minHeight){
var tWidth = this.repairScaleWidth(this.minHeight);
if(tWidth < maxWidth){ iHeight = this.minHeight; iWidth = tWidth; }
}
this._styleHeight = iHeight;
this._styleTop = this._scaleTop - iHeight / 2;
}
this._styleWidth = iWidth;
},
repairY: function(iHeight, maxHeight) {
iHeight = this.repairHeight(iHeight, maxHeight);
if(this.scale){
var iWidth = this.repairScaleWidth(iHeight);
if(this.max && iWidth > this._maxScaleWidth){
iWidth = this._maxScaleWidth;
iHeight = this.repairScaleHeight(iWidth);
}else if(this.min && iWidth < this.minWidth){
var tHeight = this.repairScaleHeight(this.minWidth);
if(tHeight < maxHeight){ iWidth = this.minWidth; iHeight = tHeight; }
}
this._styleWidth = iWidth;
this._styleLeft = this._scaleLeft - iWidth / 2;
}
this._styleHeight = iHeight;
},
repairAngle: function(iWidth, maxWidth, iHeight, maxHeight) {
iWidth = this.repairWidth(iWidth, maxWidth);
if(this.scale) {
iHeight = this.repairScaleHeight(iWidth);
if(this.max && iHeight > maxHeight){
iHeight = maxHeight;
iWidth = this.repairScaleWidth(iHeight);
}else if(this.min && iHeight < this.minHeight){
var tWidth = this.repairScaleWidth(this.minHeight);
if(tWidth < maxWidth){ iHeight = this.minHeight; iWidth = tWidth; }
}
} else {
iHeight = this.repairHeight(iHeight, maxHeight);
}
this._styleWidth = iWidth;
this._styleHeight = iHeight;
},
repairTop: function() {
this._styleTop = this._fixTop - this._styleHeight;
},
repairLeft: function() {
this._styleLeft = this._fixLeft - this._styleWidth;
},
repairHeight: function(iHeight, maxHeight) {
iHeight = Math.min(this.max ? maxHeight : iHeight, iHeight);
iHeight = Math.max(this.min ? this.minHeight : iHeight, iHeight, 0);
return iHeight;
},
repairWidth: function(iWidth, maxWidth) {
iWidth = Math.min(this.max ? maxWidth : iWidth, iWidth);
iWidth = Math.max(this.min ? this.minWidth : iWidth, iWidth, 0);
return iWidth;
},
repairScaleHeight: function(iWidth) {
return Math.max(Math.round((iWidth + this._borderX) / this.ratio - this._borderY), 0);
},
repairScaleWidth: function(iHeight) {
return Math.max(Math.round((iHeight + this._borderY) * this.ratio - this._borderX), 0);
},
turnRight: function(fun) {
if(!(this.min || this._styleWidth)){
this._fun = fun;
this._sideLeft = this._sideRight;
this.max && this._mxSet();
return true;
}
},
turnLeft: function(fun) {
if(!(this.min || this._styleWidth)){
this._fun = fun;
this._sideRight = this._sideLeft;
this._fixLeft = this._styleLeft;
this.max && this._mxSet();
return true;
}
},
turnUp: function(fun) {
if(!(this.min || this._styleHeight)){
this._fun = fun;
this._sideDown = this._sideUp;
this._fixTop = this._styleTop;
this.max && this._mxSet();
return true;
}
},
turnDown: function(fun) {
if(!(this.min || this._styleHeight)){
this._fun = fun;
this._sideUp = this._sideDown;
this.max && this._mxSet();
return true;
}
},
stop: function() {
Util.removeEventHandler(document, "mousemove", this._resizeTranscript);
Util.removeEventHandler(document, "mouseup", this._stopTranscript);
if(BROWSER.ie){
Util.removeEventHandler(this._resizeObj, "losecapture", this._stopTranscript);
this._resizeObj.releaseCapture();
}else{
Util.removeEventHandler(window, "blur", this._stopTranscript);
}
}
};
dzDrag = function() {
this.options = {
handle: '',
limit: false,
maxLeft: 0,
maxRight: 9999,
maxTop: 0,
maxBottom: 9999,
container: '',
lockX: false,
lockY: false,
onDragStart: function(){},
onDragMove: function(){},
onDragEnd: function(){}
};
this.initialize.apply(this, arguments);
};
dzDrag.prototype = {
initialize: function(dragId, options) {
this.options = Util.setOptions(this.options, options || {});
this._dragObj = $(dragId);
this._x = this._y = 0;
this._marginLeft = this._marginTop = 0;
this._handle = $(this.options.handle) || this._dragObj;
this._container = $(this.options.container) || null;
this._dragObj.style.position = "absolute";
this._dragEndTranscript = Util.bindApply(this, this.dragEnd);
this._dragMoveTranscript = Util.bindApply(this, this.dragMove);
Util.addEventHandler(this._handle, "mousedown", Util.bindApply(this, this.dragStart));
},
dragStart: function(event) {
this.setLimit();
this._x = event.clientX - this._dragObj.offsetLeft;
this._y = event.clientY - this._dragObj.offsetTop;
var curStyle = Util.currentStyle(this._dragObj);
this._marginLeft = parseInt(curStyle.marginLeft) || 0;
this._marginTop = parseInt(curStyle.marginTop) || 0;
Util.addEventHandler(document, "mousemove", this._dragMoveTranscript);
Util.addEventHandler(document, "mouseup", this._dragEndTranscript);
if(BROWSER.ie){
Util.addEventHandler(this._handle, "losecapture", this._dragEndTranscript);
this._handle.setCapture();
}else{
Util.addEventHandler(window, "blur", this._dragEndTranscript);
event.preventDefault();
};
this.options.onDragStart();
},
dragMove: function(event) {
window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
var iLeft = event.clientX - this._x;
var iTop = event.clientY - this._y;
if(this.options.limit) {
var maxLeft = this.options.maxLeft, maxRight = this.options.maxRight, maxTop = this.options.maxTop, maxBottom = this.options.maxBottom;
if(this._container != null){
maxLeft = Math.max(maxLeft, 0);
maxTop = Math.max(maxTop, 0);
maxRight = Math.min(maxRight, this._container.clientWidth);
maxBottom = Math.min(maxBottom, this._container.clientHeight);
};
iLeft = Math.max(Math.min(iLeft, maxRight - this._dragObj.offsetWidth), maxLeft);
iTop = Math.max(Math.min(iTop, maxBottom - this._dragObj.offsetHeight), maxTop);
}
if(!this.options.lockX) { this._dragObj.style.left = iLeft - this._marginLeft + "px"; }
if(!this.options.lockY) { this._dragObj.style.top = iTop - this._marginTop + "px"; }
this.options.onDragMove();
},
dragEnd: function(event) {
Util.removeEventHandler(document, "mousemove", this._dragMoveTranscript);
Util.removeEventHandler(document, "mouseup", this._dragEndTranscript);
if(BROWSER.ie) {
Util.removeEventHandler(this._handle, "losecapture", this._dragEndTranscript);
this._handle.releaseCapture();
} else {
Util.removeEventHandler(window, "blur", this._dragEndTranscript);
}
this.options.onDragEnd();
},
setLimit: function() {
if(this.options.limit) {
this.options.maxRight = Math.max(this.options.maxRight, this.options.maxLeft + this._dragObj.offsetWidth);
this.options.maxBottom = Math.max(this.options.maxBottom, this.options.maxTop + this._dragObj.offsetHeight);
!this._container || Util.currentStyle(this._container).position == "relative" || Util.currentStyle(this._container).position == "absolute" || (this._container.style.position = "relative");
}
}
};
var Util = {
setOptions: function(object, source) {
for(var property in source) {
object[property] = source[property];
}
return object;
},
addEventHandler: function(targetObj, eventType, funHandler) {
if(targetObj.addEventListener) {
targetObj.addEventListener(eventType, funHandler, false);
} else if (targetObj.attachEvent) {
targetObj.attachEvent("on" + eventType, funHandler);
} else {
targetObj["on" + eventType] = funHandler;
}
},
removeEventHandler: function(targetObj, eventType, funHandler) {
if(targetObj.removeEventListener) {
targetObj.removeEventListener(eventType, funHandler, false);
} else if (targetObj.detachEvent) {
targetObj.detachEvent("on" + eventType, funHandler);
} else {
targetObj["on" + eventType] = null;
}
},
bindApply: function(object, fun) {
var args = Array.prototype.slice.call(arguments).slice(2);
return function(event) {
return fun.apply(object, [event || window.event].concat(args));
};
},
currentStyle: function(element){
return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}
};
})();

0
static/js/index.htm Normal file
View File

View File

2
static/js/jquery/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

25
static/js/logging.js Normal file
View File

@@ -0,0 +1,25 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: logging.js 23838 2011-08-11 06:51:58Z monkey $
*/
function lsSubmit(op) {
var op = !op ? 0 : op;
if(op) {
$('lsform').cookietime.value = 2592000;
}
if($('ls_username').value == '' || $('ls_password').value == '') {
showWindow('login', 'member.php?mod=logging&action=login' + (op ? '&cookietime=1' : ''));
} else {
ajaxpost('lsform', 'return_ls', 'return_ls');
}
return false;
}
function errorhandle_ls(str, param) {
if(!param['type']) {
showError(str);
}
}

154
static/js/makehtml.js Normal file
View File

@@ -0,0 +1,154 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: makehtml.js 33047 2013-04-12 08:46:56Z zhangguosheng $
*/
function make_html(url, obj) {
var x = Ajax();
if(url && url.indexOf('?') < 0) {
url = url + '?';
}
x.getJSON(url+'&_makehtml&r='+(+ new Date()), function(ret){
var title = obj ? obj.getAttribute('mktitle') || '' : '';
if(ret && (ret=ret['data']) && ret['status'] == 'html_ok') {
if(obj) {
obj.style.color = 'blue';
obj.innerHTML = '<a href="'+ret['path']+'" target="_blank">'+title+'生成成功</a>';
}
if(ret['nexturl']) {
if(obj) {
obj.style.color = 'green';
obj.innerHTML = '生成'+title+(Math.round((ret['current']/ret['count'])*100))+'%';
}
make_html(ret['nexturl'], obj);
}
} else {
if(obj) {
obj.style.color = 'red';
obj.innerHTML = title+'生成失败';
}
}
});
}
function make_html_batch(url, ids, callback, dom, single) {
this.url = url;
this.ids = ids;
this.count = this.ids.length;
this.callback = callback;
this.dom = dom;
this.single = single && 1;
this.makedcount = 0;
this.jumptime = 2000;
if(this.single) {
this.make(this.ids, this.dom);
} else if(this.ids) {
id = this.ids.pop();
var child = document.createElement('div');
child.style.color = 'green';
var cent = ((1/this.count)*100).toFixed(2);
progress_bar(cent);
child.innerHTML = '开始生成'+this.dom.getAttribute('mktitle');
this.dom.innerHTML = '';
this.dom.appendChild(child);
this.make(id, child);
this.child = child;
var child2 = document.createElement('div');
child2.innerHTML = '<a href="javascript:void(0);" id="mk_goon">如果您的浏览器没有反应,请点击继续...</a>';
this.dom.appendChild(child2);
var obj = this;
$('mk_goon').onclick = function (e) {make_html_batch.prototype.make_goon.call(obj, e)};
}
}
make_html_batch.prototype = {
make_goon : function (){
var id = this.ids.pop();
if(id) {
this.make(this.ids.pop(), this.child);
} else if(this.callback) {
var obj = this;
setTimeout(function(){obj.dom.style.display = 'none';(obj.callback)();}, 1000);
}
},
make : function (id, child) {
var obj = this;
var x = Ajax();
x.getJSON(this.url+id+'&_makehtml&r='+(+ new Date()), function(ret){
if(ret && (data=ret['data']) && data['status'] == 'html_ok') {
obj.makedcount++;
if(data['nexturl']) {
make_html(data['nexturl']);
}
} else if(ret && ret['message']) {
var makehtml_error = $('makehtml_error');
if(!makehtml_error) {
obj.jumptime = 500000;
makehtml_error = document.createElement('div');
makehtml_error.style.color = 'red';
makehtml_error.style.height = '200px';
makehtml_error.style.overflow = 'scroll';
makehtml_error.id = 'makehtml_error';
makehtml_error.innerHTML = '错误信息';
obj.dom.appendChild(makehtml_error);
}
makehtml_error.innerHTML += '<br>[id:' + id + ']' + ret['message'];
makehtml_error.scrollTop = makehtml_error.scrollHeight;
}
if(obj.single) {
child.style.color = 'blue';
child.innerHTML = '<div class="mk_msg">'+'<a href="'+data['path']+'" target="_blank">'+obj.dom.getAttribute('mktitle')+'</a>生成完成'+'</div>';
if(obj.callback) {
setTimeout(function(){(obj.callback)();}, 2000);
}
} else if((id = obj.ids.pop()) || obj.ids.length == 0){
var current = obj.count - obj.ids.length;
var cent = ((current/obj.count)*100).toFixed(2);
progress_bar(cent);
var str = '本次共需要生成'+obj.count+'个'+obj.dom.getAttribute('mktitle')+'文件,成功生成'+obj.makedcount+'个,';
if(cent != 100) {
child.innerHTML = str+'正在生成第'+current+'个,已经完成'+cent+'%';
} else {
child.style.color = 'blue';
child.innerHTML = str+obj.dom.getAttribute('mktitle')+'生成完成';
}
if(id) {
obj.make(id, child);
} else if(obj.callback) {
setTimeout(function(){progress_bar_reset(); obj.dom.innerHTML = ''; obj.dom.style.display = 'none'; (obj.callback)();}, obj.jumptime);
}
}
});
delete x;
}
};
function progress_bar(cent) {
var dom = $('progress_bar');
if(dom) {
if(dom.style.display != 'block') {
dom.style.display = 'block';
}
var allwidth = 400;
var setwidth = allwidth * (cent / 100);
dom.style.borderLeftWidth = setwidth + 'px';
dom.style.width = (allwidth - setwidth) + 'px';
}
}
function progress_bar_reset() {
var dom = $('progress_bar');
if(dom) {
dom.style.display = 'none';
dom.style.borderLeftWidth = '1px';
dom.style.width = '400px';
}
}

153
static/js/md5.js Normal file
View File

@@ -0,0 +1,153 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: md5.js 29228 2012-03-30 01:46:00Z monkey $
*/
var hexcase = 0;
var chrsz = 8;
function hex_md5(s){
return binl2hex(core_md5(str2binl(s), s.length * chrsz));
}
function core_md5(x, len) {
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16) {
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
function str2binl(str) {
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz) {
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
}
return bin;
}
function binl2hex(binarray) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++) {
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
var pwmd5log = new Array();
function pwmd5() {
if(!$(pwmd5.arguments[0]) || $(pwmd5.arguments[0]).value == '') {
return;
}
numargs = pwmd5.arguments.length;
for(var i = 0; i < numargs; i++) {
if(!pwmd5log[pwmd5.arguments[i]] || $(pwmd5.arguments[i]).value.length != 32) {
pwmd5log[pwmd5.arguments[i]] = $(pwmd5.arguments[i]).value = hex_md5($(pwmd5.arguments[i]).value);
}
}
}

View File

@@ -0,0 +1,151 @@
jQuery.extend({
createuploadiframe: function(id, url) {
var iframeid = 'uploadiframe' + id;
var iframe = '<iframe id="' + iframeid + '" name="' + iframeid + '"';
if(window.ActiveXObject) {
if(typeof url == 'boolean') {
iframe += ' src="' + 'javascript:false' + '"';
} else if(typeof url == 'string') {
iframe += ' src="' + url + '"';
}
}
iframe += ' />';
jQuery(iframe).css({'position':'absolute', 'top':'-1200px', 'left':'-1200px'}).appendTo(document.body);
return jQuery('#' + iframeid).get(0);
},
createuploadform: function(id, fileobjid, data) {
var formid = 'uploadform' + id;
var fileid = 'uploadfile' + id;
var form = jQuery('<form method="post" name="' + formid + '" id="' + formid + '" enctype="multipart/form-data"></form>');
if(data) {
for(var i in data) {
jQuery('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
}
}
var oldobj = jQuery('#' + fileobjid);
var newobj = jQuery(oldobj).clone();
jQuery(oldobj).attr('id', fileid).before(newobj).appendTo(form);
jQuery(form).css({'position':'absolute', 'top':'-1200px', 'left':'-1200px'}).appendTo(document.body);
return form;
},
ajaxfileupload: function(s) {
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime();
var form = jQuery.createuploadform(id, s.fileElementId, (typeof(s.data)=='undefined'?false:s.data));
var io = jQuery.createuploadiframe(id, s.secureuri);
var iframeid = 'uploadiframe' + id;
var formid = 'uploadform' + id;
if(s.global && ! jQuery.active++) {
jQuery.event.trigger("ajaxStart");
}
var requestDone = false;
var xml = {};
if(s.global) {
jQuery.event.trigger("ajaxSend", [xml, s]);
}
var uploadcallback = function(istimeout) {
var io = document.getElementById(iframeid);
try {
if(io.contentWindow) {
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
} else if(io.contentDocument) {
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
}
} catch(e) {
jQuery.handleerror(s, xml, null, e);
}
if(xml||istimeout == 'timeout') {
requestdone = true;
var status;
try {
status = istimeout != 'timeout' ? 'success' : 'error';
if(status != 'error') {
var data = jQuery.uploadhttpdata(xml, s.dataType);
if(s.success) {
s.success( data, status );
}
if(s.global) {
jQuery.event.trigger("ajaxSuccess", [xml, s]);
}
} else {
jQuery.handleerror(s, xml, status);
}
} catch(e) {
status = 'error';
jQuery.handleerror(s, xml, status, e);
}
if(s.global) {
jQuery.event.trigger("ajaxComplete", [xml, s]);
}
if(s.global && ! --jQuery.active) {
jQuery.event.trigger("ajaxStop");
}
if (s.complete) {
s.complete(xml, status);
}
jQuery(io).off();
setTimeout(function() {
try {
jQuery(io).remove();
jQuery(form).remove();
} catch(e) {
jQuery.handleerror(s, xml, null, e);
}
}, 100);
xml = null;
}
}
if(s.timeout > 0) {
setTimeout(function() {
if(!requestdone) {
uploadcallback('timeout');
}
}, s.timeout);
}
try {
var form = jQuery('#' + formid);
jQuery(form).attr('action', s.url).attr('method', 'post').attr('target', iframeid);
if(form.encoding) {
jQuery(form).attr('encoding', 'multipart/form-data');
} else {
jQuery(form).attr('enctype', 'multipart/form-data');
}
jQuery(form).submit();
} catch(e) {
jQuery.handleerror(s, xml, null, e);
}
jQuery('#' + iframeid).load(uploadcallback);
return {abort: function () {}};
},
uploadhttpdata: function(r, type) {
var data = !type;
data = type == 'xml' || data ? r.responseXML : r.responseText;
if(type == 'script') {
jQuery.globalEval(data);
}
if(type == "json") {
eval("data = " + data);
}
if(type == "html") {
jQuery("<div>").html(data);
}
return data;
},
handleerror: function(s, xhr, status, e) {
if(s.error) {
s.error.call(s.context || s, xhr, status, e);
}
if(s.global) {
(s.context ? jQuery(s.context) : jQuery.event).trigger("ajaxError", [xhr, s, e]);
}
}
});

View File

@@ -0,0 +1,499 @@
jQuery.extend({
buildfileupload: function(s) {
try {
var reader = new FileReader();
var canvaszoom = false;
if(s.maxfilesize && s.files[0].size > s.maxfilesize * 1024) {
canvaszoom = true;
}
var picupload = function(picdata) {
if(!XMLHttpRequest.prototype.sendAsBinary){
XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
function byteValue(x) {
return x.charCodeAt(0) & 0xff;
}
var ords = Array.prototype.map.call(datastr, byteValue);
var ui8a = new Uint8Array(ords);
this.send(ui8a.buffer);
}
}
var xhr = new XMLHttpRequest(),
file = s.files[0],
index = 0,
start_time = new Date().getTime(),
boundary = '------multipartformboundary' + (new Date).getTime(),
builder;
builder = jQuery.getbuilder(s, file.name, picdata, boundary);
if(s.uploadpercent) {
xhr.upload.onprogress = function(e) {
if(e.lengthComputable) {
var percent = Math.ceil((e.loaded / e.total) * 100);
$('#' + s.uploadpercent).html(percent + '%');
}
};
}
xhr.open("POST", s.uploadurl, true);
xhr.setRequestHeader('content-type', 'multipart/form-data; boundary='
+ boundary);
xhr.sendAsBinary(builder);
xhr.onerror = function() {
s.error();
};
xhr.onabort = function() {
s.error();
};
xhr.ontimeout = function() {
s.error();
};
xhr.onload = function() {
if(xhr.responseText) {
s.success(xhr.responseText);
}
};
};
var getorientation = function(binfile) {
function getbyteat(offset) {
return binfile.charCodeAt(offset) & 0xFF;
}
function getbytesat(offset, length) {
var bytes = [];
for(var i=0; i<length; i++) {
bytes[i] = binfile.charCodeAt((offset + i)) & 0xFF;
}
return bytes;
}
function getshortat(offset, bigendian) {
var shortat = bigendian ?
(getbyteat(offset) << 8) + getbyteat(offset + 1)
: (getbyteat(offset + 1) << 8) + getbyteat(offset);
if(shortat < 0) {
shortat += 65536;
}
return shortat;
}
function getlongat(offset, bigendian) {
var byte1 = getbyteat(offset);
var byte2 = getbyteat(offset + 1);
var byte3 = getbyteat(offset + 2);
var byte4 = getbyteat(offset + 3);
var longat = bigendian ?
(((((byte1 << 8) + byte2) << 8) + byte3) << 8) + byte4
: (((((byte4 << 8) + byte3) << 8) + byte2) << 8) + byte1;
if(longat < 0) longat += 4294967296;
return longat;
}
function getslongat(offset, bigendian) {
var ulongat = getlongat(offset, bigendian);
if(ulongat > 2147483647) {
return ulongat - 4294967296;
} else {
return ulongat;
}
}
function getstringat(offset, length) {
var str = [];
var bytes = getbytesat(offset, length);
for(var i=0; i<length; i++) {
str[i] = String.fromCharCode(bytes[i]);
}
return str.join('');
}
function readtagvalue(entryoffset, tiffstart, dirstart, bigend) {
var type = getshortat(entryoffset + 2, bigend);
var numvalues = getlongat(entryoffset + 4, bigend);
var valueoffset = getlongat(entryoffset + 8, bigend) + tiffstart;
var offset, vals;
switch(type) {
case 1:
case 7:
if(numvalues == 1) {
return getbyteat(entryoffset + 8, bigend);
} else {
offset = numvalues > 4 ? valueoffset : (entryoffset + 8);
vals = [];
for(var n=0; n<numvalues; n++) {
vals[n] = getbyteat(offset + n);
}
return vals;
}
case 2:
offset = numvalues > 4 ? valueoffset : (entryoffset + 8);
return getstringat(offset, numvalues - 1);
case 3:
if(numvalues == 1) {
return getshortat(entryoffset + 8, bigend);
} else {
offset = numvalues > 2 ? valueoffset : (entryoffset + 8);
vals = [];
for(var n=0;n<numvalues; n++) {
vals[n] = getshortat(offset + 2 * n, bigend);
}
return vals;
}
case 4:
if(numvalues == 1) {
return getlongat(entryoffset + 8, bigend);
} else {
vals = [];
for(var n=0; n<numvalues; i++) {
vals[n] = getlongat(valueoffset + 4 * n, bigend);
}
return vals;
}
case 5:
if(numvalues == 1) {
var numerator = getlongat(valueoffset, bigend);
var denominator = getlongat(valueoffset + 4, bigend);
var val = new Number(numerator / denominator);
val.numerator = numerator;
val.denominator = denominator;
return val;
} else {
vals = [];
for(var n=0; n<numvalues; n++) {
var numerator = getlongat(valueoffset + 8*n, bigend);
var denominator = getlongat(valueoffset+4 + 8*n, bigend);
vals[n] = new Number(numerator / denominator);
vals[n].numerator = numerator;
vals[n].denominator = denominator;
}
return vals;
}
case 9:
if(numvalues == 1) {
return getslongat(entryoffset + 8, bigend);
} else {
vals = [];
for(var n=0;n<numvalues; n++) {
vals[n] = getslongat(valueoffset + 4 * n, bigend);
}
return vals;
}
case 10:
if(numvalues == 1) {
return getslongat(valueoffset, bigend) / getslongat(valueoffset+4, bigend);
} else {
vals = [];
for(var n=0; n<numvalues; n++) {
vals[n] = getslongat(valuesoffset + 8*n, bigend) / getslongat(valueoffset+4 + 8*n, bigend);
}
return vals;
}
}
}
function readtags(tiffstart, dirstart, strings, bigend) {
var entries = getshortat(dirstart, bigend);
var tags = {}, entryofffset, tag;
for(var i=0; i<entries; i++) {
entryoffset = dirstart + i *12 + 2;
tag = strings[getshortat(entryoffset, bigend)];
tags[tag] = readtagvalue(entryoffset, tiffstart, dirstart, bigend);
}
return tags;
}
function readexifdata(start) {
if(getstringat(start, 4) != 'Exif') {
return false;
}
var bigend;
var tags, tag;
var tiffoffset = start + 6;
if(getshortat(tiffoffset) == 0x4949) {
bigend = false;
} else if(getshortat(tiffoffset) == 0x4D4D) {
bigend = true;
} else {
return false;
}
if(getshortat(tiffoffset + 2, bigend) != 0x002A) {
return false;
}
if(getlongat(tiffoffset + 4, bigend) != 0x00000008) {
return false;
}
var tifftags = {
0x0112 : "Orientation"
};
tags = readtags(tiffoffset, tiffoffset + 8, tifftags, bigend);
return tags;
}
if(getbyteat(0) != 0xFF || getbyteat(1) != 0xD8) {
return false;
}
var offset = 2;
var length = binfile.length;
var marker;
while(offset < length) {
if(getbyteat(offset) != 0xFF) {
return false;
}
marker = getbyteat(offset + 1);
if(marker == 22400 || marker == 225) {
return readexifdata(offset + 4);
} else {
offset += 2 + getshortat(offset + 2, true);
}
}
};
var detectsubsampling = function(img, imgwidth, imgheight) {
if(imgheight * imgwidth > 1024 * 1024) {
var tmpcanvas = document.createElement('canvas');
tmpcanvas.width = tmpcanvas.height = 1;
var tmpctx = tmpcanvas.getContext('2d');
tmpctx.imageSmoothingQuality = 'high';
tmpctx.drawImage(img, -imgwidth + 1, 0);
return tmpctx.getImageData(0, 0, 1, 1).data[3] === 0;
} else {
return false;
}
};
var detectverticalsquash = function(img, imgheight) {
var tmpcanvas = document.createElement('canvas');
tmpcanvas.width = 1;
tmpcanvas.height = imgheight;
var tmpctx = tmpcanvas.getContext('2d');
tmpctx.imageSmoothingQuality = 'high';
tmpctx.drawImage(img, 0, 0);
var data = tmpctx.getImageData(0, 0, 1, imgheight).data;
var sy = 0;
var ey = imgheight;
var py = imgheight;
while(py > sy) {
var alpha = data[(py - 1) * 4 + 3];
if(alpha === 0) {
ey = py;
} else {
sy = py;
}
py = (ey + sy) >> 1;
}
var ratio = py / imgheight;
return (ratio === 0) ? 1 : ratio;
};
var transformcoordinate = function(canvas, ctx, width, height, orientation) {
switch(orientation) {
case 5:
case 6:
case 7:
case 8:
canvas.width = height;
canvas.height = width;
break;
default:
canvas.width = width;
canvas.height = height;
}
switch(orientation) {
case 2:
ctx.translate(width, 0);
ctx.scale(-1, 1);
break;
case 3:
ctx.translate(width, height);
ctx.rotate(Math.PI);
break;
case 4:
ctx.translate(0, height);
ctx.scale(1, -1);
break;
case 5:
ctx.rotate(0.5 * Math.PI);
ctx.scale(1, -1);
break;
case 6:
ctx.rotate(0.5 * Math.PI);
ctx.translate(0, -height);
break;
case 7:
ctx.rotate(0.5 * Math.PI);
ctx.translate(width, -height);
ctx.scale(-1, 1);
break;
case 8:
ctx.rotate(-0.5 * Math.PI);
ctx.translate(-width, 0);
break;
}
};
var maxheight = s.maxfilesize > 1000 ? (s.maxfilesize > 2000 ? 2560 : 1920) : 1280;
var maxwidth = s.maxfilesize > 1000 ? (s.maxfilesize > 2000 ? 1440 : 1080) : 720;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
ctx.imageSmoothingQuality = 'high';
var img = new Image();
img.onload = function() {
$this = $(this);
var imgwidth = this.width ? this.width : $this.width();
var imgheight = this.height ? this.height : $this.height();
var canvaswidth = maxwidth;
var canvasheight = maxheight;
var newwidth = imgwidth;
var newheight = imgheight;
if(imgwidth/imgheight <= canvaswidth/canvasheight && imgheight >= canvasheight) {
newheight = canvasheight;
newwidth = Math.ceil(canvasheight/imgheight*imgwidth);
} else if(imgwidth/imgheight > canvaswidth/canvasheight && imgwidth >= canvaswidth) {
newwidth = canvaswidth;
newheight = Math.ceil(canvaswidth/imgwidth*imgheight);
}
ctx.save();
var imgfilebinary = this.src.replace(/data:.+;base64,/, '');
if(typeof atob == 'function') {
imgfilebinary = atob(imgfilebinary);
} else {
imgfilebinary = jQuery.base64decode(imgfilebinary);
}
var orientation = getorientation(imgfilebinary);
orientation = orientation.Orientation;
if(detectsubsampling(this, imgwidth, imgheight)) {
imgheight = imgheight / 2;
imgwidth = imgwidth / 2;
}
var vertsquashratio = detectverticalsquash(this, imgheight);
transformcoordinate(canvas, ctx, newwidth, newheight, orientation);
ctx.drawImage(this, 0, 0, imgwidth, imgheight, 0, 0, newwidth, newheight/vertsquashratio);
ctx.restore();
var newdataurl = canvas.toDataURL(s.files[0].type).replace(/data:.+;base64,/, '');
if(typeof atob == 'function') {
picupload(atob(newdataurl));
} else {
picupload(jQuery.base64decode(newdataurl));
}
};
reader.index = 0;
reader.onloadend = function(e) {
if(canvaszoom) {
img.src = e.target.result;
} else {
picupload(e.target.result);
}
return;
};
if(canvaszoom) {
reader.readAsDataURL(s.files[0]);
} else {
reader.readAsBinaryString(s.files[0]);
}
} catch(err) {
return s.error();
}
return;
},
getbuilder: function(s, filename, filedata, boundary) {
var dashdash = '--',
crlf = '\r\n',
builder = '';
for(var i in s.uploadformdata) {
builder += dashdash;
builder += boundary;
builder += crlf;
builder += 'Content-Disposition: form-data; name="' + i + '"';
builder += crlf;
builder += crlf;
builder += s.uploadformdata[i];
builder += crlf;
}
builder += dashdash;
builder += boundary;
builder += crlf;
builder += 'Content-Disposition: form-data; name="' + s.uploadinputname + '"';
builder += '; filename="' + filename + '"';
builder += crlf;
builder += 'Content-Type: application/octet-stream';
builder += crlf;
builder += crlf;
builder += filedata;
builder += crlf;
builder += dashdash;
builder += boundary;
builder += dashdash;
builder += crlf;
return builder;
}
});
jQuery.extend({
base64encode: function(input) {
var output = '';
var chr1, chr2, chr3 = '';
var enc1, enc2, enc3, enc4 = '';
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)){
enc3 = enc4 = 64;
} else if (isNaN(chr3)){
enc4 = 64;
}
output = output+this._keys.charAt(enc1)+this._keys.charAt(enc2)+this._keys.charAt(enc3)+this._keys.charAt(enc4);
chr1 = chr2 = chr3 = '';
enc1 = enc2 = enc3 = enc4 = '';
} while (i < input.length);
return output;
},
base64decode: function(input) {
var output = '';
var chr1, chr2, chr3 = '';
var enc1, enc2, enc3, enc4 = '';
var i = 0;
if (input.length%4!=0){
return '';
}
var base64test = /[^A-Za-z0-9\+\/\=]/g;
if (base64test.exec(input)){
return '';
}
do {
enc1 = this._keys.indexOf(input.charAt(i++));
enc2 = this._keys.indexOf(input.charAt(i++));
enc3 = this._keys.indexOf(input.charAt(i++));
enc4 = this._keys.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64){
output+=String.fromCharCode(chr2);
}
if (enc4 != 64){
output+=String.fromCharCode(chr3);
}
chr1 = chr2 = chr3 = '';
enc1 = enc2 = enc3 = enc4 = '';
} while (i < input.length);
return output;
},
_keys: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
});

951
static/js/mobile/common.js Normal file
View File

@@ -0,0 +1,951 @@
var supporttouch = "ontouchend" in document;
var platform = navigator.platform;
var ua = navigator.userAgent;
var ios = /iPhone|iPad|iPod/.test(platform) && ua.indexOf( "AppleWebKit" ) > -1;
var andriod = ua.indexOf( "Android" ) > -1;
var JSLOADED = [];
var HTML5PLAYER = [];
HTML5PLAYER['apload'] = 0;
HTML5PLAYER['dpload'] = 0;
HTML5PLAYER['flvload'] = 0;
var BROWSER = {};
var USERAGENT = navigator.userAgent.toLowerCase();
browserVersion({'ie':'msie','firefox':'','chrome':'','opera':'','safari':'','mozilla':'','webkit':'','maxthon':'','qq':'qqbrowser','rv':'rv'});
if(BROWSER.safari || BROWSER.rv) {
BROWSER.firefox = true;
}
BROWSER.opera = BROWSER.opera ? opera.version() : 0;
var page = {
converthtml : function() {
var prevpage = qSel('div.pg .prev') ? qSel('div.pg .prev').href : undefined;
var nextpage = qSel('div.pg .nxt') ? qSel('div.pg .nxt').href : undefined;
var lastpage = qSel('div.pg label span') ? (qSel('div.pg label span').innerText.replace(/[^\d]/g, '') || 0) : 0;
var curpage = qSel('div.pg input') ? qSel('div.pg input').value : 1;
var multipage_url = getID('multipage_url') ? getID('multipage_url').value : undefined;
if(!lastpage) {
prevpage = qSel('div.pg .pgb a') ? qSel('div.pg .pgb a').href : undefined;
}
var prevpagehref = nextpagehref = '';
if(prevpage == undefined) {
prevpagehref = 'javascript:;" class="grey';
} else {
prevpagehref = prevpage;
}
if(nextpage == undefined) {
nextpagehref = 'javascript:;" class="grey';
} else {
nextpagehref = nextpage;
}
var selector = '';
if(lastpage) {
selector += '<a id="select_a">';
selector += '<select id="dumppage">';
for(var i=1; i<=lastpage; i++) {
selector += '<option value="'+i+'" '+ (i == curpage ? 'selected' : '') +'>第'+i+'页</option>';
}
selector += '</select>';
selector += '<span>第'+curpage+'页</span>';
}
var pgobj = qSel('div.pg');
pgobj.classList.remove('pg');
pgobj.classList.add('page');
pgobj.innerHTML = '<a href="'+ prevpagehref +'">上一页</a>'+ selector +'<a href="'+ nextpagehref +'">下一页</a>';
qSel('#dumppage').addEventListener('change', function() {
var href = (prevpage || nextpage);
var newhref = href.replace(/page=\d+/, 'page=' + this.value);
if (newhref == href) {
newhref = href.replace(/(forum|thread|article|group|blog)-(\d+)-(\d+)(-(\d+))?\.html/i, '$1-$2-' + this.value + '$4.html');
if (newhref == href && multipage_url != undefined) {
newhref = multipage_url.replace(/{page}/i, this.value);
}
}
window.location.href = newhref;
});
},
};
var scrolltop = {
obj : null,
init : function(obj) {
scrolltop.obj = obj;
var pageHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight);
var screenHeight = window.innerHeight;
var scrollType = 'bottom';
var scrollToPos = function() {
if(scrollType == 'bottom') {
window.scrollTo(0, pageHeight);
} else {
window.scrollTo(0, 0);
}
scrollfunc();
};
var scrollfunc = function() {
var newType;
if(document.documentElement.scrollTop >= 50) {
newType = 'top';
} else {
newType = 'bottom';
}
if(newType != scrollType) {
scrollType = newType;
if(newType == 'top') {
obj.classList.remove('bottom');
} else {
obj.classList.add('bottom');
}
}
};
if(pageHeight - screenHeight < 100) {
obj.style.display = 'none';
} else {
obj.addEventListener('click', scrollToPos);
document.addEventListener('scroll', scrollfunc);
scrollfunc();
}
},
};
var img = {
init : function(is_err_t) {
var errhandle = this.errorhandle;
$('img').on('load', function() {
var obj = $(this);
obj.attr('zsrc', obj.attr('src'));
if(obj.width() < 5 && obj.height() < 10 && obj.css('display') != 'none') {
return errhandle(obj, is_err_t);
}
obj.css('display', 'inline');
obj.css('visibility', 'visible');
if(obj.width() > window.innerWidth) {
obj.css('width', window.innerWidth);
}
obj.parent().find('.loading').remove();
obj.parent().find('.error_text').remove();
})
.on('error', function() {
var obj = $(this);
obj.attr('zsrc', obj.attr('src'));
errhandle(obj, is_err_t);
});
},
errorhandle : function(obj, is_err_t) {
if(obj.attr('noerror') == 'true') {
return;
}
obj.css('visibility', 'hidden');
obj.css('display', 'none');
var parentnode = obj.parent();
parentnode.find('.loading').remove();
parentnode.append('<div class="loading" style="background:url('+ IMGDIR +'/imageloading.gif) no-repeat center center;width:'+parentnode.width()+'px;height:'+parentnode.height()+'px"></div>');
var loadnums = parseInt(obj.attr('load')) || 0;
if(loadnums < 3) {
obj.attr('src', obj.attr('zsrc'));
obj.attr('load', ++loadnums);
return false;
}
if(is_err_t) {
var parentnode = obj.parent();
parentnode.find('.loading').remove();
parentnode.append('<div class="error_text">点击重新加载</div>');
parentnode.find('.error_text').one('click', function() {
obj.attr('load', 0).find('.error_text').remove();
parentnode.append('<div class="loading" style="background:url('+ IMGDIR +'/imageloading.gif) no-repeat center center;width:'+parentnode.width()+'px;height:'+parentnode.height()+'px"></div>');
obj.attr('src', obj.attr('zsrc'));
});
}
return false;
}
};
var POPMENU = new Object;
var popup = {
init : function() {
var $this = this;
$('.popup').each(function(index, obj) {
obj = $(obj);
var pop = $(obj.attr('href'));
if(pop && pop.attr('popup')) {
pop.css({'display':'none'});
obj.on('click', function(e) {
$this.open(pop);
return false;
});
}
});
this.maskinit();
},
maskinit : function() {
var $this = this;
$('#mask').off().on('click', function() {
$this.close();
});
},
open : function(pop, type, url) {
this.close();
this.maskinit();
if(typeof pop == 'string') {
$('#ntcmsg').remove();
if(type == 'alert') {
pop = '<div class="tip"><dt>'+ pop +'</dt><dd><input class="button2" type="button" value="确定" onclick="popup.close();"></dd></div>'
} else if(type == 'confirm') {
pop = '<div class="tip"><dt>'+ pop +'</dt><dd><a class="button" href="'+ url +'">确定</a> <button onclick="popup.close();" class="button">取消</a></dd></div>'
}
$('body').append('<div id="ntcmsg" style="display:none;">'+ pop +'</div>');
pop = $('#ntcmsg');
}
if(POPMENU[pop.attr('id')]) {
$('#' + pop.attr('id') + '_popmenu').html(pop.html()).css({'height':pop.height()+'px', 'width':pop.width()+'px'});
} else {
pop.parent().append('<div class="dialogbox" id="'+ pop.attr('id') +'_popmenu" style="height:'+ pop.height() +'px;width:'+ pop.width() +'px;">'+ pop.html() +'</div>');
}
var popupobj = $('#' + pop.attr('id') + '_popmenu');
var left = (window.innerWidth - popupobj.width()) / 2;
var top = (document.documentElement.clientHeight - popupobj.height()) / 2;
popupobj.css({'display':'block','position':'fixed','left':left,'top':top,'z-index':120,'opacity':1});
$('#mask').css({'display':'block','width':'100%','height':'100%','position':'fixed','top':'0','left':'0','background':'black','opacity':'0.2','z-index':'100'});
POPMENU[pop.attr('id')] = pop;
},
close : function() {
$('#mask').css('display', 'none');
$.each(POPMENU, function(index, obj) {
$('#' + index + '_popmenu').css('display','none');
});
}
};
var dialog = {
init : function() {
$(document).on('click', '.dialog', function() {
var obj = $(this);
popup.open('<img src="' + IMGDIR + '/imageloading.gif">');
$.ajax({
type : 'GET',
url : obj.attr('href') + '&inajax=1',
dataType : 'xml'
})
.success(function(s) {
popup.open(s.lastChild.firstChild.nodeValue);
evalscript(s.lastChild.firstChild.nodeValue);
})
.error(function() {
window.location.href = obj.attr('href');
popup.close();
});
return false;
});
},
};
var formdialog = {
init : function() {
$(document).on('click', '.formdialog', function() {
popup.open('<img src="' + IMGDIR + '/imageloading.gif">');
var obj = $(this);
var formobj = $(this.form);
var isFormData = formobj.find("input[type='file']").length > 0;
$.ajax({
type:'POST',
url:formobj.attr('action') + '&handlekey='+ formobj.attr('id') +'&inajax=1',
data:isFormData ? new FormData(formobj[0]) : formobj.serialize(),
dataType:'xml',
processData:isFormData ? false : true,
contentType:isFormData ? false : 'application/x-www-form-urlencoded; charset=UTF-8'
})
.success(function(s) {
popup.open(s.lastChild.firstChild.nodeValue);
evalscript(s.lastChild.firstChild.nodeValue);
})
.error(function() {
popup.open('表单提交异常,无法完成您的请求', 'alert');
});
return false;
});
}
};
var DISMENU = new Object;
var display = {
init : function() {
var $this = this;
$('.display').each(function(index, obj) {
obj = $(obj);
var dis = $(obj.attr('href'));
if(dis && dis.attr('display')) {
dis.css({'display':'none'});
dis.css({'z-index':'102'});
DISMENU[dis.attr('id')] = dis;
obj.on('click', function(e) {
if(in_array(e.target.tagName, ['A', 'IMG', 'INPUT'])) return;
$this.maskinit();
if(dis.attr('display') == 'true') {
dis.css('display', 'block');
dis.attr('display', 'false');
$('#mask').css({'display':'block','width':'100%','height':'100%','position':'fixed','top':'0','left':'0','background':'transparent','z-index':'100'});
}
return false;
});
}
});
},
maskinit : function() {
var $this = this;
$('#mask').off().on('touchstart', function() {
$this.hide();
});
},
hide : function() {
$('#mask').css('display', 'none');
$.each(DISMENU, function(index, obj) {
obj.css('display', 'none');
obj.attr('display', 'true');
});
}
};
function getID(id) {
return !id ? null : document.getElementById(id);
}
function qSel(sel) {
return document.querySelector(sel);
}
function qSelA(sel) {
return document.querySelectorAll(sel);
}
function mygetnativeevent(event) {
while(event && typeof event.originalEvent !== "undefined") {
event = event.originalEvent;
}
return event;
}
function evalscript(s) {
if(s.indexOf('<script') == -1) return s;
var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
var arr = [];
while(arr = p.exec(s)) {
var p1 = /<script[^\>]*?src=\"([^\>]*?)\"[^\>]*?(reload=\"1\")?(?:charset=\"([\w\-]+?)\")?><\/script>/i;
var arr1 = [];
arr1 = p1.exec(arr[0]);
if(arr1) {
appendscript(arr1[1], '', arr1[2], arr1[3]);
} else {
p1 = /<script(.*?)>([^\x00]+?)<\/script>/i;
arr1 = p1.exec(arr[0]);
appendscript('', arr1[2], arr1[1].indexOf('reload=') != -1);
}
}
return s;
}
var safescripts = {}, evalscripts = [];
function appendscript(src, text, reload, charset) {
var id = hash(src + text);
if(!reload && in_array(id, evalscripts)) return;
if(reload && getID(id)) {
getID(id).parentNode.removeChild(getID(id));
}
evalscripts.push(id);
var scriptNode = document.createElement("script");
scriptNode.type = "text/javascript";
scriptNode.id = id;
scriptNode.charset = charset ? charset : (!document.charset ? document.characterSet : document.charset);
try {
if(src) {
scriptNode.src = src;
scriptNode.onloadDone = false;
scriptNode.onload = function () {
scriptNode.onloadDone = true;
JSLOADED[src] = 1;
};
scriptNode.onreadystatechange = function () {
if((scriptNode.readyState == 'loaded' || scriptNode.readyState == 'complete') && !scriptNode.onloadDone) {
scriptNode.onloadDone = true;
JSLOADED[src] = 1;
}
};
} else if(text){
scriptNode.text = text;
}
document.getElementsByTagName('head')[0].appendChild(scriptNode);
} catch(e) {}
}
function hash(string, length) {
var length = length ? length : 32;
var start = 0;
var i = 0;
var result = '';
filllen = length - string.length % length;
for(i = 0; i < filllen; i++){
string += "0";
}
while(start < string.length) {
result = stringxor(result, string.substr(start, length));
start += length;
}
return result;
}
function stringxor(s1, s2) {
var s = '';
var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var max = Math.max(s1.length, s2.length);
for(var i=0; i<max; i++) {
var k = s1.charCodeAt(i) ^ s2.charCodeAt(i);
s += hash.charAt(k % 52);
}
return s;
}
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 isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
if(cookieValue == '' || seconds < 0) {
cookieValue = '';
seconds = -2592000;
}
if(seconds) {
var expires = new Date();
expires.setTime(expires.getTime() + seconds * 1000);
}
domain = !domain ? cookiedomain : domain;
path = !path ? cookiepath : path;
document.cookie = escape(cookiepre + cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '/')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
}
function getcookie(name, nounescape) {
name = cookiepre + name;
var cookie_start = document.cookie.indexOf(name);
var cookie_end = document.cookie.indexOf(";", cookie_start);
if(cookie_start == -1) {
return '';
} else {
var v = document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length));
return !nounescape ? unescape(v) : v;
}
}
function browserVersion(types) {
var other = 1;
for(i in types) {
var v = types[i] ? types[i] : i;
if(USERAGENT.indexOf(v) != -1) {
var re = new RegExp(v + '(\\/|\\s|:)([\\d\\.]+)', 'ig');
var matches = re.exec(USERAGENT);
var ver = matches != null ? matches[2] : 0;
other = ver !== 0 && v != 'mozilla' ? 0 : other;
} else {
var ver = 0;
}
eval('BROWSER.' + i + '= ver');
}
BROWSER.other = other;
}
function AC_FL_RunContent() {
var str = '';
var ret = AC_GetArgs(arguments, "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
if(BROWSER.ie && !BROWSER.opera) {
str += '<object ';
for (var i in ret.objAttrs) {
str += i + '="' + ret.objAttrs[i] + '" ';
}
str += '>';
for (var i in ret.params) {
str += '<param name="' + i + '" value="' + ret.params[i] + '" /> ';
}
str += '</object>';
} else {
str += '<embed ';
for (var i in ret.embedAttrs) {
str += i + '="' + ret.embedAttrs[i] + '" ';
}
str += '></embed>';
}
return str;
}
function AC_GetArgs(args, classid, mimeType) {
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for (var i = 0; i < args.length; i = i + 2){
var currArg = args[i].toLowerCase();
switch (currArg){
case "classid":break;
case "pluginspage":ret.embedAttrs[args[i]] = 'http://www.macromedia.com/go/getflashplayer';break;
case "src":ret.embedAttrs[args[i]] = args[i+1];ret.params["movie"] = args[i+1];break;
case "codebase":ret.objAttrs[args[i]] = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';break;
case "onafterupdate":case "onbeforeupdate":case "onblur":case "oncellchange":case "onclick":case "ondblclick":case "ondrag":case "ondragend":
case "ondragenter":case "ondragleave":case "ondragover":case "ondrop":case "onfinish":case "onfocus":case "onhelp":case "onmousedown":
case "onmouseup":case "onmouseover":case "onmousemove":case "onmouseout":case "onkeypress":case "onkeydown":case "onkeyup":case "onload":
case "onlosecapture":case "onpropertychange":case "onreadystatechange":case "onrowsdelete":case "onrowenter":case "onrowexit":case "onrowsinserted":case "onstart":
case "onscroll":case "onbeforeeditfocus":case "onactivate":case "onbeforedeactivate":case "ondeactivate":case "type":
case "id":ret.objAttrs[args[i]] = args[i+1];break;
case "width":case "height":case "align":case "vspace": case "hspace":case "class":case "title":case "accesskey":case "name":
case "tabindex":ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];break;
default:ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
ret.objAttrs["classid"] = classid;
if(mimeType) {
ret.embedAttrs["type"] = mimeType;
}
return ret;
}
function appendstyle(url) {
var link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;
var head = document.getElementsByTagName('head')[0];
head.appendChild(link);
}
function detectHtml5Support() {
return document.createElement("Canvas").getContext;
}
function detectPlayer(randomid, ext, src, width, height) {
var h5_support = new Array('aac', 'flac', 'mp3', 'm4a', 'wav', 'flv', 'mp4', 'm4v', '3gp', 'ogv', 'ogg', 'weba', 'webm');
var trad_support = new Array('mp3', 'wma', 'mid', 'wav', 'ra', 'ram', 'rm', 'rmvb', 'swf', 'asf', 'asx', 'wmv', 'avi', 'mpg', 'mpeg', 'mov');
if (in_array(ext, h5_support) && detectHtml5Support()) {
html5Player(randomid, ext, src, width, height);
} else if (in_array(ext, trad_support)) {
tradionalPlayer(randomid, ext, src, width, height);
} else {
document.getElementById(randomid).style.width = '100%';
document.getElementById(randomid).style.height = height + 'px';
}
}
function tradionalPlayer(randomid, ext, src, width, height) {
switch(ext) {
case 'mp3':
case 'wma':
case 'mid':
case 'wav':
height = 64;
html = '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="' + width + '" height="' + height + '"><param name="invokeURLs" value="0"><param name="autostart" value="0" /><param name="url" value="' + src + '" /><embed src="' + src + '" autostart="0" type="application/x-mplayer2" width="' + width + '" height="' + height + '"></embed></object>';
break;
case 'ra':
case 'ram':
height = 32;
html = '<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="' + width + '" height="' + height + '"><param name="autostart" value="0" /><param name="src" value="' + src + '" /><param name="controls" value="controlpanel" /><param name="console" value="' + randomid + '_" /><embed src="' + src + '" autostart="0" type="audio/x-pn-realaudio-plugin" controls="ControlPanel" console="' + randomid + '_" width="' + width + '" height="' + height + '"></embed></object>';
break;
case 'rm':
case 'rmvb':
html = '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="' + width + '" height="' + height + '"><param name="autostart" value="0" /><param name="src" value="' + src + '" /><param name="controls" value="imagewindow" /><param name="console" value="' + randomid + '_" /><embed src="' + src + '" autostart="0" type="audio/x-pn-realaudio-plugin" controls="imagewindow" console="' + randomid + '_" width="' + width + '" height="' + height + '"></embed></object><br /><object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="' + width + '" height="32"><param name="src" value="' + src +'" /><param name="controls" value="controlpanel" /><param name="console" value="' + randomid + '_" /><embed src="' + src + '" autostart="0" type="audio/x-pn-realaudio-plugin" controls="controlpanel" console="' + randomid + '_" width="' + width + '" height="32"></embed></object>';
break;
case 'swf':
html = AC_FL_RunContent('width', width, 'height', height, 'allowNetworking', 'internal', 'allowScriptAccess', 'never', 'src', encodeURI(src), 'quality', 'high', 'bgcolor', '#ffffff', 'wmode', 'transparent', 'allowfullscreen', 'true');
break;
case 'asf':
case 'asx':
case 'wmv':
case 'avi':
case 'mpg':
case 'mpeg':
html = '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="' + width + '" height="' + height + '"><param name="invokeURLs" value="0"><param name="autostart" value="0" /><param name="url" value="' + src + '" /><embed src="' + src + '" autostart="0" type="application/x-mplayer2" width="' + width + '" height="' + height + '"></embed></object>';
break;
case 'mov':
html = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="' + width + '" height="' + height + '"><param name="autostart" value="false" /><param name="src" value="' + src + '" /><embed src="' + src + '" autostart="false" type="video/quicktime" controller="true" width="' + width + '" height="' + height + '"></embed></object>';
break;
default:
break;
}
document.getElementById(randomid).style.width = '100%';
document.getElementById(randomid).style.height = height + 'px';
document.getElementById(randomid + '_container').innerHTML = html;
}
function html5Player(randomid, ext, src, width, height) {
switch (ext) {
case 'aac':
case 'flac':
case 'mp3':
case 'm4a':
case 'wav':
case 'ogg':
height = 66;
if(!HTML5PLAYER['apload']) {
appendstyle(STATICURL + 'js/player/aplayer.min.css');
appendscript(STATICURL + 'js/player/aplayer.min.js');
HTML5PLAYER['apload'] = 1;
}
html5APlayer(randomid, ext, src, width, height);
break;
case 'flv':
if(!HTML5PLAYER['flvload']) {
appendscript(STATICURL + 'js/player/flv.min.js');
HTML5PLAYER['flvload'] = 1;
}
case 'mp4':
case 'm4v':
case '3gp':
case 'ogv':
case 'webm':
if(!HTML5PLAYER['dpload']) {
appendstyle(STATICURL + 'js/player/dplayer.min.css');
appendscript(STATICURL + 'js/player/dplayer.min.js');
HTML5PLAYER['dpload'] = 1;
}
html5DPlayer(randomid, ext, src, width, height);
break;
default:
break;
}
document.getElementById(randomid).style.width = '100%';
}
function html5APlayer(randomid, ext, src, width, height) {
if (JSLOADED[STATICURL + 'js/player/aplayer.min.js']) {
window[randomid] = new APlayer({
container: document.getElementById(randomid + '_container'),
mini: false,
autoplay: false,
loop: 'all',
preload: 'none',
volume: 1,
mutex: true,
listFolded: true,
audio: [{
name: ' ',
artist: ' ',
url: src,
}]
});
} else {
setTimeout(function () {
html5APlayer(randomid, ext, src, width, height);
}, 50);
}
}
function html5DPlayer(randomid, ext, src, width, height) {
if (JSLOADED[STATICURL + 'js/player/dplayer.min.js'] && (ext != 'flv' || JSLOADED[STATICURL + 'js/player/flv.min.js'])) {
window[randomid] = new DPlayer({
container: document.getElementById(randomid + '_container'),
autoplay: false,
loop: true,
screenshot: false,
hotkey: true,
preload: 'none',
volume: 1,
mutex: true,
listFolded: true,
video: {
url: src,
}
});
} else {
setTimeout(function () {
html5DPlayer(randomid, ext, src, width, height);
}, 50);
}
}
$(document).ready(function() {
if(qSel('div.pg')) {
page.converthtml();
}
if(qSel('.scrolltop')) {
scrolltop.init(qSel('.scrolltop'));
}
if($('img').length > 0) {
img.init(1);
}
if($('.popup').length > 0) {
popup.init();
}
if($('.display').length > 0) {
display.init();
}
dialog.init();
formdialog.init();
});
function ajaxget(url, showid, waitid, loading, display, recall) {
var url = url + '&inajax=1&ajaxtarget=' + showid;
$.ajax({
type : 'GET',
url : url,
dataType : 'xml',
}).success(function(s) {
$('#'+showid).html(s.lastChild.firstChild.nodeValue);
$("[ajaxtarget]").off('click').on('click', function(e) {
var id = $(this);
ajaxget(id.attr('href'), id.attr('ajaxtarget'));
return false;
});
});
return false;
}
function getHost(url) {
var host = "null";
if(typeof url == "undefined"|| null == url) {
url = window.location.href;
}
var regex = /^\w+\:\/\/([^\/]*).*/;
var match = url.match(regex);
if(typeof match != "undefined" && null != match) {
host = match[1];
}
return host;
}
function hostconvert(url) {
if(!url.match(/^https?:\/\//)) url = SITEURL + url;
var url_host = getHost(url);
var cur_host = getHost().toLowerCase();
if(url_host && cur_host != url_host) {
url = url.replace(url_host, cur_host);
}
return url;
}
function Ajax(recvType, waitId) {
var aj = new Object();
aj.loading = '请稍候...';
aj.recvType = recvType ? recvType : 'XML';
aj.waitId = waitId ? $(waitId) : null;
aj.resultHandle = null;
aj.sendString = '';
aj.targetUrl = '';
aj.setLoading = function(loading) {
if(typeof loading !== 'undefined' && loading !== null) aj.loading = loading;
};
aj.setRecvType = function(recvtype) {
aj.recvType = recvtype;
};
aj.setWaitId = function(waitid) {
aj.waitId = typeof waitid == 'object' ? waitid : $(waitid);
};
aj.createXMLHttpRequest = function() {
var request = false;
if(window.XMLHttpRequest) {
request = new XMLHttpRequest();
if(request.overrideMimeType) {
request.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject) {
var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
for(var i=0; i<versions.length; i++) {
try {
request = new ActiveXObject(versions[i]);
if(request) {
return request;
}
} catch(e) {}
}
}
return request;
};
aj.XMLHttpRequest = aj.createXMLHttpRequest();
aj.showLoading = function() {
if(aj.waitId && (aj.XMLHttpRequest.readyState != 4 || aj.XMLHttpRequest.status != 200)) {
aj.waitId.style.display = '';
aj.waitId.innerHTML = '<span><div class="loadicon vm"></div> ' + aj.loading + '</span>';
}
};
aj.processHandle = function() {
if(aj.XMLHttpRequest.readyState == 4 && aj.XMLHttpRequest.status == 200) {
if(aj.waitId) {
aj.waitId.style.display = 'none';
}
if(aj.recvType == 'HTML') {
aj.resultHandle(aj.XMLHttpRequest.responseText, aj);
} else if(aj.recvType == 'XML') {
if(!aj.XMLHttpRequest.responseXML || !aj.XMLHttpRequest.responseXML.lastChild || aj.XMLHttpRequest.responseXML.lastChild.localName == 'parsererror') {
aj.resultHandle('' , aj);
} else {
aj.resultHandle(aj.XMLHttpRequest.responseXML.lastChild.firstChild.nodeValue, aj);
}
} else if(aj.recvType == 'JSON') {
var s = null;
try {
s = (new Function("return ("+aj.XMLHttpRequest.responseText+")"))();
} catch (e) {
s = null;
}
aj.resultHandle(s, aj);
}
}
};
aj.get = function(targetUrl, resultHandle) {
targetUrl = hostconvert(targetUrl);
setTimeout(function(){aj.showLoading()}, 250);
aj.targetUrl = targetUrl;
aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
aj.resultHandle = resultHandle;
var attackevasive = isUndefined(attackevasive) ? 0 : attackevasive;
if(window.XMLHttpRequest) {
aj.XMLHttpRequest.open('GET', aj.targetUrl);
aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
aj.XMLHttpRequest.send(null);
} else {
aj.XMLHttpRequest.open("GET", targetUrl, true);
aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
aj.XMLHttpRequest.send();
}
};
aj.post = function(targetUrl, sendString, resultHandle) {
targetUrl = hostconvert(targetUrl);
setTimeout(function(){aj.showLoading()}, 250);
aj.targetUrl = targetUrl;
aj.sendString = sendString;
aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
aj.resultHandle = resultHandle;
aj.XMLHttpRequest.open('POST', targetUrl);
aj.XMLHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
aj.XMLHttpRequest.send(aj.sendString);
};
aj.getJSON = function(targetUrl, resultHandle) {
aj.setRecvType('JSON');
aj.get(targetUrl+'&ajaxdata=json', resultHandle);
};
aj.getHTML = function(targetUrl, resultHandle) {
aj.setRecvType('HTML');
aj.get(targetUrl+'&ajaxdata=html', resultHandle);
};
return aj;
}
function portal_flowlazyload() {
var obj = this;
var times = 0;
var processing = false;
this.getOffset = function (el, isLeft) {
var retValue = 0 ;
while (el != null) {
retValue += el["offset" + (isLeft ? "Left" : "Top" )];
el = el.offsetParent;
}
return retValue;
};
this.attachEvent = function (obj, evt, func, eventobj) {
eventobj = !eventobj ? obj : eventobj;
if(obj.addEventListener) {
obj.addEventListener(evt, func, false);
} else if(eventobj.attachEvent) {
obj.attachEvent('on' + evt, func);
}
};
this.removeElement = function (_element) {
var _parentElement = _element.parentNode;
if(_parentElement) {
_parentElement.removeChild(_element);
}
};
this.showNextPage = function() {
var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
var offsetTop = this.getOffset(document.getElementsByClassName('page')[0]);
if (!processing && times <= 9 && offsetTop > document.documentElement.clientHeight && (offsetTop - scrollTop < document.documentElement.clientHeight)) {
processing = true;
times++;
var x = new Ajax();
x.get('portal.php?mod=index&page=' + ++flowpage + '&inajax=1', function(s) {
if(s.indexOf(mobnodata) !== -1) {
var infoli = s.match(/<li>([\w\W]+)<\/li>/g);
var pgdiv = s.match(/<div class="pg">([\w\W]+)<\/div>/g);
if (infoli !== null && pgdiv !== null) {
document.getElementsByClassName('wzlist')[0].insertAdjacentHTML('beforeend', infoli);
document.getElementsByClassName('page')[0].insertAdjacentHTML('afterend', pgdiv);
obj.removeElement(document.getElementsByClassName('page')[0]);
page.converthtml();
processing = false;
}
}
});
}
};
this.attachEvent(window, 'scroll', function(){obj.showNextPage();});
}
function explode(sep, string) {
return string.split(sep);
}
function setCopy(text, msg) {
var cp = document.createElement('textarea');
cp.style.fontSize = '12pt';
cp.style.border = '0';
cp.style.padding = '0';
cp.style.margin = '0';
cp.style.position = 'absolute';
cp.style.left = '-9999px';
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
cp.style.top = yPosition + 'px';
cp.setAttribute('readonly', '');
text = text.replace(/[\xA0]/g, ' ');
cp.value = text;
document.getElementById('append_parent').appendChild(cp);
cp.select();
cp.setSelectionRange(0, cp.value.length);
try {
var success = document.execCommand('copy', false, null);
} catch(e) {
var success = false;
}
document.getElementById('append_parent').removeChild(cp);
if (success) {
if (msg) {
popup.open(msg, 'alert');
}
} else if (BROWSER.ie) {
var r = clipboardData.setData('Text', text);
if (r) {
if (msg) {
popup.open(msg, 'alert');
}
} else {
popup.open('复制失败', 'alert');
}
} else {
popup.open('复制失败', 'alert');
}
}
function copycode(obj) {
setCopy(obj.textContent, '代码已复制到剪贴板');
}

View File

5
static/js/mobile/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3
static/js/player/aplayer.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
static/js/player/aplayer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
static/js/player/dplayer.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
static/js/player/dplayer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

6
static/js/player/flv.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

341
static/js/portal.js Normal file
View File

@@ -0,0 +1,341 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: portal.js 31313 2012-08-10 03:51:03Z zhangguosheng $
*/
function block_get_setting(classname, script, bid) {
var x = new Ajax();
x.get('portal.php?mod=portalcp&ac=block&op=setting&bid='+bid+'&classname='+classname+'&script='+script+'&inajax=1', function(s){
ajaxinnerhtml($('tbody_setting'), s);
});
}
function switch_blocktab(type) {
if(type == 'setting') {
$('blockformsetting').style.display = '';
$('blockformdata').style.display = 'none';
$('li_setting').className = 'a';
$('li_data').className = '';
} else {
$('blockformsetting').style.display = 'none';
$('blockformdata').style.display = '';
$('li_setting').className = '';
$('li_data').className = 'a';
}
}
function showpicedit(pre) {
pre = pre ? pre : 'pic';
if($(pre+'way_remote').checked) {
$(pre+'_remote').style.display = "block";
$(pre+'_upload').style.display = "none";
} else {
$(pre+'_remote').style.display = "none";
$(pre+'_upload').style.display = "block";
}
}
function block_show_thumbsetting(classname, styleid, bid) {
var x = new Ajax();
x.get('portal.php?mod=portalcp&ac=block&op=thumbsetting&classname='+classname+'&styleid='+styleid+'&bid='+bid+'&inajax=1', function(s){
ajaxinnerhtml($('tbody_thumbsetting'), s);
});
}
function block_showstyle(stylename) {
var el_span = $('span_'+stylename);
var el_value = $('value_' + stylename);
if (el_value.value == '1'){
el_value.value = '0';
el_span.className = "";
} else {
el_value.value = '1';
el_span.className = "a";
}
}
function block_pushitem(bid, itemid) {
var id = $('push_id').value;
var idtype = $('push_idtype').value;
if(id && idtype) {
var x = new Ajax();
x.get('portal.php?mod=portalcp&ac=block&op=push&&bid='+bid+'&itemid='+itemid+'&idtype='+idtype+'&id='+id+'&inajax=1', function(s){
ajaxinnerhtml($('tbody_pushcontent'), s);
evalscript(s);
});
}
}
function block_delete_item(bid, itemid, itemtype, itemfrom, from) {
var msg = itemtype==1 ? '您确定要删除该数据吗?' : '您确定要屏蔽该数据吗?';
if(confirm(msg)) {
var url = 'portal.php?mod=portalcp&ac=block&op=remove&bid='+bid+'&itemid='+itemid;
if(itemfrom=='ajax') {
var x = new Ajax();
x.get(url+'&inajax=1', function(){
if(succeedhandle_showblock) succeedhandle_showblock('', '', {'bid':bid});
showWindow('showblock', 'portal.php?mod=portalcp&ac=block&op=data&bid='+bid+'&from='+from+'&tab=data&t='+(+ new Date()), 'get', 0);
});
} else {
location.href = url;
}
}
doane();
}
function portal_comment_requote(cid, aid) {
var x = new Ajax();
x.get('portal.php?mod=portalcp&ac=comment&op=requote&cid='+cid+'&aid='+aid+'&inajax=1', function(s){
$('message').focus();
ajaxinnerhtml($('message'), s);
});
}
function insertImage(text) {
text = "\n[img]" + text + "[/img]\n";
insertContent('message', text);
}
function insertContent(target, text) {
var obj = $(target);
selection = document.selection;
checkFocus(target);
if(!isUndefined(obj.selectionStart)) {
var opn = obj.selectionStart + 0;
obj.value = obj.value.substr(0, obj.selectionStart) + text + obj.value.substr(obj.selectionEnd);
} else if(selection && selection.createRange) {
var sel = selection.createRange();
sel.text = text;
sel.moveStart('character', -strlen(text));
} else {
obj.value += text;
}
}
function searchblock(from) {
var value = $('searchkey').value;
var targettplname = $('targettplname').value;
value = BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(value) : (value ? value.replace(/#/g,'%23') : '');
var url = 'portal.php?mod=portalcp&ac=portalblock&searchkey='+value+'&from='+from;
url += targettplname != '' ? '&targettplname='+targettplname+'&type=page' : '&type=block';
reloadselection(url);
}
function reloadselection(url) {
ajaxget(url+'&t='+(+ new Date()), 'block_selection');
}
function getColorPalette(colorid, id, background) {
return "<input id=\"c"+colorid+"\" onclick=\"createPalette('"+colorid+"', '"+id+"');\" type=\"button\" class=\"pn colorwd\" value=\"\" style=\"background-color: "+background+"\">";
}
function listblock_bypage(id, idtype) {
var tpl = $('rtargettplname') ? $('rtargettplname').value : '';
var searchkey = $('rsearchkey') ? $('rsearchkey').value.replace('#', '%23') : '';
ajaxget('portal.php?mod=portalcp&ac=portalblock&op=recommend&getdata=yes&searchkey='+searchkey+'&targettplname='+tpl+'&id='+id+'&idtype='+idtype, 'itemeditarea');
}
function recommenditem_check() {
var sel = $('recommend_bid');
if(sel && sel.value) {
document.forms['recommendform'].action = document.forms['recommendform'].action+'&bid='+sel.value;
return true;
} else {
alert("请选择一个模块!");
return false;
}
}
function recommenditem_byblock(bid, id, idtype) {
var editarea = $('itemeditarea');
if(editarea) {
var olditemeditarea = $('olditemeditarea');
ajaxinnerhtml(olditemeditarea, editarea.innerHTML);
if(!$('recommendback')) {
var back = document.createElement('div');
back.innerHTML = '<em id="recommendback" onclick="recommenditem_back()" class="cur1">&nbsp;&nbsp;&laquo;返回</em>';
var return_mods = $('return_mods') || $('return_recommend') || $('return_');
if(return_mods) {
return_mods.parentNode.appendChild(back.childNodes[0]);
}
}
if(bid) {
if($('recommend_bid')) {
$('recommend_bid').value = bid;
}
ajaxget('portal.php?mod=portalcp&ac=block&op=recommend&bid='+bid+'&id='+id+'&idtype='+idtype+'&handlekey=recommenditem', 'itemeditarea');
} else {
ajaxinnerhtml(editarea, '<tr><td>&nbsp;</td><td>&nbsp;</td></tr>');
}
}
}
function delete_recommenditem(dataid, bid) {
if(dataid && bid) {
var x = new Ajax();
x.get('portal.php?mod=portalcp&ac=block&op=delrecommend&bid='+bid+'&dataid='+dataid+'&inajax=1', function(s){
$('recommenditem_'+dataid).parentNode.removeChild($('recommenditem_'+dataid));
if(!$('recommenditem_ul').getElementsByTagName('li').length) {
$('hasinblocks').parentNode.removeChild($('hasinblocks'));
}
});
}
}
function recommenditem_back(){
var editarea = $('itemeditarea');
var oldeditarea = $('olditemeditarea');
var recommendback = $('recommendback');
if(oldeditarea){
ajaxinnerhtml(editarea, oldeditarea.innerHTML);
ajaxupdateevents(editarea);
}
if(recommendback) {
recommendback.parentNode.removeChild(recommendback);
}
if($('recommend_bid')) {
$('recommend_bid').value = '';
}
}
function blockBindTips() {
var elems = ($('blockformsetting') || document).getElementsByTagName('img');
var k = 0;
var stamp = (+new Date());
var tips = '';
for(var i = 0; i < elems.length; i++) {
tips = elems[i]['tips'] || elems[i].getAttribute('tips') || '';
if(tips && ! elems[i].isBindTips) {
elems[i].isBindTips = '1';
elems[i].id = elems[i].id ? elems[i].id : ('elem_' + stamp + k.toString());
k++;
showPrompt(elems[i].id, 'mouseover', tips, 1, true);
}
}
}
function blockSetCacheTime(timer) {
$('txt_cachetime').value=timer;
doane();
}
function toggleSettingShow() {
if(!$('tbody_setting').style.display) {
$('tbody_setting').style.display = 'none';
$('a_setting_show').innerHTML = '展开设置项';
} else {
$('tbody_setting').style.display = '';
$('a_setting_show').innerHTML = '收起设置项';
}
doane();
}
function switchSetting() {
var checked = $('isblank').checked;
if(checked) {
$('tbody_setting').style.display = 'none';
$('a_setting_show').innerHTML = '展开设置项';
} else {
$('tbody_setting').style.display = '';
$('a_setting_show').innerHTML = '收起设置项';
}
}
function checkblockname(form) {
if(!(trim(form.name.value) > '')) {
showDialog('模块标识不能为空', 'error', null, function(){form.name.focus();});
return false;
}
if(form.summary && form.summary.value) {
var tag = blockCheckTag(form.summary.value, true);
if(tag) {
showBlockSummary();
form.summary.focus();
showDialog('自定义内容错误HTML代码'+tag+' 标签不匹配', 'error', null, function(){form.summary.select();});
return false;
}
}
return true;
}
function blockCheckTag(summary, returnValue) {
var obj = null, fn = null;
if(typeof summary == 'object') {
obj = summary;
summary = summary.value;
fn = function(){obj.focus();obj.select();};
}
if(trim(summary) > '') {
var tags = ['div', 'table', 'tbody', 'tr', 'td', 'th'];
for(var i = 0; i < tags.length; i++) {
var tag = tags[i];
var reg = new RegExp('<'+tag+'', 'gi');
var preTag = [];
var one = [];
while (one = reg.exec(summary)) {
preTag.push(one[0]);
}
reg = new RegExp('</'+tag+'>', 'gi');
var endTag = [];
var one = [];
while (one = reg.exec(summary)) {
endTag.push(one[0]);
}
if(!preTag && !endTag) continue;
if((!preTag && endTag) || (preTag && !endTag) || preTag.length != endTag.length) {
if(returnValue) {
return tag;
} else {
showDialog('HTML代码'+tag+' 标签不匹配', 'error', null, fn, true, fn);
return false;
}
}
}
}
return false;
}
function showBlockSummary() {
$('block_sumamry_content').style.display='';
$('a_summary_show').style.display='none';
$('a_summary_hide').style.display='';
return false;
}
function hideBlockSummary() {
$('block_sumamry_content').style.display='none';
$('a_summary_hide').style.display='none';
$('a_summary_show').style.display='';
return false;
}
function blockconver(ele,bid) {
if(ele && bid) {
if(confirm('您确定要转换模块的类型从 '+ele.options[0].innerHTML+' 到 '+ele.options[ele.selectedIndex].innerHTML)) {
ajaxget('portal.php?mod=portalcp&ac=block&op=convert&bid='+bid+'&toblockclass='+ele.value,'blockshow');
} else {
ele.selectedIndex = 0;
}
}
}
function blockFavorite(bid){
if(bid) {
ajaxget('portal.php?mod=portalcp&ac=block&op=favorite&bid='+bid,'bfav_'+bid);
}
}
function check_itemdata_lentgh(form) {
if(form.title && (!strLenCalc(form.title, "titlechk", form.title.getAttribute('_maxlength')) || !form.title.value)) {
form.title.focus();
showDialog('标题长度不正确', 'error', null, function(){form.title.select();});
return false;
}
if(form.summary && !strLenCalc(form.summary, "summarychk", form.summary.getAttribute('_maxlength'))) {
form.summary.focus();
showDialog('简介长度不正确', 'error', null, function(){form.summary.select();});
return false;
}
return true;
}

1086
static/js/portal_diy.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: portal_diy_data.js 24360 2011-09-14 08:38:06Z zhangguosheng $
*/
var drag = new Drag();
drag.extend({
'getBlocksTimer' : '',
'blocks' : [],
'blockDefaultClass' : [],
'frameDefaultClass' : [],
setSampleMenu : function () {
this.addMenu('block', '数据', 'drag.openBlockEdit(event,"data")');
this.addMenu('block', '更新', 'drag.blockForceUpdate(event)');
},
openBlockEdit : function (e,op) {
e = Util.event(e);
op = (op=='data') ? 'data' : 'block';
var bid = e.aim.id.replace('cmd_portal_block_','');
this.removeMenu();
showWindow('showblock', 'portal.php?mod=portalcp&ac=block&op='+op+'&bid='+bid+'&tpl='+document.diyform.template.value, 'get', -1);
},
getBlockData : function (blockname) {
var bid = this.dragObj.id;
var eleid = bid;
if (bid.indexOf('portal_block_') != -1) {
eleid = 0;
}else {
bid = 0;
}
showWindow('showblock', 'portal.php?mod=portalcp&ac=block&op=block&classname='+blockname+'&bid='+bid+'&eleid='+eleid+'&tpl='+document.diyform.template.value,'get',-1);
drag.initPosition();
this.fn = '';
return true;
},
stopSlide : function (id) {
if (typeof slideshow == 'undefined' || typeof slideshow.entities == 'undefined') return false;
var slidebox = $C('slidebox',$(id));
if(slidebox && slidebox.length > 0) {
if(slidebox[0].id) {
var timer = slideshow.entities[slidebox[0].id].timer;
if(timer) clearTimeout(timer);
slideshow.entities[slidebox[0].id] = '';
}
}
},
init : function (sampleMode) {
this.initCommon();
$('samplepanel').innerHTML = '可直接管理模块数据 [<a href="javascript:;" onclick="spaceDiy.cancel();return false;" class="xi2">退出</a>]';
this.setSampleMode(sampleMode);
this.initSample();
return true;
},
setClose : function () {},
blockForceUpdate : function (e,all) {
if ( typeof e !== 'string') {
e = Util.event(e);
var id = e.aim.id.replace('cmd_','');
} else {
var id = e;
}
if ($(id) == null) return false;
var bid = id.replace('portal_block_', '');
var bcontent = $(id+'_content');
if (!bcontent) {
bcontent = document.createElement('div');
bcontent.id = id+'_content';
bcontent.className = this.contentClass;
}
this.stopSlide(id);
var height = Util.getFinallyStyle(bcontent, 'height');
bcontent.style.lineHeight = height == 'auto' ? '' : (height == '0px' ? '20px' : height);
var boldcontent = bcontent.innerHTML;
bcontent.innerHTML = '<center>正在加载内容...</center>';
var x = new Ajax();
x.get('portal.php?mod=portalcp&ac=block&op=getblock&forceupdate=1&inajax=1&bid='+bid+'&tpl='+document.diyform.template.value, function(s) {
if(s.indexOf('errorhandle_') != -1) {
bcontent.innerHTML = boldcontent;
runslideshow();
showDialog('抱歉,您没有权限添加或编辑模块', 'alert');
doane();
} else {
var obj = document.createElement('div');
obj.innerHTML = s;
bcontent.parentNode.removeChild(bcontent);
$(id).innerHTML = obj.childNodes[0].innerHTML;
evalscript(s);
if(s.indexOf('runslideshow()') != -1) {runslideshow();}
drag.initPosition();
if (all) {drag.getBlocks();}
}
});
}
});
var spaceDiy = new DIY();
spaceDiy.init(1);
function succeedhandle_diyform (url, message, values) {
if (values['rejs'] == '1') {
document.diyform.rejs.value = '';
parent.$('preview_form').submit();
}
spaceDiy.enablePreviewButton();
return false;
}

View File

@@ -0,0 +1,68 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: portal_upload.js 32590 2013-02-22 09:42:48Z monkey $
*/
var nowid = 0;
var extensions = '';
function addAttach() {
var newnode = $('upload').cloneNode(true);
var id = nowid;
var tags;
newnode.id = 'upload_' + id;
tags = newnode.getElementsByTagName('input');
for(i = 0;i < tags.length;i++) {
if(tags[i].name == 'attach') {
tags[i].id = 'attach_' + id;
tags[i].name = 'attach';
tags[i].onchange = function() {this.form.action = this.form.action.replace(/catid\=\d/, 'catid='+$('catid').value);insertAttach(id)};
tags[i].unselectable = 'on';
}
}
tags = newnode.getElementsByTagName('span');
for(i = 0;i < tags.length;i++) {
if(tags[i].id == 'localfile') {
tags[i].id = 'localfile_' + id;
}
}
nowid++;
$('attachbody').appendChild(newnode);
}
function insertAttach(id) {
var path = $('attach_' + id).value;
if(path == '') {
return;
}
var ext = path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
if(extensions != '' && (re.exec(extensions) == null || ext == '')) {
alert('对不起,不支持上传此类文件');
return;
}
var localfile = $('attach_' + id).value.substr($('attach_' + id).value.replace(/\\/g, '/').lastIndexOf('/') + 1);
$('localfile_' + id).innerHTML = localfile + ' 上传中...';
$('attach_' + id).style.display = 'none';
$('upload_' + id).action += '&attach_target_id=' + id;
$('upload_' + id).submit();
addAttach();
}
function deleteAttach(attachid, url) {
ajaxget(url);
$('attach_list_' + attachid).style.display = 'none';
}
function setConver(attach) {
$('conver').value = attach;
}
addAttach();

View File

1
static/js/qrcode/qrcode.min.js vendored Normal file

File diff suppressed because one or more lines are too long

83
static/js/redef.js Normal file
View File

@@ -0,0 +1,83 @@
/*
参数
parent 放置瀑布流元素的容器,默认为 $("waterfall")
container 放置瀑布流的父容器,默认为 $("threadlist")
maxcolumn 最多多少列,默认为 0 不限制
space 图片间距,默认为 10
index 从第几张开始排列,默认为 0
tag 瀑布流元素的 tagName默认为 li
columnsheight 存放列高度的数组
返回值
index 当前瀑布流已经排列了多少个图片
totalwidth 当前瀑布流的总宽度
totalheight 当前瀑布流的总高度
columnsheight 存放瀑布流列高的数组
*/
function waterfall(v) {
var v = typeof(v) == "undefined" ? {} : v;
var column = 1;
var totalwidth = typeof(v.totalwidth) == "undefined" ? 0 : v.totalwidth;
var totalheight = typeof(v.totalheight) == "undefined" ? 0 : v.totalheight;
var parent = typeof(v.parent) == "undefined" ? $("waterfall") : v.parent;
var container = typeof(v.container) == "undefined" ? $("threadlist") : v.container;
var maxcolumn = typeof(v.maxcolumn) == "undefined" ? 0 : v.maxcolumn;
var space = typeof(v.space) == "undefined" ? 10 : v.space;
var index = typeof(v.index) == "undefined" ? 0 : v.index;
var tag = typeof(v.tag) == "undefined" ? "li" : v.tag;
var columnsheight = typeof(v.columnsheight) == "undefined" ? [] : v.columnsheight;
function waterfallMin() {
var min = 0;
var index = 0;
if(columnsheight.length > 0) {
min = Math.min.apply({}, columnsheight);
for(var i = 0, j = columnsheight.length; i < j; i++) {
if(columnsheight[i] == min) {
index = i;
break;
}
}
}
return {"value": min, "index": index};
}
function waterfallMax() {
return Math.max.apply({}, columnsheight);
}
var mincolumn = {"value": 0, "index": 0};
var totalelem = [];
var singlewidth = 0;
totalelem = parent.getElementsByTagName(tag);
if(totalelem.length > 0) {
column = Math.floor((container.offsetWidth - space) / (totalelem[0].offsetWidth + space));
if(maxcolumn && column > maxcolumn) {
column = maxcolumn;
}
if(!column) {
column = 1;
}
if(columnsheight.length != column) {
columnsheight = [];
for(var i = 0; i < column; i++) {
columnsheight[i] = 0;
}
index = 0;
}
singlewidth = totalelem[0].offsetWidth + space;
totalwidth = singlewidth * column - space;
for(var i = index, j = totalelem.length; i < j; i++) {
mincolumn = waterfallMin();
totalelem[i].style.position = "absolute";
totalelem[i].style.left = singlewidth * mincolumn.index + "px";
totalelem[i].style.top = mincolumn.value + "px";
columnsheight[mincolumn.index] = columnsheight[mincolumn.index] + totalelem[i].offsetHeight + space;
totalheight = Math.max(totalheight, waterfallMax());
index++;
}
parent.style.height = totalheight + "px";
parent.style.width = totalwidth + "px";
}
return {"index": index, "totalwidth": totalwidth, "totalheight": totalheight, "columnsheight" : columnsheight};
}

375
static/js/register.js Normal file
View File

@@ -0,0 +1,375 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: register.js 33433 2013-06-13 07:36:25Z nemohou $
*/
var lastusername = '', lastpassword = '', lastemail = '', lastinvitecode = '', stmp = new Array(), modifypwd = false, profileTips = '如不需要更改密码,此处请留空';
function errormessage(id, msg) {
if($(id)) {
try{
showInputTip();
} catch (e) {}
msg = !msg ? '' : msg;
if($('tip_' + id)) {
if(msg == 'succeed') {
msg = '';
$('tip_' + id).parentNode.className = $('tip_' + id).parentNode.className.replace(/ p_right/, '');
$('tip_' + id).parentNode.className += ' p_right';
} else if(msg !== '') {
$('tip_' + id).parentNode.className = $('tip_' + id).parentNode.className.replace(/ p_right/, '');
}
}
if($('chk_' + id)) {
$('chk_' + id).innerHTML = msg;
}
$(id).className = $(id).className.replace(/ er/, '');
$(id).className += !msg ? '' : ' er';
}
}
function addFormEvent(formid, focus){
var si = 0;
var formNode = $(formid).getElementsByTagName('input');
for(i = 0;i < formNode.length;i++) {
if(formNode[i].name == '') {
formNode[i].name = formNode[i].id;
stmp[si] = i;
si++;
}
if(formNode[i].type == 'text' || formNode[i].type == 'password'){
formNode[i].onfocus = function(){
showInputTip(!this.id ? this.name : this.id);
}
}
}
if(!si) {
return;
}
formNode[stmp[0]].onblur = function () {
checkusername(formNode[stmp[0]].id);
};
checkPwdComplexity(formNode[stmp[1]], formNode[stmp[2]]);
try {
if(!ignoreEmail) {
addMailEvent(formNode[stmp[3]]);
}
} catch(e) {}
try {
if(focus) {
$('invitecode').focus();
} else {
formNode[stmp[0]].focus();
}
} catch(e) {}
}
function checkPwdComplexity(firstObj, secondObj, modify) {
modifypwd = modify || false;
firstObj.onblur = function () {
if(firstObj.value == '') {
var pwmsg = !modifypwd ? '请填写密码' : profileTips;
if(pwlength > 0) {
pwmsg += ', 最小长度为 '+pwlength+' 个字符';
}
errormessage(firstObj.id, pwmsg);
}else{
errormessage(firstObj.id, !modifypwd ? 'succeed' : '');
}
checkpassword(firstObj.id, secondObj.id);
};
firstObj.onkeyup = function () {
if(pwlength == 0 || $(firstObj.id).value.length >= pwlength) {
var passlevels = new Array('','弱','中','强');
var passlevel = checkstrongpw(firstObj.id);
errormessage(firstObj.id, '<span class="passlevel passlevel'+passlevel+'">密码强度:'+passlevels[passlevel]+'</span>');
}
};
secondObj.onblur = function () {
if(secondObj.value == '') {
errormessage(secondObj.id, !modifypwd ? '请再次输入密码' : profileTips);
}
checkpassword(firstObj.id, secondObj.id);
};
}
function addMailEvent(mailObj) {
mailObj.onclick = function (event) {
emailMenu(event, mailObj.id);
};
mailObj.onkeyup = function (event) {
emailMenu(event, mailObj.id);
};
mailObj.onkeydown = function (event) {
emailMenuOp(4, event, mailObj.id);
};
mailObj.onblur = function () {
if(mailObj.value == '') {
errormessage(mailObj.id, '请输入邮箱地址');
}
emailMenuOp(3, null, mailObj.id);
};
stmp['email'] = mailObj.id;
}
function checkstrongpw(id) {
var passlevel = 0;
if($(id).value.match(/\d+/g)) {
passlevel ++;
}
if($(id).value.match(/[a-z]+/ig)) {
passlevel ++;
}
if($(id).value.match(/[^a-z0-9]+/ig)) {
passlevel ++;
}
return passlevel;
}
function showInputTip(id) {
var p_tips = $('registerform').getElementsByTagName('i');
for(i = 0;i < p_tips.length;i++){
if(p_tips[i].className == 'p_tip'){
p_tips[i].style.display = 'none';
}
}
if($('tip_' + id)) {
$('tip_' + id).style.display = 'block';
}
}
function showbirthday(){
var el = $('birthday');
var birthday = el.value;
el.length=0;
el.options.add(new Option('日', ''));
for(var i=0;i<28;i++){
el.options.add(new Option(i+1, i+1));
}
if($('birthmonth').value!="2"){
el.options.add(new Option(29, 29));
el.options.add(new Option(30, 30));
switch($('birthmonth').value){
case "1":
case "3":
case "5":
case "7":
case "8":
case "10":
case "12":{
el.options.add(new Option(31, 31));
}
}
} else if($('birthyear').value!="") {
var nbirthyear=$('birthyear').value;
if(nbirthyear%400==0 || (nbirthyear%4==0 && nbirthyear%100!=0)) el.options.add(new Option(29, 29));
}
el.value = birthday;
}
function trim(str) {
return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
}
var emailMenuST = null, emailMenui = 0, emaildomains = ['qq.com', '163.com', 'sina.com', 'sohu.com', 'yahoo.com', 'gmail.com', 'hotmail.com'];
function emailMenuOp(op, e, id) {
if(op == 3 && BROWSER.ie && BROWSER.ie < 7) {
checkemail(id);
}
if(!$('emailmore_menu')) {
return;
}
if(op == 1) {
$('emailmore_menu').style.display = 'none';
} else if(op == 2) {
showMenu({'ctrlid':'emailmore','pos': '13!'});
} else if(op == 3) {
emailMenuST = setTimeout(function () {
emailMenuOp(1, id);
checkemail(id);
}, 500);
} else if(op == 4) {
e = e ? e : window.event;
var obj = $(id);
if(e.keyCode == 13 && obj.value.indexOf('@') == -1) {
obj.value = obj.value + '@' + emaildomains[emailMenui];
doane(e);
}
} else if(op == 5) {
var as = $('emailmore_menu').getElementsByTagName('a');
for(i = 0;i < as.length;i++){
as[i].className = '';
}
}
}
function emailMenu(e, id) {
if(BROWSER.ie && BROWSER.ie < 7) {
return;
}
e = e ? e : window.event;
var obj = $(id);
if(obj.value.indexOf('@') != -1) {
$('emailmore_menu').style.display = 'none';
return;
}
var value = e.keyCode;
var v = obj.value;
if(!obj.value.length) {
emailMenuOp(1);
return;
}
if(value == 40) {
emailMenui++;
if(emailMenui >= emaildomains.length) {
emailMenui = 0;
}
} else if(value == 38) {
emailMenui--;
if(emailMenui < 0) {
emailMenui = emaildomains.length - 1;
}
} else if(value == 13) {
$('emailmore_menu').style.display = 'none';
return;
}
if(!$('emailmore_menu')) {
menu = document.createElement('div');
menu.id = 'emailmore_menu';
menu.style.display = 'none';
menu.className = 'p_pop';
menu.setAttribute('disautofocus', true);
$('append_parent').appendChild(menu);
}
var s = '<ul>';
for(var i = 0; i < emaildomains.length; i++) {
s += '<li><a href="javascript:;" onmouseover="emailMenuOp(5)" ' + (emailMenui == i ? 'class="a" ' : '') + 'onclick="$(stmp[\'email\']).value=this.innerHTML;display(\'emailmore_menu\');checkemail(stmp[\'email\']);">' + v + '@' + emaildomains[i] + '</a></li>';
}
s += '</ul>';
$('emailmore_menu').innerHTML = s;
emailMenuOp(2);
}
function checksubmit() {
var p_chks = $('registerform').getElementsByTagName('kbd');
for(i = 0;i < p_chks.length;i++){
if(p_chks[i].className == 'p_chk'){
p_chks[i].innerHTML = '';
}
}
ajaxpost('registerform', 'returnmessage4', 'returnmessage4', 'onerror');
return;
}
function checkusername(id) {
errormessage(id);
var username = trim($(id).value);
if($('tip_' + id).parentNode.className.match(/ p_right/) && (username == '' || username == lastusername)) {
return;
} else {
lastusername = username;
}
if(username.match(/<|>|"|\(|\)|'/ig)) {
errormessage(id, '用户名包含敏感字符');
return;
}
var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
if(unlen < 3 || unlen > 15) {
errormessage(id, unlen < 3 ? '用户名不得小于 3 个字符' : '用户名不得超过 15 个字符');
return;
}
var x = new Ajax();
$('tip_' + id).parentNode.className = $('tip_' + id).parentNode.className.replace(/ p_right/, '');
x.get('forum.php?mod=ajax&inajax=yes&infloat=register&handlekey=register&ajaxmenu=1&action=checkusername&username=' + (BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(username) : username.replace(/%/g, '%25').replace(/#/g, '%23')), function(s) {
errormessage(id, s);
});
}
function checkpassword(id1, id2) {
if(!$(id1).value && !$(id2).value) {
return;
}
if(pwlength > 0) {
if($(id1).value.length < pwlength) {
errormessage(id1, '密码太短,不得少于 '+pwlength+' 个字符');
return;
}
}
if(strongpw) {
var strongpw_error = false, j = 0;
var strongpw_str = new Array();
for(var i in strongpw) {
if(strongpw[i] === 1 && !$(id1).value.match(/\d+/g)) {
strongpw_error = true;
strongpw_str[j] = '数字';
j++;
}
if(strongpw[i] === 2 && !$(id1).value.match(/[a-z]+/g)) {
strongpw_error = true;
strongpw_str[j] = '小写字母';
j++;
}
if(strongpw[i] === 3 && !$(id1).value.match(/[A-Z]+/g)) {
strongpw_error = true;
strongpw_str[j] = '大写字母';
j++;
}
if(strongpw[i] === 4 && !$(id1).value.match(/[^A-Za-z0-9]+/g)) {
strongpw_error = true;
strongpw_str[j] = '特殊符号';
j++;
}
}
if(strongpw_error) {
errormessage(id1, '密码太弱,密码中必须包含 '+strongpw_str.join(''));
return;
}
}
errormessage(id2);
if($(id1).value != $(id2).value) {
errormessage(id2, '两次输入的密码不一致');
} else {
errormessage(id2, !modifypwd ? 'succeed' : '');
}
}
function checkemail(id) {
errormessage(id);
var email = trim($(id).value);
if($(id).parentNode.className.match(/ p_right/) && (email == '' || email == lastemail)) {
return;
} else {
lastemail = email;
}
if(email.match(/<|"/ig)) {
errormessage(id, 'Email 包含敏感字符');
return;
}
var x = new Ajax();
$('tip_' + id).parentNode.className = $('tip_' + id).parentNode.className.replace(/ p_right/, '');
x.get('forum.php?mod=ajax&inajax=yes&infloat=register&handlekey=register&ajaxmenu=1&action=checkemail&email=' + email, function(s) {
errormessage(id, s);
});
}
function checkinvite() {
errormessage('invitecode');
var invitecode = trim($('invitecode').value);
if(invitecode == '' || invitecode == lastinvitecode) {
return;
} else {
lastinvitecode = invitecode;
}
if(invitecode.match(/<|"/ig)) {
errormessage('invitecode', '邀请码包含敏感字符');
return;
}
var x = new Ajax();
$('tip_invitecode').parentNode.className = $('tip_invitecode').parentNode.className.replace(/ p_right/, '');
x.get('forum.php?mod=ajax&inajax=yes&infloat=register&handlekey=register&ajaxmenu=1&action=checkinvitecode&invitecode=' + invitecode, function(s) {
errormessage('invitecode', s);
});
}

154
static/js/seditor.js Normal file
View File

@@ -0,0 +1,154 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: seditor.js 28601 2012-03-06 02:49:55Z monkey $
*/
function seditor_showimgmenu(seditorkey) {
var imgurl = $(seditorkey + '_image_param_1').value;
var width = parseInt($(seditorkey + '_image_param_2').value);
var height = parseInt($(seditorkey + '_image_param_3').value);
var extparams = '';
if(width || height) {
extparams = '=' + width + ',' + height
}
seditor_insertunit(seditorkey, '[img' + extparams + ']' + imgurl, '[/img]', null, 1);
$(seditorkey + '_image_param_1').value = '';
hideMenu();
}
function seditor_menu(seditorkey, tag) {
var sel = false;
if(!isUndefined($(seditorkey + 'message').selectionStart)) {
sel = $(seditorkey + 'message').selectionEnd - $(seditorkey + 'message').selectionStart;
} else if(document.selection && document.selection.createRange) {
$(seditorkey + 'message').focus();
var sel = document.selection.createRange();
$(seditorkey + 'message').sel = sel;
sel = sel.text ? true : false;
}
if(sel) {
seditor_insertunit(seditorkey, '[' + tag + ']', '[/' + tag + ']');
return;
}
var ctrlid = seditorkey + tag;
var menuid = ctrlid + '_menu';
if(!$(menuid)) {
switch(tag) {
case 'at':
curatli = 0;
atsubmitid = ctrlid + '_submit';
setTimeout(function() {atFilter('', 'at_list','atListSet');$('atkeyword').focus();}, 100);
str = '请输用户名:<br /><input type="text" id="atkeyword" style="width:240px" value="" class="px" onkeydown="atFilter(this.value, \'at_list\',\'atListSet\',event);" /><div class="p_pop" id="at_list" style="width:250px;"><ul><li>@朋友账号,就能提醒他来看文章</li></ul></div>';
submitstr = 'seditor_insertunit(\'' + seditorkey + '\', \'@\' + $(\'atkeyword\').value.replace(/<\\/?b>/g, \'\')+\' \'); hideMenu();';
break;
case 'url':
str = '请输入链接地址:<br /><input type="text" id="' + ctrlid + '_param_1" sautocomplete="off" style="width: 98%" value="" class="px" />' +
'<br />请输入链接文字:<br /><input type="text" id="' + ctrlid + '_param_2" style="width: 98%" value="" class="px" />';
submitstr = "$('" + ctrlid + "_param_2').value !== '' ? seditor_insertunit('" + seditorkey + "', '[url='+seditor_squarestrip($('" + ctrlid + "_param_1').value)+']'+$('" + ctrlid + "_param_2').value, '[/url]', null, 1) : seditor_insertunit('" + seditorkey + "', '[url]'+$('" + ctrlid + "_param_1').value, '[/url]', null, 1);hideMenu();";
break;
case 'code':
case 'quote':
var tagl = {'quote' : '请输入要插入的引用', 'code' : '请输入要插入的代码'};
str = tagl[tag] + ':<br /><textarea id="' + ctrlid + '_param_1" style="width: 98%" cols="50" rows="5" class="txtarea"></textarea>';
submitstr = "seditor_insertunit('" + seditorkey + "', '[" + tag + "]'+$('" + ctrlid + "_param_1').value, '[/" + tag + "]', null, 1);hideMenu();";
break;
case 'img':
str = '请输入图片地址:<br /><input type="text" id="' + ctrlid + '_param_1" style="width: 98%" value="" class="px" onchange="loadimgsize(this.value, \'' + seditorkey + '\',\'' + tag + '\')" />' +
'<p class="mtm">宽(可选): <input type="text" id="' + ctrlid + '_param_2" style="width: 15%" value="" class="px" /> &nbsp;' +
'高(可选): <input type="text" id="' + ctrlid + '_param_3" style="width: 15%" value="" class="px" /></p>';
submitstr = "seditor_insertunit('" + seditorkey + "', '[img' + ($('" + ctrlid + "_param_2').value !== '' && $('" + ctrlid + "_param_3').value !== '' ? '='+$('" + ctrlid + "_param_2').value+','+$('" + ctrlid + "_param_3').value : '')+']'+seditor_squarestrip($('" + ctrlid + "_param_1').value), '[/img]', null, 1);hideMenu();";
break;
}
var menu = document.createElement('div');
menu.id = menuid;
menu.style.display = 'none';
menu.className = 'p_pof upf';
menu.style.width = '270px';
$('append_parent').appendChild(menu);
menu.innerHTML = '<span class="y"><a onclick="hideMenu()" class="flbc" href="javascript:;">关闭</a></span><div class="p_opt cl"><form onsubmit="' + submitstr + ';return false;" autocomplete="off"><div>' + str + '</div><div class="pns mtn"><button type="submit" id="' + ctrlid + '_submit" class="pn pnc"><strong>提交</strong></button><button type="button" onClick="hideMenu()" class="pn"><em>取消</em></button></div></form></div>';
}
showMenu({'ctrlid':ctrlid,'evt':'click','duration':3,'cache':0,'drag':1});
}
function seditor_squarestrip(str) {
str = str.replace('[', '%5B');
str = str.replace(']', '%5D');
return str;
}
function seditor_insertunit(key, text, textend, moveend, selappend) {
if($(key + 'message')) {
$(key + 'message').focus();
}
textend = isUndefined(textend) ? '' : textend;
moveend = isUndefined(textend) ? 0 : moveend;
selappend = isUndefined(selappend) ? 1 : selappend;
startlen = strlen(text);
endlen = strlen(textend);
if(!isUndefined($(key + 'message').selectionStart)) {
if(selappend) {
var opn = $(key + 'message').selectionStart + 0;
if(textend != '') {
text = text + $(key + 'message').value.substring($(key + 'message').selectionStart, $(key + 'message').selectionEnd) + textend;
}
$(key + 'message').value = $(key + 'message').value.substr(0, $(key + 'message').selectionStart) + text + $(key + 'message').value.substr($(key + 'message').selectionEnd);
if(!moveend) {
$(key + 'message').selectionStart = opn + strlen(text) - endlen;
$(key + 'message').selectionEnd = opn + strlen(text) - endlen;
}
} else {
text = text + textend;
$(key + 'message').value = $(key + 'message').value.substr(0, $(key + 'message').selectionStart) + text + $(key + 'message').value.substr($(key + 'message').selectionEnd);
}
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(!sel.text.length && $(key + 'message').sel) {
sel = $(key + 'message').sel;
$(key + 'message').sel = null;
}
if(selappend) {
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
if(!moveend) {
sel.moveStart('character', -endlen);
sel.moveEnd('character', -endlen);
}
sel.select();
} else {
sel.text = text + textend;
}
} else {
$(key + 'message').value += text;
}
hideMenu(2);
if(BROWSER.ie) {
doane();
}
}
function seditor_ctlent(event, script) {
if(event.ctrlKey && event.keyCode == 13 || event.altKey && event.keyCode == 83) {
eval(script);
}
}
function loadimgsize(imgurl, editor, p) {
var editor = !editor ? editorid : editor;
var s = new Object();
var p = !p ? '_image' : p;
s.img = new Image();
s.img.src = imgurl;
s.loadCheck = function () {
if(s.img.complete) {
$(editor + p + '_param_2').value = s.img.width ? s.img.width : '';
$(editor + p + '_param_3').value = s.img.height ? s.img.height : '';
} else {
setTimeout(function () {s.loadCheck();}, 100);
}
};
s.loadCheck();
}

129
static/js/smilies.js Normal file
View File

@@ -0,0 +1,129 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: smilies.js 29684 2012-04-25 04:00:58Z zhangguosheng $
*/
function _smilies_show(id, smcols, seditorkey) {
if(seditorkey && !$(seditorkey + 'sml_menu')) {
var div = document.createElement("div");
div.id = seditorkey + 'sml_menu';
div.style.display = 'none';
div.className = 'sllt';
$('append_parent').appendChild(div);
var div = document.createElement("div");
div.id = id;
div.style.overflow = 'hidden';
$(seditorkey + 'sml_menu').appendChild(div);
}
if(typeof smilies_type == 'undefined') {
var scriptNode = document.createElement("script");
scriptNode.type = "text/javascript";
scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset);
scriptNode.src = 'data/cache/common_smilies_var.js?' + VERHASH;
$('append_parent').appendChild(scriptNode);
if(BROWSER.ie) {
scriptNode.onreadystatechange = function() {
smilies_onload(id, smcols, seditorkey);
};
} else {
scriptNode.onload = function() {
smilies_onload(id, smcols, seditorkey);
};
}
} else {
smilies_onload(id, smcols, seditorkey);
}
}
function smilies_onload(id, smcols, seditorkey) {
seditorkey = !seditorkey ? '' : seditorkey;
smile = getcookie('smile').split('D');
if(typeof smilies_type == 'object') {
if(smile[0] && smilies_array[smile[0]]) {
CURRENTSTYPE = smile[0];
} else {
for(i in smilies_array) {
CURRENTSTYPE = i;break;
}
}
smiliestype = '<div id="'+id+'_tb" class="tb tb_s cl"><ul>';
for(i in smilies_type) {
key = i.substring(1);
if(smilies_type[i][0]) {
smiliestype += '<li ' + (CURRENTSTYPE == key ? 'class="current"' : '') + ' id="'+seditorkey+'stype_'+key+'" onclick="smilies_switch(\'' + id + '\', \'' + smcols + '\', '+key+', 1, \'' + seditorkey + '\');if(CURRENTSTYPE) {$(\''+seditorkey+'stype_\'+CURRENTSTYPE).className=\'\';}this.className=\'current\';CURRENTSTYPE='+key+';doane(event);"><a href="javascript:;" hidefocus="true">'+smilies_type[i][0]+'</a></li>';
}
}
smiliestype += '</ul></div>';
$(id).innerHTML = smiliestype + '<div id="' + id + '_data"></div><div class="sllt_p" id="' + id + '_page"></div>';
smilies_switch(id, smcols, CURRENTSTYPE, smile[1], seditorkey);
smilies_fastdata = '';
if(seditorkey == 'fastpost' && $('fastsmilies') && smilies_fast) {
var j = 0;
for(i = 0;i < smilies_fast.length; i++) {
if(j == 0) {
smilies_fastdata += '<tr>';
}
j = ++j > 3 ? 0 : j;
s = smilies_array[smilies_fast[i][0]][smilies_fast[i][1]][smilies_fast[i][2]];
smilieimg = STATICURL + 'image/smiley/' + smilies_type['_' + smilies_fast[i][0]][1] + '/' + s[2];
img[k] = new Image();
img[k].src = smilieimg;
smilies_fastdata += s ? '<td onmouseover="smilies_preview(\'' + seditorkey + '\', \'fastsmiliesdiv\', this, ' + s[5] + ')" onmouseout="$(\'smilies_preview\').style.display = \'none\'" onclick="' + (typeof wysiwyg != 'undefined' ? 'insertSmiley(' + s[0] + ')': 'seditor_insertunit(\'' + seditorkey + '\', \'' + s[1].replace(/'/, '\\\'') + '\')') +
'" id="' + seditorkey + 'smilie_' + s[0] + '_td"><img id="smilie_' + s[0] + '" width="' + s[3] +'" height="' + s[4] +'" src="' + smilieimg + '" alt="' + s[1] + '" />' : '<td>';
}
$('fastsmilies').innerHTML = '<table cellspacing="0" cellpadding="0"><tr>' + smilies_fastdata + '</tr></table>';
}
}
}
function smilies_switch(id, smcols, type, page, seditorkey) {
page = page ? page : 1;
if(!smilies_array[type] || !smilies_array[type][page]) return;
setcookie('smile', type + 'D' + page, 31536000);
smiliesdata = '<table id="' + id + '_table" cellpadding="0" cellspacing="0"><tr>';
j = k = 0;
img = [];
for(var i = 0; i < smilies_array[type][page].length; i++) {
if(j >= smcols) {
smiliesdata += '<tr>';
j = 0;
}
s = smilies_array[type][page][i];
smilieimg = STATICURL + 'image/smiley/' + smilies_type['_' + type][1] + '/' + s[2];
img[k] = new Image();
img[k].src = smilieimg;
smiliesdata += s && s[0] ? '<td onmouseover="smilies_preview(\'' + seditorkey + '\', \'' + id + '\', this, ' + s[5] + ')" onclick="' + (typeof wysiwyg != 'undefined' ? 'insertSmiley(' + s[0] + ')': 'seditor_insertunit(\'' + seditorkey + '\', \'' + s[1].replace(/'/, '\\\'') + '\')') +
'" id="' + seditorkey + 'smilie_' + s[0] + '_td"><img id="smilie_' + s[0] + '" width="' + s[3] +'" height="' + s[4] +'" src="' + smilieimg + '" alt="' + s[1] + '" />' : '<td>';
j++;k++;
}
smiliesdata += '</table>';
smiliespage = '';
if(smilies_array[type].length > 2) {
prevpage = ((prevpage = parseInt(page) - 1) < 1) ? smilies_array[type].length - 1 : prevpage;
nextpage = ((nextpage = parseInt(page) + 1) == smilies_array[type].length) ? 1 : nextpage;
smiliespage = '<div class="z"><a href="javascript:;" onclick="smilies_switch(\'' + id + '\', \'' + smcols + '\', ' + type + ', ' + prevpage + ', \'' + seditorkey + '\');doane(event);">上页</a>' +
'<a href="javascript:;" onclick="smilies_switch(\'' + id + '\', \'' + smcols + '\', ' + type + ', ' + nextpage + ', \'' + seditorkey + '\');doane(event);">下页</a></div>' +
page + '/' + (smilies_array[type].length - 1);
}
$(id + '_data').innerHTML = smiliesdata;
$(id + '_page').innerHTML = smiliespage;
$(id + '_tb').style.width = smcols*(16+parseInt(s[3])) + 'px';
}
function smilies_preview(seditorkey, id, obj, w) {
var menu = $('smilies_preview');
if(!menu) {
menu = document.createElement('div');
menu.id = 'smilies_preview';
menu.className = 'sl_pv';
menu.style.display = 'none';
$('append_parent').appendChild(menu);
}
menu.innerHTML = '<img width="' + w + '" src="' + obj.childNodes[0].src + '" />';
mpos = fetchOffset($(id + '_data'));
spos = fetchOffset(obj);
pos = spos['left'] >= mpos['left'] + $(id + '_data').offsetWidth / 2 ? '13' : '24';
showMenu({'ctrlid':obj.id,'showid':id + '_data','menuid':menu.id,'pos':pos,'layer':3});
}

241
static/js/space_diy.js Normal file
View File

@@ -0,0 +1,241 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: space_diy.js 23838 2011-08-11 06:51:58Z monkey $
*/
var drag = new Drag();
drag.extend({
setDefalutMenu : function () {
this.addMenu('default', '删除', 'drag.removeBlock(event)');
this.addMenu('block', '属性', 'drag.openBlockEdit(event)');
},
removeBlock : function (e) {
if ( typeof e !== 'string') {
e = Util.event(e);
id = e.aim.id.replace('cmd_','');
} else {
id = e;
}
if (!confirm('您确实要删除吗,删除以后将不可恢复')) return false;
$(id).parentNode.removeChild($(id));
var el = $('chk'+id);
if (el != null) el.className = '';
this.initPosition();
this.initChkBlock();
},
initChkBlock : function (data) {
if (typeof name == 'undefined' || data == null ) data = this.data;
if ( data instanceof Frame) {
this.initChkBlock(data['columns']);
} else if (data instanceof Block) {
var el = $('chk'+data.name);
if (el != null) el.className = 'activity';
} else if (typeof data == 'object') {
for (var i in data) {
this.initChkBlock(data[i]);
}
}
},
toggleBlock : function (blockname) {
var el = $('chk'+blockname);
if (el != null) {
if (el.className == '') {
this.getBlockData(blockname);
el.className = 'activity';
} else {
this.removeBlock(blockname);
this.initPosition();
}
this.setClose();
}
},
getBlockData : function (blockname) {
var el = $(blockname);
if (el != null) {
Util.show(blockname);
} else {
var x = new Ajax();
x.get('home.php?mod=spacecp&ac=index&op=getblock&blockname='+blockname+'&inajax=1',function(s) {
if (s) {
el = document.createElement("div");
el.className = drag.blockClass + ' ' + drag.moveableObject;
el.id = blockname;
s = s.replace(/\<script.*\<\/script\>/ig,'<font color="red"> [javascript脚本保存后显示] </font>');
el.innerHTML = s;
var id = drag.data['diypage'][0]['columns']['frame1_left']['children'][0]['name'];
$('frame1_left').insertBefore(el,$(id));
drag.initPosition();
}
});
}
},
openBlockEdit : function (e) {
e = Util.event(e);
var blockname = e.aim.id.replace('cmd_','');
this.removeMenu();
showWindow('showblock', 'home.php?mod=spacecp&ac=index&op=edit&blockname='+blockname,'get',0);
}
});
var spaceDiy = new DIY();
spaceDiy.extend({
save:function () {
drag.clearClose();
document.diyform.spacecss.value = this.getSpacecssStr();
document.diyform.style.value = this.style;
document.diyform.layoutdata.value = drag.getPositionStr();
document.diyform.currentlayout.value = this.currentLayout;
document.diyform.submit();
},
getdiy : function (type) {
var type_ = type == 'image' ? 'diy' : type;
if (type_) {
var nav = $('controlnav').children;
for (var i in nav) {
if (nav[i].className == 'current') {
nav[i].className = '';
}
}
$('nav'+type_).className = 'current';
var para = '&op='+type;
if (arguments.length > 1) {
for (i = 1; i < arguments.length; i++) {
para += '&' + arguments[i] + '=' + arguments[++i];
}
}
var ajaxtarget = type == 'image' ? 'diyimages' : '';
var x = new Ajax();
x.showId = ajaxtarget;
x.get('home.php?mod=spacecp&ac=index'+para+'&inajax=1&ajaxtarget='+ajaxtarget,function(s) {
if (s) {
drag.deleteFrame(['pb', 'bpb', 'tpb', 'lpb']);
if (type == 'image') {
$('diyimages').innerHTML = s;
} else {
$('controlcontent').innerHTML = s;
x.showId = 'controlcontent';
}
if (type_ == 'block') {
drag.initPosition();
drag.initChkBlock();
} else if (type_ == 'layout') {
$('layout'+spaceDiy.currentLayout).className = 'activity';
} else if (type_ == 'diy' && type != 'image') {
spaceDiy.setCurrentDiy(spaceDiy.currentDiy);
if (spaceDiy.styleSheet.rules.length > 0) {
Util.show('recover_button');
}
}
var evaled = false;
if(s.indexOf('ajaxerror') != -1) {
evalscript(s);
evaled = true;
}
if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
if(x.showId) {
ajaxupdateevents($(x.showId));
}
}
if(!evaled) evalscript(s);
}
});
}
},
menuChange : function (tabs, menu) {
var tabobj = $(tabs);
var aobj = tabobj.getElementsByTagName("li");
for(i=0; i<aobj.length; i++) {
aobj[i].className = '';
$(aobj[i].id+'_content').style.display = 'none';
}
$(menu).className = 'a';
$(menu+'_content').style.display="block";
doane(null);
},
delIframe : function (){
drag.deleteFrame(['m_ctc', 'm_bc', 'm_fc']);
},
showEditSpaceInfo : function () {
$('spaceinfoshow').style.display='none';
if (!$('spaceinfoedit')) {
var dom = document.createElement('h2');
dom.id = 'spaceinfoedit';
Util.insertBefore(dom, $('spaceinfoshow'));
}
ajaxget('home.php?mod=spacecp&ac=index&op=getspaceinfo','spaceinfoedit');
},
spaceInfoCancel : function () {
if ($('spaceinfoedit')) $('spaceinfoedit').style.display = 'none';
if ($('spaceinfoshow')) $('spaceinfoshow').style.display = 'inline';
},
spaceInfoSave : function () {
ajaxpost('savespaceinfo','spaceinfoshow','','onerror');
},
init : function () {
drag.init();
this.style = document.diyform.style.value;
this.currentLayout = typeof document.diyform.currentlayout == 'undefined' ? '' : document.diyform.currentlayout.value;
this.initStyleSheet();
if (this.styleSheet.rules) this.initDiyStyle();
this.initSpaceInfo();
},
initSpaceInfo : function () {
this.spaceInfoCancel();
if ($('spaceinfoshow')) {
if (!$('infoedit')) {
var dom = document.createElement('em');
dom.id = 'infoedit';
dom.innerHTML = '编辑';
$('spacename').appendChild(dom);
}
$('infoedit').onmousedown = function () {spaceDiy.showEditSpaceInfo();};
}
if ($('nv')) {
if(!$('nv').getElementsByTagName('li').length) {
$('nv').getElementsByTagName('ul')[0].className = 'mininv';
}
$('nv').onmouseover = function () {spaceDiy.showEditNvInfo();};
$('nv').onmouseout = function () {spaceDiy.hideEditNvInfo();};
}
},
showEditNvInfo : function () {
var nv = $('editnvinfo');
if(!nv) {
var dom = document.createElement('div');
dom.innerHTML = '<span id="editnvinfo" class="edit" style="background-color:#336699;" onclick="spaceDiy.opNvEditInfo();">设置</span>';
$('nv').appendChild(dom.childNodes[0]);
} else {
nv.style.display = '';
}
},
hideEditNvInfo : function () {
var nv = $('editnvinfo');
if(nv) {
nv.style.display = 'none';
}
},
opNvEditInfo : function () {
showWindow('showpersonalnv', 'home.php?mod=spacecp&ac=index&op=editnv','get',0);
},
getPersonalNv : function (show) {
var x = new Ajax();
show = !show ? '' : '&show=1';
x.get('home.php?mod=spacecp&ac=index&op=getpersonalnv&inajax=1'+show, function(s) {
if($('nv')) {
$('hd').removeChild($('nv'));
}
var dom = document.createElement('div');
dom.innerHTML = !s ? '&nbsp;' : s;
$('hd').appendChild(dom.childNodes[0]);
spaceDiy.initSpaceInfo();
});
}
});
spaceDiy.init();

52
static/js/stat.js Normal file
View File

@@ -0,0 +1,52 @@
function drawstatchart(url) {
if (BROWSER.ie && BROWSER.ie < 9) {
$('statchart').innerHTML = AC_FL_RunContent(
'width', '100%', 'height', '300',
'src', STATICURL + 'image/common/stat.swf?path=&settings_file=data/stat_setting.xml&data_file=' + encodeURIComponent(url),
'quality', 'high', 'wmode', 'transparent'
);
return;
}
var x = new Ajax();
x.recvType = 'HTML';
$('statchart').style.width = '100%';
$('statchart').style.height = '400px';
x.get(url, function (s, x) {
var myChart = echarts.init($('statchart'));
option = {
grid: { left: 60, right: 20 },
xAxis: { type: 'category', data: [] },
yAxis: { type: 'value' },
tooltip: { trigger: 'axis', textStyle: { fontSize: 12 } },
series: [],
legend: { type: 'scroll', data: [], left: 60, bottom: 10 }
};
var rex = x.XMLHttpRequest.responseXML, reax = rex.getElementsByTagName('xaxis')[0].childNodes;
if (!reax.length) {
option['title'] = {
text: 'There is no data for selected period', padding: [10, 50],
textAlign: 'center', textVerticalAlign: 'center',
left: '50%', top: '50%', backgroundColor: '#e8f0f7'
};
}
for (var i = 0; i < reax.length; i++) {
option.xAxis.data.push(reax[i].firstChild.nodeValue);
}
for (var i = 0, q = rex.getElementsByTagName('graphs')[0].childNodes; i < q.length; i++) {
qttl = q[i].getAttribute('title');
option.legend.data.push(qttl);
qdata = {
type: 'line',
name: qttl,
data: []
};
for (var j = 0; j < q[i].childNodes.length; j++) {
qdata.data.push(parseInt(q[i].childNodes[j].firstChild.nodeValue));
}
option.series.push(qdata);
}
myChart.setOption(option);
});
}

929
static/js/swfupload.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,90 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: swfupload.queue.js 23838 2011-08-11 06:51:58Z monkey $
*/
var SWFUpload;
if (typeof(SWFUpload) === "function") {
SWFUpload.queue = {};
SWFUpload.prototype.initSettings = (function (oldInitSettings) {
return function (userSettings) {
if (typeof(oldInitSettings) === "function") {
oldInitSettings.call(this, userSettings);
}
this.queueSettings = {};
this.queueSettings.queue_cancelled_flag = false;
this.queueSettings.queue_upload_count = 0;
this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
this.settings.queue_complete_handler = userSettings.queue_complete_handler || null;
};
})(SWFUpload.prototype.initSettings);
SWFUpload.prototype.startUpload = function (fileID) {
this.queueSettings.queue_cancelled_flag = false;
this.callFlash("StartUpload", [fileID]);
};
SWFUpload.prototype.cancelQueue = function () {
this.queueSettings.queue_cancelled_flag = true;
this.stopUpload();
var stats = this.getStats();
while (stats.files_queued > 0) {
this.cancelUpload();
stats = this.getStats();
}
};
SWFUpload.queue.uploadStartHandler = function (file) {
var returnValue;
if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
}
returnValue = (returnValue === false) ? false : true;
this.queueSettings.queue_cancelled_flag = !returnValue;
return returnValue;
};
SWFUpload.queue.uploadCompleteHandler = function (file) {
var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
var continueUpload;
if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
this.queueSettings.queue_upload_count++;
}
if (typeof(user_upload_complete_handler) === "function") {
continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
} else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
continueUpload = false;
} else {
continueUpload = true;
}
if (continueUpload) {
var stats = this.getStats();
if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
this.startUpload();
} else if (this.queueSettings.queue_cancelled_flag === false) {
this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
this.queueSettings.queue_upload_count = 0;
} else {
this.queueSettings.queue_cancelled_flag = false;
this.queueSettings.queue_upload_count = 0;
}
}
};
}

View File

35
static/js/swiper/swiper-bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

234
static/js/threadsort.js Normal file
View File

@@ -0,0 +1,234 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: threadsort.js 30962 2012-07-04 07:57:45Z zhangjie $
*/
function xmlobj() {
var obj = new Object();
obj.createXMLDoc = function(xmlstring) {
var xmlobj = false;
if(window.DOMParser && document.implementation && document.implementation.createDocument) {
try{
var domparser = new DOMParser();
xmlobj = domparser.parseFromString(xmlstring, 'text/xml');
} catch(e) {
}
} else if(window.ActiveXObject) {
var versions = ["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument", "Microsoft.XmlDom"];
for(var i=0; i<versions.length; i++) {
try {
xmlobj = new ActiveXObject(versions[i]);
if(xmlobj) {
xmlobj.async = false;
xmlobj.loadXML(xmlstring);
}
} catch(e) {}
}
}
return xmlobj;
};
obj.xml2json = function(xmlobj, node) {
var nodeattr = node.attributes;
if(nodeattr != null) {
if(nodeattr.length && xmlobj == null) {
xmlobj = new Object();
}
for(var i = 0;i < nodeattr.length;i++) {
xmlobj[nodeattr[i].name] = nodeattr[i].value;
}
}
var nodetext = "text";
if(node.text == null) {
nodetext = "textContent";
}
var nodechilds = node.childNodes;
if(nodechilds != null) {
if(nodechilds.length && xmlobj == null) {
xmlobj = new Object();
}
for(var i = 0;i < nodechilds.length;i++) {
if(nodechilds[i].tagName != null) {
if(nodechilds[i].childNodes[0] != null && nodechilds[i].childNodes.length <= 1 && (nodechilds[i].childNodes[0].nodeType == 3 || nodechilds[i].childNodes[0].nodeType == 4)) {
if(xmlobj[nodechilds[i].tagName] == null) {
xmlobj[nodechilds[i].tagName] = nodechilds[i][nodetext];
} else {
if(typeof(xmlobj[nodechilds[i].tagName]) == "object" && xmlobj[nodechilds[i].tagName].length) {
xmlobj[nodechilds[i].tagName][xmlobj[nodechilds[i].tagName].length] = nodechilds[i][nodetext];
} else {
xmlobj[nodechilds[i].tagName] = [xmlobj[nodechilds[i].tagName]];
xmlobj[nodechilds[i].tagName][1] = nodechilds[i][nodetext];
}
}
} else {
if(nodechilds[i].childNodes.length) {
if(xmlobj[nodechilds[i].tagName] == null) {
xmlobj[nodechilds[i].tagName] = new Object();
this.xml2json(xmlobj[nodechilds[i].tagName], nodechilds[i]);
} else {
if(xmlobj[nodechilds[i].tagName].length) {
xmlobj[nodechilds[i].tagName][xmlobj[nodechilds[i].tagName].length] = new Object();
this.xml2json(xmlobj[nodechilds[i].tagName][xmlobj[nodechilds[i].tagName].length-1], nodechilds[i]);
} else {
xmlobj[nodechilds[i].tagName] = [xmlobj[nodechilds[i].tagName]];
xmlobj[nodechilds[i].tagName][1] = new Object();
this.xml2json(xmlobj[nodechilds[i].tagName][1], nodechilds[i]);
}
}
} else {
xmlobj[nodechilds[i].tagName] = nodechilds[i][nodetext];
}
}
}
}
}
};
return obj;
}
var xml = new xmlobj();
var xmlpar = xml.createXMLDoc(forum_optionlist);
var forum_optionlist_obj = new Object();
xml.xml2json(forum_optionlist_obj, xmlpar);
function changeselectthreadsort(selectchoiceoptionid, optionid, type) {
if(selectchoiceoptionid == '0') {
return;
}
var soptionid = 's' + optionid;
var sselectchoiceoptionid = 's' + selectchoiceoptionid;
forum_optionlist = forum_optionlist_obj['forum_optionlist'];
var choicesarr = forum_optionlist[soptionid]['schoices'];
var lastcount = 1;
var name = issearch = id = nameid = '';
if(type == 'search') {
issearch = ', \'search\'';
name = ' name="searchoption[' + optionid + '][value]"';
id = 'id="' + forum_optionlist[soptionid]['sidentifier'] + '"';
} else {
name = ' name="typeoption[' + forum_optionlist[soptionid]['sidentifier'] + ']"';
id = 'id="typeoption_' + forum_optionlist[soptionid]['sidentifier'] + '"';
}
if((choicesarr[sselectchoiceoptionid]['slevel'] == 1 || type == 'search') && choicesarr[sselectchoiceoptionid]['scount'] == 1) {
nameid = name + ' ' + id;
}
var selectoption = '<select' + nameid + ' class="ps vm" onchange="changeselectthreadsort(this.value, \'' + optionid + '\'' + issearch + ');checkoption(\'' + forum_optionlist[soptionid]['sidentifier'] + '\', \'' + forum_optionlist[soptionid]['srequired'] + '\', \'' + forum_optionlist[soptionid]['stype'] + '\')" ' + ((forum_optionlist[soptionid]['sunchangeable'] == 1 && type == 'update') ? 'disabled' : '') + '><option value="0">请选择</option>';
for(var i in choicesarr) {
nameid = '';
if((choicesarr[sselectchoiceoptionid]['slevel'] == 1 || type == 'search') && choicesarr[i]['scount'] == choicesarr[sselectchoiceoptionid]['scount']) {
nameid = name + ' ' + id;
}
if(choicesarr[i]['sfoptionid'] != '0') {
var patrn1 = new RegExp("^" + choicesarr[i]['sfoptionid'] + "\\.", 'i');
var patrn2 = new RegExp("^" + choicesarr[i]['sfoptionid'] + "$", 'i');
if(selectchoiceoptionid.match(patrn1) == null && selectchoiceoptionid.match(patrn2) == null) {
continue;
}
}
if(choicesarr[i]['scount'] != lastcount) {
if(parseInt(choicesarr[i]['scount']) >= (parseInt(choicesarr[sselectchoiceoptionid]['scount']) + parseInt(choicesarr[sselectchoiceoptionid]['slevel']))) {
break;
}
selectoption += '</select>' + "\r\n" + '<select' + nameid + ' class="ps vm" onchange="changeselectthreadsort(this.value, \'' + optionid + '\'' + issearch + ');checkoption(\'' + forum_optionlist[soptionid]['sidentifier'] + '\', \'' + forum_optionlist[soptionid]['srequired'] + '\', \'' + forum_optionlist[soptionid]['stype'] + '\')" ' + ((forum_optionlist[soptionid]['sunchangeable'] == 1 && type == 'update') ? 'disabled' : '') + '><option value="0">请选择</option>';
lastcount = parseInt(choicesarr[i]['scount']);
}
var patrn1 = new RegExp("^" + choicesarr[i]['soptionid'] + "\\.", 'i');
var patrn2 = new RegExp("^" + choicesarr[i]['soptionid'] + "$", 'i');
var isnext = '';
if(parseInt(choicesarr[i]['slevel']) != 1) {
isnext = '&raquo;';
}
if(selectchoiceoptionid.match(patrn1) != null || selectchoiceoptionid.match(patrn2) != null) {
selectoption += "\r\n" + '<option value="' + choicesarr[i]['soptionid'] + '" selected="selected">' + choicesarr[i]['scontent'] + isnext + '</option>';
} else {
selectoption += "\r\n" + '<option value="' + choicesarr[i]['soptionid'] + '">' + choicesarr[i]['scontent'] + isnext + '</option>';
}
}
selectoption += '</select>';
if(type == 'search') {
selectoption += "\r\n" + '<input type="hidden" name="searchoption[' + optionid + '][type]" value="select">';
}
$('select_' + forum_optionlist[soptionid]['sidentifier']).innerHTML = selectoption;
}
function checkoption(identifier, required, checktype, checkmaxnum, checkminnum, checkmaxlength) {
if(checktype != 'image' && checktype != 'select' && !$('typeoption_' + identifier) || !$('check' + identifier)) {
return true;
}
var ce = $('check' + identifier);
ce.innerHTML = '';
if(checktype == 'select') {
if(required != '0' && ($('typeoption_' + identifier) == null || $('typeoption_' + identifier).value == '0')) {
warning(ce, '必填项目没有填写');
return false;
} else if(required == '0' && ($('typeoption_' + identifier) == null || $('typeoption_' + identifier).value == '0')) {
ce.innerHTML = '<i class="fico-error fic4 fc-l vm"></i> 请选择下一级';
ce.className = "warning";
return true;
}
}
if(checktype == 'radio' || checktype == 'checkbox') {
var nodes = $('typeoption_' + identifier).parentNode.parentNode.parentNode.getElementsByTagName('INPUT');
var nodechecked = false;
for(var i=0; i<nodes.length; i++) {
if(nodes[i].id == 'typeoption_' + identifier) {
if(nodes[i].checked) {
nodechecked = true;
}
}
}
if(!nodechecked && required != '0') {
warning(ce, '必填项目没有填写');
return false;
}
}
if(checktype == 'image') {
var checkvalue = $('sortaid_' + identifier).value;
} else {
var checkvalue = $('typeoption_' + identifier).value.trim();
}
if(required != '0') {
if(checkvalue == '') {
warning(ce, '必填项目没有填写');
return false;
} else {
ce.innerHTML = '<i class="fico-check_right fic4 fc-v vm"></i>';
}
}
if(checkvalue) {
if(checktype == 'email' && !(/^[\-\.\w]+@[\.\-\w]+(\.\w+)+$/.test(checkvalue))) {
warning(ce, '邮件地址不正确');
return false;
} else if((checktype == 'text' || checktype == 'textarea') && checkmaxlength != '0' && mb_strlen(checkvalue) > checkmaxlength) {
warning(ce, '填写项目长度过长');
return false;
} else if((checktype == 'number' || checktype == 'range')) {
if(isNaN(checkvalue)) {
warning(ce, '数字填写不正确');
return false;
} else if(checkmaxnum != '0' && parseInt(checkvalue) > parseInt(checkmaxnum)) {
warning(ce, '大于设置最大值');
return false;
} else if(checkminnum != '0' && parseInt(checkvalue) < parseInt(checkminnum)) {
warning(ce, '小于设置最小值');
return false;
}
} else if(checktype == 'url' && !(/(http[s]?|ftp):\/\/[^\/\.]+?\..+\w[\/]?$/i.test(checkvalue))) {
warning(ce, '请正确填写以http://开头的URL地址');
return false;
}
ce.innerHTML = '<i class="fico-check_right fic4 fc-v vm"></i>';
}
return true;
}

178
static/js/tree.js Normal file
View File

@@ -0,0 +1,178 @@
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tree.js 23838 2011-08-11 06:51:58Z monkey $
*/
var icon = new Object();
icon.root = IMGDIR + '/tree_root.gif';
icon.folder = IMGDIR + '/tree_folder.gif';
icon.folderOpen = IMGDIR + '/tree_folderopen.gif';
icon.file = IMGDIR + '/tree_file.gif';
icon.empty = IMGDIR + '/tree_empty.gif';
icon.line = IMGDIR + '/tree_line.gif';
icon.lineMiddle = IMGDIR + '/tree_linemiddle.gif';
icon.lineBottom = IMGDIR + '/tree_linebottom.gif';
icon.plus = IMGDIR + '/tree_plus.gif';
icon.plusMiddle = IMGDIR + '/tree_plusmiddle.gif';
icon.plusBottom = IMGDIR + '/tree_plusbottom.gif';
icon.minus = IMGDIR + '/tree_minus.gif';
icon.minusMiddle = IMGDIR + '/tree_minusmiddle.gif';
icon.minusBottom = IMGDIR + '/tree_minusbottom.gif';
function treeNode(id, pid, name, url, target, open) {
var obj = new Object();
obj.id = id;
obj.pid = pid;
obj.name = name;
obj.url = url;
obj.target = target;
obj.open = open;
obj._isOpen = open;
obj._lastChildId = 0;
obj._pid = 0;
return obj;
}
function dzTree(treeName) {
this.nodes = new Array();
this.openIds = getcookie('leftmenu_openids');
this.pushNodes = new Array();
this.addNode = function(id, pid, name, url, target, open) {
var theNode = new treeNode(id, pid, name, url, target, open);
this.pushNodes.push(id);
if(!this.nodes[pid]) {
this.nodes[pid] = new Array();
}
this.nodes[pid]._lastChildId = id;
for(k in this.nodes) {
if(this.openIds && this.openIds.indexOf('_' + theNode.id) != -1) {
theNode._isOpen = true;
}
if(this.nodes[k].pid == id) {
theNode._lastChildId = this.nodes[k].id;
}
}
this.nodes[id] = theNode;
};
this.show = function() {
var s = '<div class="tree">';
s += this.createTree(this.nodes[0]);
s += '</div>';
document.write(s);
};
this.createTree = function(node, padding) {
padding = padding ? padding : '';
if(node.id == 0){
var icon1 = '';
} else {
var icon1 = '<img src="' + this.getIcon1(node) + '" onclick="' + treeName + '.switchDisplay(\'' + node.id + '\')" id="icon1_' + node.id + '" style="cursor: pointer;">';
}
var icon2 = '<img src="' + this.getIcon2(node) + '" onclick="' + treeName + '.switchDisplay(\'' + node.id + '\')" id="icon2_' + node.id + '" style="cursor: pointer;">';
var s = '<div class="node" id="node_' + node.id + '">' + padding + icon1 + icon2 + this.getName(node) + '</div>';
s += '<div class="nodes" id="nodes_' + node.id + '" style="display:' + (node._isOpen ? '' : 'none') + '">';
for(k in this.pushNodes) {
var id = this.pushNodes[k];
var theNode = this.nodes[id];
if(theNode.pid == node.id) {
if(node.id == 0){
var thePadding = '';
} else {
var thePadding = padding + (node.id == this.nodes[node.pid]._lastChildId ? '<img src="' + icon.empty + '">' : '<img src="' + icon.line + '">');
}
if(!theNode._lastChildId) {
var icon1 = '<img src="' + this.getIcon1(theNode) + '"' + ' id="icon1_' + theNode.id + '">';
var icon2 = '<img src="' + this.getIcon2(theNode) + '" id="icon2_' + theNode.id + '">';
s += '<div class="node" id="node_' + theNode.id + '">' + thePadding + icon1 + icon2 + this.getName(theNode) + '</div>';
} else {
s += this.createTree(theNode, thePadding);
}
}
}
s += '</div>';
return s;
};
this.getIcon1 = function(theNode) {
var parentNode = this.nodes[theNode.pid];
var src = '';
if(theNode._lastChildId) {
if(theNode._isOpen) {
if(theNode.id == 0) {
return icon.minus;
}
if(theNode.id == parentNode._lastChildId) {
src = icon.minusBottom;
} else {
src = icon.minusMiddle;
}
} else {
if(theNode.id == 0) {
return icon.plus;
}
if(theNode.id == parentNode._lastChildId) {
src = icon.plusBottom;
} else {
src = icon.plusMiddle;
}
}
} else {
if(theNode.id == parentNode._lastChildId) {
src = icon.lineBottom;
} else {
src = icon.lineMiddle;
}
}
return src;
};
this.getIcon2 = function(theNode) {
var src = '';
if(theNode.id == 0 ) {
return icon.root;
}
if(theNode._lastChildId) {
if(theNode._isOpen) {
src = icon.folderOpen;
} else {
src = icon.folder;
}
} else {
src = icon.file;
}
return src;
};
this.getName = function(theNode) {
if(theNode.url) {
return '<a href="'+theNode.url+'" target="' + theNode.target + '"> '+theNode.name+'</a>';
} else {
return theNode.name;
}
};
this.switchDisplay = function(nodeId) {
eval('var theTree = ' + treeName);
var theNode = theTree.nodes[nodeId];
if($('nodes_' + nodeId).style.display == 'none') {
theTree.openIds = updatestring(theTree.openIds, nodeId);
setcookie('leftmenu_openids', theTree.openIds, 8640000000);
theNode._isOpen = true;
$('nodes_' + nodeId).style.display = '';
$('icon1_' + nodeId).src = theTree.getIcon1(theNode);
$('icon2_' + nodeId).src = theTree.getIcon2(theNode);
} else {
theTree.openIds = updatestring(theTree.openIds, nodeId, true);
setcookie('leftmenu_openids', theTree.openIds, 8640000000);
theNode._isOpen = false;
$('nodes_' + nodeId).style.display = 'none';
$('icon1_' + nodeId).src = theTree.getIcon1(theNode);
$('icon2_' + nodeId).src = theTree.getIcon2(theNode);
}
};
}

1665
static/js/upload.js Normal file

File diff suppressed because one or more lines are too long

940
static/js/webuploader.js Normal file
View File

@@ -0,0 +1,940 @@
var getBasePath = function() {
var els = document.getElementsByTagName('script'),
src;
for (var i = 0,
len = els.length; i < len; i++) {
src = els[i].src || '';
if (/webuploader[\w\-\.]*\.js/.test(src)) {
return src.substring(0, src.lastIndexOf('/') + 1);
}
}
return '';
};
var SWFUpload;
var sdCloseTime = 2;
if (SWFUpload == undefined) {
SWFUpload = function(settings) {
this.initSWFUpload(settings);
};
}
SWFUpload.CURSOR = {
ARROW: -1,
HAND: -2
};
SWFUpload.EXT_MIME_MAP = {
'3gp': 'video/3gpp',
'7z': 'application/x-7z-compressed',
'aac': 'audio/aac',
'abw': 'application/x-abiword',
'arc': 'application/x-freearc',
'avi': 'video/x-msvideo',
'apk': 'application/vnd.android.package-archive',
'azw': 'application/vnd.amazon.ebook',
'bin': 'application/octet-stream',
'bmp': 'image/bmp',
'bz': 'application/x-bzip',
'bz2': 'application/x-bzip2',
'bzip2': 'application/x-bzip2',
'chm': 'application/vnd.ms-htmlhelp',
'csh': 'application/x-csh',
'css': 'text/css',
'csv': 'text/csv',
'doc': 'application/msword',
'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'eot': 'application/vnd.ms-fontobject',
'epub': 'application/epub+zip',
'flv': 'video/x-flv',
'gif': 'image/gif',
'gz': 'application/gzip',
'htm': 'text/html',
'html': 'text/html',
'ico': 'image/vnd.microsoft.icon',
'ics': 'text/calendar',
'jar': 'application/java-archive',
'jpeg': 'image/jpeg',
'jpg': 'image/jpeg',
'js': 'text/javascript',
'json': 'application/json',
'jsonld': 'application/ld+json',
'm4a': 'audio/mp4',
'mid': 'audio/midi',
'midi': 'audio/midi',
'mjs': 'text/javascript',
'mov': 'video/quicktime',
'mkv': 'video/x-matroska',
'mp3': 'audio/mpeg',
'mp4': 'video/mp4',
'mp4a': 'audio/mp4',
'mp4v': 'video/mp4',
'mpeg': 'video/mpeg',
'mpkg': 'application/vnd.apple.installer+xml',
'odp': 'application/vnd.oasis.opendocument.presentation',
'ods': 'application/vnd.oasis.opendocument.spreadsheet',
'odt': 'application/vnd.oasis.opendocument.text',
'oga': 'audio/ogg',
'ogv': 'video/ogg',
'ogx': 'application/ogg',
'opus': 'audio/opus',
'otf': 'font/otf',
'pdf': 'application/pdf',
'php': 'application/php',
'png': 'image/png',
'ppt': 'application/vnd.ms-powerpoint',
'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'rar': 'application/x-rar-compressed',
'rtf': 'application/rtf',
'sh': 'application/x-sh',
'svg': 'image/svg+xml',
'swf': 'application/x-shockwave-flash',
'tar': 'application/x-tar',
'tif': 'image/tiff',
'tiff': 'image/tiff',
'ts': 'video/mp2t',
'ttf': 'font/ttf',
'txt': 'text/plain',
'vsd': 'application/vnd.visio',
'wav': 'audio/wav',
'wma': 'audio/x-ms-wma',
'wmv': 'video/x-ms-asf',
'weba': 'audio/webm',
'webm': 'video/webm',
'webp': 'image/webp',
'woff': 'font/woff',
'woff2': 'font/woff2',
'xhtml': 'application/xhtml+xml',
'xls': 'application/vnd.ms-excel',
'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xml': 'application/xml',
'xul': 'application/vnd.mozilla.xul+xml',
'zip': 'application/zip'
};
SWFUpload.prototype.initSWFUpload = function(userSettings) {
try {
this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
this.settings = {};
this.eventQueue = [];
this.initSettings(userSettings);
} catch (ex) {
throw ex;
}
};
SWFUpload.prototype.initSettings = function (userSettings) {
this.ensureDefault = function(settingName, defaultValue) {
var setting = userSettings[settingName];
if (setting != undefined) {
this.settings[settingName] = setting;
} else {
this.settings[settingName] = defaultValue;
}
};
this.ensureDefault("upload_url", "");
this.ensureDefault("file_post_name", "Filedata");
this.ensureDefault("post_params", {});
this.ensureDefault("file_types", "*.*");
this.ensureDefault("file_types_description", "All Files");
this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
this.ensureDefault("file_upload_limit", 0);
this.ensureDefault("file_queue_limit", 0);
this.ensureDefault("button_image_url", "");
this.ensureDefault("button_width", 1);
this.ensureDefault("button_height", 1);
this.ensureDefault("button_placeholder_id", "");
this.ensureDefault("debug", false);
this.ensureDefault("swfupload_preload_handler", null);
this.ensureDefault("swfupload_load_failed_handler", null);
this.ensureDefault("swfupload_loaded_handler", null);
this.ensureDefault("file_dialog_start_handler", null);
this.ensureDefault("file_queued_handler", null);
this.ensureDefault("file_queue_error_handler", null);
this.ensureDefault("file_dialog_complete_handler", null);
this.ensureDefault("upload_resize_start_handler", null);
this.ensureDefault("upload_start_handler", null);
this.ensureDefault("upload_progress_handler", null);
this.ensureDefault("upload_error_handler", null);
this.ensureDefault("upload_success_handler", null);
this.ensureDefault("upload_complete_handler", null);
this.ensureDefault("debug_handler", this.debugMessage);
this.ensureDefault("custom_settings", {});
this.customSettings = this.settings.custom_settings;
if(this.settings.button_placeholder_id == 'imgSpanButtonPlaceholder' && $("imgSpanButtonPlaceholder")){
if($("icoImg_image_menu")){
$('icoImg_image_menu').style.display = '';
$('icoImg_image_menu').style.position = 'absolute';
$('icoImg_image_menu').style.top = '-9999px';
}else if(typeof editorid != 'undefined' && $(editorid + '_image_menu')){
$(editorid + '_image_menu').style.display = '';
}
$('imgSpanButtonPlaceholder').innerHTML = 'upload';
$("imgSpanButtonPlaceholder").style.display = 'inline-block';
$("imgSpanButtonPlaceholder").style.width = this.settings.button_width + 'px';
$("imgSpanButtonPlaceholder").style.height = this.settings.button_height + 'px';
$("imgSpanButtonPlaceholder").style.backgroundImage = 'url(' + this.settings.button_image_url + ')';
$("imgSpanButtonPlaceholder").style.backgroundRepeat = 'no-repeat';
$("imgSpanButtonPlaceholder").onmouseover = function () {
$("imgSpanButtonPlaceholder").style.backgroundPosition = '0px -25px';
};
$("imgSpanButtonPlaceholder").onmouseout = function () {
$("imgSpanButtonPlaceholder").style.backgroundPosition = '0px 0px';
};
}
if(this.settings.button_placeholder_id == 'spanButtonPlaceholder' && $("spanButtonPlaceholder")){
if($("icoAttach_attach_menu")){
$('icoAttach_attach_menu').style.display = '';
$('icoAttach_attach_menu').style.position = 'absolute';
$('icoAttach_attach_menu').style.top = '-9999px';
}else if(typeof editorid != 'undefined' && $(editorid + '_attach_menu')){
$(editorid + '_attach_menu').style.display = '';
}
$('spanButtonPlaceholder').innerHTML = 'upload';
$("spanButtonPlaceholder").style.display = 'inline-block';
$("spanButtonPlaceholder").style.width = this.settings.button_width + 'px';
$("spanButtonPlaceholder").style.height = this.settings.button_height + 'px';
$("spanButtonPlaceholder").style.backgroundImage = 'url(' + this.settings.button_image_url + ')';
$("spanButtonPlaceholder").style.backgroundRepeat = 'no-repeat';
$("spanButtonPlaceholder").onmouseover = function () {
$("spanButtonPlaceholder").style.backgroundPosition = '0px -25px';
};
$("spanButtonPlaceholder").onmouseout = function () {
$("spanButtonPlaceholder").style.backgroundPosition = '0px 0px';
};
}
if(this.customSettings.uploadSource == 'forum' && this.customSettings.uploadType == 'poll' && $(this.settings.button_placeholder_id)){
$(this.settings.button_placeholder_id).innerHTML = 'upload';
$(this.settings.button_placeholder_id).style.display = 'inline-block';
$(this.settings.button_placeholder_id).style.width = this.settings.button_width + 'px';
$(this.settings.button_placeholder_id).style.height = this.settings.button_height + 'px';
$(this.settings.button_placeholder_id).style.backgroundImage = 'url(' + this.settings.button_image_url + ')';
$(this.settings.button_placeholder_id).style.backgroundRepeat = 'no-repeat';
$(this.settings.button_placeholder_id).style.backgroundPosition = 'center top';
}
var self = this;
var exts = "",
mimes = "";
if (this.settings.file_types.indexOf('*.*') < 0) {
exts = this.settings.file_types.replace(/\*\./g, '').replace(/;/g, ',');
var extsArray = jQuery.grep(exts.split(','), function (s) {
return s.length > 0
});
mimes = jQuery.grep(
jQuery.merge(
jQuery.map(extsArray, function (ext) {
return "." + ext;
}),
jQuery.map(extsArray, function (ext) {
return SWFUpload.EXT_MIME_MAP[ext];
})
),
function (s) {
return s.length > 0
}
);
mimes = jQuery.grep(mimes, function (m, i) {
return i === jQuery.inArray(m, mimes)
}).join(",");
}
var uploader = WebUploader.create({
swf: getBasePath() + 'Uploader.swf',
server: this.settings.upload_url,
pick: '#' + this.settings.button_placeholder_id,
compress: false,
threads: 1,
accept: {
title: this.settings.file_types_description,
extensions: exts,
mimeTypes: mimes
},
fileVal: this.settings.file_post_name,
formData: this.settings.post_params,
fileNumLimit: this.settings.file_upload_limit,
fileSingleSizeLimit: this.settings.file_size_limit * 1024,
duplicate: true
});
this.uploader = uploader;
uploader.on('beforeFileQueued', function(file) {
self.queueEvent("file_dialog_start_handler");
});
uploader.on('fileQueued', function(file) {
self.queueEvent("file_queued_handler", file);
});
uploader.on('startUpload', function() {
self.queueEvent("file_dialog_complete_handler");
});
uploader.on('uploadStart', function(file) {
self.queueEvent("upload_start_handler", file);
});
uploader.on('uploadBeforeSend', function (block, data) {
delete data.id;
delete data.name;
delete data.lastModifiedDate;
if(self.settings.post_params.type){
data.type = self.settings.post_params.type;
}
});
uploader.on('uploadProgress', function(file, percentage) {
self.queueEvent("upload_progress_handler", [file, percentage]);
});
uploader.on('uploadError', function(file, reason) {
self.queueEvent("upload_error_handler", [file, reason]);
});
uploader.on('uploadSuccess', function(file, response) {
self.queueEvent("upload_success_handler", [file, response]);
});
uploader.on('error', function(code) {
self.queueEvent("file_queue_error_handler", code);
});
};
SWFUpload.prototype.setUploadURL = function (url) {
this.uploader.options.server = url.toString();
};
SWFUpload.prototype.addPostParam = function (name, value) {
this.uploader.options.formData[name] = value;
};
SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
var self = this;
if (argumentArray == undefined) {
argumentArray = [];
} else if (!(argumentArray instanceof Array)) {
argumentArray = [argumentArray];
}
if (typeof this.settings[handlerName] === "function") {
this.eventQueue.push(function () {
this.settings[handlerName].apply(this, argumentArray);
});
setTimeout(function () {
self.executeNextEvent();
}, 0);
} else if (this.settings[handlerName] !== null) {
throw "Event handler " + handlerName + " is unknown or is not a function";
}
};
SWFUpload.prototype.executeNextEvent = function () {
var f = this.eventQueue ? this.eventQueue.shift() : null;
if (typeof(f) === "function") {
f.apply(this);
}
};
SWFUpload.prototype.debug = function (message) {
this.queueEvent("debug_handler", message);
};
SWFUpload.prototype.debugMessage = function (message) {
var exceptionMessage, exceptionValues, key;
if (this.settings.debug) {
exceptionValues = [];
if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
for (key in message) {
if (message.hasOwnProperty(key)) {
exceptionValues.push(key + ": " + message[key]);
}
}
exceptionMessage = exceptionValues.join("\n") || "";
exceptionValues = exceptionMessage.split("\n");
exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
SWFUpload.Console.writeLine(exceptionMessage);
} else {
SWFUpload.Console.writeLine(message);
}
}
};
function preLoad() {
}
function loadFailed() {
}
function fileDialogStart() {
if(this.customSettings.uploadSource == 'forum') {
this.customSettings.alertType = 0;
if(this.customSettings.uploadFrom == 'fastpost') {
if(typeof forum_post_inited == 'undefined') {
appendscript(JSPATH + 'forum_post.js?' + VERHASH);
}
}
}
}
function fileQueued(file) {
try {
var createQueue = true;
if(this.customSettings.uploadSource == 'forum' && this.customSettings.uploadType == 'poll') {
var inputObj = $(this.customSettings.progressTarget+'_aid');
if(inputObj && parseInt(inputObj.value)) {
this.addPostParam('aid', inputObj.value);
}
} else if(this.customSettings.uploadSource == 'portal') {
var inputObj = $('catid');
if (inputObj && parseInt(inputObj.value)) {
this.addPostParam('catid', inputObj.value);
}else if(typeof check_catid == 'function' && !check_catid()) {
this.uploader.cancelFile(file);
return false;
}
}
this.addPostParam('filetype', file.type);
var progress = new FileProgress(file, this.customSettings.progressTarget);
if(this.customSettings.uploadSource == 'forum') {
if(this.customSettings.maxAttachNum != undefined) {
if(this.customSettings.maxAttachNum > 0) {
this.customSettings.maxAttachNum--;
} else {
this.customSettings.alertType = 6;
createQueue = false;
}
}
if(createQueue && this.customSettings.maxSizePerDay != undefined) {
if(this.customSettings.maxSizePerDay - file.size > 0) {
this.customSettings.maxSizePerDay = this.customSettings.maxSizePerDay - file.size
} else {
this.customSettings.alertType = 11;
createQueue = false;
}
}
if(createQueue && this.customSettings.filterType != undefined) {
var fileSize = this.customSettings.filterType[file.source.ext.toLowerCase()];
if(fileSize != undefined && fileSize && file.size > fileSize) {
this.customSettings.alertType = 5;
createQueue = false;
}
}
}
if(createQueue) {
progress.setStatus("等待上传...");
this.uploader.upload(file);
} else {
this.uploader.cancelFile(file);
progress.setStatus(this.customSettings.alertType ? STATUSMSG[this.customSettings.alertType] : "Cancelled");
progress.setCancelled();
}
progress.toggleCancel(true, this);
} catch (ex) {
this.debug(ex);
}
}
function fileQueueError(errorCode) {
try {
var err = '';
switch (errorCode) {
case 'F_EXCEED_SIZE':
err = '单个文件大小不得超过' + WebUploader.Base.formatSize(this.uploader.option('fileSingleSizeLimit')) + '';
break;
case 'Q_EXCEED_NUM_LIMIT':
err = '最多只能上传' + this.settings.fileNumLimit + '个!';
break;
case 'Q_EXCEED_SIZE_LIMIT':
err = '上传文件总大小超出' + WebUploader.Base.formatSize(this.uploader.option('fileSizeLimit')) + '';
break;
case 'Q_TYPE_DENIED':
err = '无效文件类型,请上传正确的文件格式!';
break;
case 'F_DUPLICATE':
err = '请不要重复上传相同文件!';
break;
default:
err = '上传错误,请刷新重试!' + code;
break;
}
showDialog(err, 'notice', null, null, 0, null, null, null, null, sdCloseTime);
} catch (ex) {
this.debug(ex);
}
}
function fileDialogComplete() {
try {
if(this.customSettings.uploadSource == 'forum') {
if(this.customSettings.uploadType == 'attach') {
if(typeof switchAttachbutton == "function") {
switchAttachbutton('attachlist');
}
try {
$('attach_tblheader').style.display = '';
$('attach_notice').style.display = '';
} catch (ex) {}
} else if(this.customSettings.uploadType == 'image') {
if(typeof switchImagebutton == "function") {
switchImagebutton('imgattachlist');
}
try {
$('imgattach_notice').style.display = '';
} catch (ex) {}
}
var objId = this.customSettings.uploadType == 'attach' ? 'attachlist' : 'imgattachlist';
var listObj = $(objId);
var tableObj = listObj.getElementsByTagName("table");
if(!tableObj.length) {
listObj.innerHTML = "";
}
} else if(this.customSettings.uploadType == 'blog') {
if(typeof switchImagebutton == "function") {
switchImagebutton('imgattachlist');
}
}
} catch (ex) {
this.debug(ex);
}
}
function uploadStart(file) {
try {
if(this.customSettings.uploadSource == 'forum' && this.customSettings.uploadType == 'poll') {
var preObj = $(this.customSettings.progressTarget);
preObj.style.display = 'none';
preObj.innerHTML = '';
}
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus("上传中...");
progress.toggleCancel(true, this);
if(this.customSettings.uploadSource == 'forum') {
var objId = this.customSettings.uploadType == 'attach' ? 'attachlist' : 'imgattachlist';
var attachlistObj = $(objId).parentNode;
attachlistObj.scrollTop = $(file.id).offsetTop - attachlistObj.clientHeight;
}
} catch (ex) {
}
}
function uploadProgress(file, percentage) {
try {
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus("正在上传 <progress value='" + percentage + "' max='1' style='width: 200px;'></progress> " + Math.ceil(percentage * 100) + "%");
} catch (ex) {
this.debug(ex);
}
}
function uploadSuccess(file, serverData) {
try {
var progress = new FileProgress(file, this.customSettings.progressTarget);
if(this.customSettings.uploadSource == 'forum') {
if(this.customSettings.uploadType == 'poll') {
var data = serverData;
if(parseInt(data.aid)) {
var preObj = $(this.customSettings.progressTarget);
preObj.innerHTML = "";
preObj.style.display = '';
var img = new Image();
img.src = IMGDIR + '/attachimg_2.png';//data.smallimg;
var imgObj = document.createElement("img");
imgObj.src = img.src;
imgObj.className = "cur1";
imgObj.onmouseout = function(){hideMenu('poll_img_preview_'+data.aid+'_menu');};//"hideMenu('poll_img_preview_"+data.aid+"_menu');";
imgObj.onmouseover = function(){showMenu({'menuid':'poll_img_preview_'+data.aid+'_menu','ctrlclass':'a','duration':2,'timeout':0,'pos':'34'});};//"showMenu({'menuid':'poll_img_preview_"+data.aid+"_menu','ctrlclass':'a','duration':2,'timeout':0,'pos':'34'});";
preObj.appendChild(imgObj);
var inputObj = document.createElement("input");
inputObj.type = 'hidden';
inputObj.name = 'pollimage[]';
inputObj.id = this.customSettings.progressTarget+'_aid';
inputObj.value= data.aid;
preObj.appendChild(inputObj);
var preImgObj = document.createElement("span");
preImgObj.style.display = 'none';
preImgObj.id = 'poll_img_preview_'+data.aid+'_menu';
img = new Image();
img.src = data.smallimg;
imgObj = document.createElement("img");
imgObj.src = img.src;
preImgObj.appendChild(imgObj);
preObj.appendChild(preImgObj);
}
} else {
aid = parseInt(serverData);
if(aid > 0) {
if(this.customSettings.uploadType == 'attach') {
ajaxget('forum.php?mod=ajax&action=attachlist&aids=' + aid + (!fid ? '' : '&fid=' + fid)+(typeof resulttype == 'undefined' ? '' : '&result=simple'), file.id);
} else if(this.customSettings.uploadType == 'image') {
var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'image_td_'+aid);
ajaxget('forum.php?mod=ajax&action=imagelist&type=single&pid=' + pid + '&aids=' + aid + (!fid ? '' : '&fid=' + fid), tdObj.id);
$(file.id).style.display = 'none';
}
} else {
aid = aid < -1 ? Math.abs(aid) : aid;
if(typeof STATUSMSG[aid] == "string") {
progress.setStatus(STATUSMSG[aid]);
showDialog(STATUSMSG[aid], 'notice', null, null, 0, null, null, null, null, sdCloseTime);
} else {
progress.setStatus("取消上传");
}
this.uploader.cancelFile(file);
progress.setCancelled();
progress.toggleCancel(true, this.uploader);
}
}
} else if(this.customSettings.uploadType == 'album') {
var data = serverData;
if(parseInt(data.picid)) {
var newTr = document.createElement("TR");
var newTd = document.createElement("TD");
var img = new Image();
img.src = data.url;
var imgObj = document.createElement("img");
imgObj.src = img.src;
newTd.className = 'c';
newTd.appendChild(imgObj);
newTr.appendChild(newTd);
newTd = document.createElement("TD");
newTd.innerHTML = '<strong>'+file.name+'</strong>';
newTr.appendChild(newTd);
newTd = document.createElement("TD");
newTd.className = 'd';
newTd.innerHTML = '图片描述<br/><textarea name="title['+data.picid+']" cols="40" rows="2" class="pt"></textarea>';
newTr.appendChild(newTd);
this.customSettings.imgBoxObj.appendChild(newTr);
} else {
showDialog('图片上传失败', 'notice', null, null, 0, null, null, null, null, sdCloseTime);
}
$(file.id).style.display = 'none';
} else if(this.customSettings.uploadType == 'blog') {
var data = serverData;
if(parseInt(data.picid)) {
var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'image_td_'+data.picid);
var img = new Image();
img.src = data.url;
var imgObj = document.createElement("img");
imgObj.src = img.src;
imgObj.className = "cur1";
imgObj.onclick = function() {insertImage(data.bigimg);};
tdObj.appendChild(imgObj);
var inputObj = document.createElement("input");
inputObj.type = 'hidden';
inputObj.name = 'picids['+data.picid+']';
inputObj.value= data.picid;
tdObj.appendChild(inputObj);
} else {
showDialog('图片上传失败', 'notice', null, null, 0, null, null, null, null, sdCloseTime);
}
$(file.id).style.display = 'none';
} else if(this.customSettings.uploadSource == 'portal') {
var data = serverData;
if(data.aid) {
if(this.customSettings.uploadType == 'attach') {
ajaxget('portal.php?mod=attachment&op=getattach&type=attach&id=' + data.aid, file.id);
if($('attach_tblheader')) {
$('attach_tblheader').style.display = '';
}
} else {
var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'attach_list_'+data.aid);
ajaxget('portal.php?mod=attachment&op=getattach&id=' + data.aid, tdObj.id);
$(file.id).style.display = 'none';
}
} else {
showDialog('上传失败', 'notice', null, null, 0, null, null, null, null, sdCloseTime);
progress.setStatus("Cancelled");
this.uploader.cancelFile(file);
progress.setCancelled();
progress.toggleCancel(true, this.uploader);
}
} else {
progress.setComplete();
progress.setStatus("上传完成.");
progress.toggleCancel(false);
}
} catch (ex) {
this.debug(ex);
}
}
function uploadComplete(file) {
}
function uploadError(file, message) {
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus("Upload Failed.");
progress.setCancelled();
}
function getInsertTdId(boxObj, tdId) {
var tableObj = boxObj.getElementsByTagName("table");
var tbodyObj, trObj, tdObj;
if (!tableObj.length) {
tableObj = document.createElement("table");
tableObj.className = "imgl";
tbodyObj = document.createElement("TBODY");
tableObj.appendChild(tbodyObj);
boxObj.appendChild(tableObj);
} else if (!tableObj[0].getElementsByTagName("tbody").length) {
tbodyObj = document.createElement("TBODY");
tableObj.appendChild(tbodyObj);
} else {
tableObj = tableObj[0];
tbodyObj = tableObj.getElementsByTagName("tbody")[0];
}
var createTr = true;
var inserID = 0;
if (tbodyObj.childNodes.length) {
trObj = tbodyObj.childNodes[tbodyObj.childNodes.length - 1];
var findObj = trObj.getElementsByTagName("TD");
for (var j = 0; j < findObj.length; j++) {
if (findObj[j].id == "") {
inserID = j;
tdObj = findObj[j];
break;
}
}
if (inserID) {
createTr = false;
}
}
if (createTr) {
trObj = document.createElement("TR");
for (var i = 0; i < 4; i++) {
var newTd = document.createElement("TD");
newTd.width = "25%";
newTd.vAlign = "bottom";
newTd.appendChild(document.createTextNode(" "));
trObj.appendChild(newTd);
}
tdObj = trObj.childNodes[0];
tbodyObj.appendChild(trObj);
}
tdObj.id = tdId;
return tdObj;
}
function FileProgress(file, targetID) {
this.fileProgressID = file.id;
this.opacity = 100;
this.height = 0;
this.fileProgressWrapper = document.getElementById(this.fileProgressID);
if (!this.fileProgressWrapper) {
this.fileProgressWrapper = document.createElement("div");
this.fileProgressWrapper.className = "progressWrapper";
this.fileProgressWrapper.id = this.fileProgressID;
this.fileProgressElement = document.createElement("div");
this.fileProgressElement.className = "progressContainer";
var progressCancel = document.createElement("a");
progressCancel.className = "progressCancel";
progressCancel.href = "javascript:;";
progressCancel.style.display = "none";
progressCancel.appendChild(document.createTextNode(" "));
var progressText = document.createElement("div");
progressText.className = "progressName";
progressText.appendChild(document.createTextNode(file.name));
var progressBar = document.createElement("div");
progressBar.className = "progressBarInProgress";
var progressStatus = document.createElement("div");
progressStatus.className = "progressBarStatus";
progressStatus.innerHTML = "&nbsp;";
this.fileProgressElement.appendChild(progressCancel);
this.fileProgressElement.appendChild(progressText);
this.fileProgressElement.appendChild(progressStatus);
this.fileProgressElement.appendChild(progressBar);
this.fileProgressWrapper.appendChild(this.fileProgressElement);
document.getElementById(targetID).appendChild(this.fileProgressWrapper);
} else {
this.fileProgressElement = this.fileProgressWrapper.firstChild;
this.reset();
}
this.height = this.fileProgressWrapper.offsetHeight;
this.setTimer(null);
}
FileProgress.prototype.setTimer = function(timer) {
this.fileProgressElement["FP_TIMER"] = timer;
};
FileProgress.prototype.getTimer = function(timer) {
return this.fileProgressElement["FP_TIMER"] || null;
};
FileProgress.prototype.reset = function() {
try {
this.fileProgressElement.className = "progressContainer";
this.fileProgressElement.childNodes[2].innerHTML = "&nbsp;";
this.fileProgressElement.childNodes[2].className = "progressBarStatus";
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
this.fileProgressElement.childNodes[3].style.width = "0%";
this.appear();
} catch(ex) {}
};
FileProgress.prototype.setProgress = function(percentage) {
this.fileProgressElement.className = "progressContainer green";
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
this.appear();
};
FileProgress.prototype.setComplete = function() {
this.fileProgressElement.className = "progressContainer blue";
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
this.fileProgressElement.childNodes[3].style.width = "";
};
FileProgress.prototype.setError = function() {
this.fileProgressElement.className = "progressContainer red";
this.fileProgressElement.childNodes[3].className = "progressBarError";
this.fileProgressElement.childNodes[3].style.width = "";
var oSelf = this;
this.setTimer(setTimeout(function() {
oSelf.disappear();
},
5000));
};
FileProgress.prototype.setCancelled = function() {
this.fileProgressElement.className = "progressContainer";
this.fileProgressElement.childNodes[3].className = "progressBarError";
this.fileProgressElement.childNodes[3].style.width = "";
var oSelf = this;
this.setTimer(setTimeout(function() {
oSelf.disappear();
},
2000));
};
FileProgress.prototype.setStatus = function(status) {
this.fileProgressElement.childNodes[2].innerHTML = status;
};
FileProgress.prototype.toggleCancel = function(show, swfUploadInstance) {
this.fileProgressElement.childNodes[0].style.display = show ? "": "none";
if (swfUploadInstance) {
var fileID = this.fileProgressID;
var oSelf = this;
this.fileProgressElement.childNodes[0].onclick = function() {
swfUploadInstance.cancelFile(fileID);
oSelf.setStatus("Cancelled");
oSelf.setCancelled();
return false;
};
}
};
FileProgress.prototype.appear = function() {
if (this.getTimer() !== null) {
clearTimeout(this.getTimer());
this.setTimer(null);
}
if (this.fileProgressWrapper.filters) {
try {
this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100;
} catch(e) {
this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
}
} else {
this.fileProgressWrapper.style.opacity = 1;
}
this.fileProgressWrapper.style.height = "";
this.height = this.fileProgressWrapper.offsetHeight;
this.opacity = 100;
this.fileProgressWrapper.style.display = "";
};
FileProgress.prototype.disappear = function() {
var reduceOpacityBy = 15;
var reduceHeightBy = 4;
var rate = 30; // 15 fps
if (this.opacity > 0) {
this.opacity -= reduceOpacityBy;
if (this.opacity < 0) {
this.opacity = 0;
}
if (this.fileProgressWrapper.filters) {
try {
this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity;
} catch(e) {
this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
}
} else {
this.fileProgressWrapper.style.opacity = this.opacity / 100;
}
}
if (this.height > 0) {
this.height -= reduceHeightBy;
if (this.height < 0) {
this.height = 0;
}
this.fileProgressWrapper.style.height = this.height + "px";
}
if (this.height > 0 || this.opacity > 0) {
var oSelf = this;
this.setTimer(setTimeout(function() {
oSelf.disappear();
},
rate));
} else {
this.fileProgressWrapper.style.display = "none";
this.setTimer(null);
}
};

View File

View File

@@ -0,0 +1,10 @@
.webuploader-container {
position: relative;
}
.webuploader-element-invisible {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px,1px,1px,1px);
}
.webuploader-pick{text-indent:-999em;}

File diff suppressed because one or more lines are too long