Diff
checker
文本
文本
圖像
文檔
Excel
文件夾
Legal
Enterprise
桌面版
定價
登入
下載 Diffchecker 桌面版
比較文本
尋找兩個文字檔案之間的差異
工具
歷史
即時編輯器
摺疊未變更行
關閉換行
檢視
拆分
統一
比對精度
智能
單詞
字符
語法突出顯示
選擇語法
忽略
文字轉換
前往第一個差異
編輯輸入
Diffchecker Desktop
執行Diffchecker最安全的方式。取得Diffchecker桌面應用程式:您的差異永遠不會離開您的電腦!
取得桌面版
Untitled diff
建立於
7 年前
差異永不過期
清除
匯出
分享
解釋
60 刪除
行
總計
刪除
字符
總計
刪除
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
352 行
全部複製
31 新增
行
總計
新增
字符
總計
新增
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
349 行
全部複製
複製
已複製
複製
已複製
/*##################################################
/**
* bbcode.js
*
@
copyright
©
2005
-2019 PHPBoost
* -------------------
*
@license
https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0
* begin : August 01, 2005
* @author
Regis VIARRE <
crowkait@phpboost.com
>
*
copyright
: (C)
2005
Viarre Régis
* @version PHPBoost 5.2 - last update: 2018 11 18
*
email
:
crowkait@phpboost.com
* @since PHPBoost 1.2 - 2005 08 01
*
* @contributor Julien BRISWALTER <j1.seth@phpboost.com>
*
* @contributor Arnaud GENET <elenwii@phpboost.com>
###################################################
* @contributor Sebastien LARTIGUE <babsolune@phpboost.com>
*
*/
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
###################################################*/
function textarea_resize(id, px, type)
function textarea_resize(id, px, type)
{
{
var textarea = document.getElementById(id);
var textarea = document.getElementById(id);
if( type == 'height' )
if( type == 'height' )
{
{
var current_height = parseInt(textarea.style.height) ? parseInt(textarea.style.height) : 300;
var current_height = parseInt(textarea.style.height) ? parseInt(textarea.style.height) : 300;
var new_height = current_height + px;
var new_height = current_height + px;
複製
已複製
複製
已複製
if( new_height > 40 )
if( new_height > 40 )
textarea.style.height = new_height + "px";
textarea.style.height = new_height + "px";
}
}
else
else
{
{
var current_width = parseInt(textarea.style.width) ? parseInt(textarea.style.width) : 150;
var current_width = parseInt(textarea.style.width) ? parseInt(textarea.style.width) : 150;
var new_width = current_width + px;
var new_width = current_width + px;
複製
已複製
複製
已複製
if( new_width > 40 )
if( new_width > 40 )
textarea.style.width = new_width + "px";
textarea.style.width = new_width + "px";
}
}
複製
已複製
複製
已複製
return false;
return false;
}
}
//Insertion dans le champs.
//Insertion dans le champs.
function simple_insert(open_balise, close_balise, field)
function simple_insert(open_balise, close_balise, field)
{
{
var textarea = document.getElementById(field);
var textarea = document.getElementById(field);
var scroll = textarea.scrollTop;
var scroll = textarea.scrollTop;
複製
已複製
複製
已複製
if( close_balise != "" && close_balise != "smile" )
if( close_balise != "" && close_balise != "smile" )
textarea.value += '[' + open_balise + '][/' + close_balise + ']';
textarea.value += '[' + open_balise + '][/' + close_balise + ']';
else if( close_balise == "smile" )
else if( close_balise == "smile" )
textarea.value += ' ' + open_balise + ' ';
textarea.value += ' ' + open_balise + ' ';
複製
已複製
複製
已複製
textarea.focus();
textarea.focus();
textarea.scrollTop = scroll;
textarea.scrollTop = scroll;
return;
return;
}
}
//Récupération de la sélection sur netscape, ajout des balises autour.
//Récupération de la sélection sur netscape, ajout des balises autour.
function netscape_sel(target, open_balise, close_balise)
function netscape_sel(target, open_balise, close_balise)
{
{
var sel_length = target.textLength;
var sel_length = target.textLength;
var sel_start = target.selectionStart;
var sel_start = target.selectionStart;
var sel_end = target.selectionEnd;
var sel_end = target.selectionEnd;
var scroll = target.scrollTop; //Position verticale.
var scroll = target.scrollTop; //Position verticale.
複製
已複製
複製
已複製
if( sel_end == 1 || sel_end == 2 )
if( sel_end == 1 || sel_end == 2 )
{
{
sel_end = sel_length;
sel_end = sel_length;
}
}
var string_start = (target.value).substring(0, sel_start);
var string_start = (target.value).substring(0, sel_start);
var selection = (target.value).substring(sel_start, sel_end);
var selection = (target.value).substring(sel_start, sel_end);
var string_end = (target.value).substring(sel_end, sel_length);
var string_end = (target.value).substring(sel_end, sel_length);
if( close_balise != "" && selection == "" && close_balise != "smile" )
if( close_balise != "" && selection == "" && close_balise != "smile" )
{
{
target.value = string_start + open_balise + close_balise + string_end;
target.value = string_start + open_balise + close_balise + string_end;
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.focus();
target.focus();
}
}
else if( close_balise == "smile" )
else if( close_balise == "smile" )
{
{
複製
已複製
複製
已複製
target.value = string_start + selection + ' ' + open_balise + ' ' + string_end;
target.value = string_start + selection + ' ' + open_balise + ' ' + string_end;
target.setSelectionRange(string_start.length + open_balise.length + 2, target.value.length - string_end.length);
target.setSelectionRange(string_start.length + open_balise.length + 2, target.value.length - string_end.length);
target.focus();
target.focus();
}
}
else
else
{
{
target.value = string_start + open_balise + selection + close_balise + string_end;
target.value = string_start + open_balise + selection + close_balise + string_end;
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.focus();
target.focus();
}
}
複製
已複製
複製
已複製
target.scrollTop = scroll; //Remet à la bonne position le textarea.
target.scrollTop = scroll; //Remet à la bonne position le textarea.
return;
return;
}
}
//Récupération de la sélection sur IE, ajout des balises autour.
//Récupération de la sélection sur IE, ajout des balises autour.
function ie_sel(target, open_balise, close_balise)
function ie_sel(target, open_balise, close_balise)
{
{
selText = false;
selText = false;
var scroll = target.scrollTop; //Position verticale.
var scroll = target.scrollTop; //Position verticale.
複製
已複製
複製
已複製
selection = document.selection.createRange().text; // Sélection
selection = document.selection.createRange().text; // Sélection
if( close_balise != "" && selection == "" && close_balise != "smile" )
if( close_balise != "" && selection == "" && close_balise != "smile" )
document.selection.createRange().text = open_balise + close_balise;
document.selection.createRange().text = open_balise + close_balise;
else if( close_balise == "smile" )
else if( close_balise == "smile" )
document.selection.createRange().text = selection + open_balise + ' ';
document.selection.createRange().text = selection + open_balise + ' ';
else
else
複製
已複製
複製
已複製
document.selection.createRange().text = open_balise + selection + close_balise;
document.selection.createRange().text = open_balise + selection + close_balise;
target.scrollTop = scroll; //Remet à la bonne position le textarea.
target.scrollTop = scroll; //Remet à la bonne position le textarea.
selText = '';
selText = '';
複製
已複製
複製
已複製
return;
return;
}
}
//Fonction de remplacement des caractères spéciaux
//Fonction de remplacement des caractères spéciaux
function url_encode_rewrite(link_name)
function url_encode_rewrite(link_name)
{
{
link_name = link_name.toLowerCase(link_name);
link_name = link_name.toLowerCase(link_name);
複製
已複製
複製
已複製
var chars_special = new Array(/ /g, /é/g, /è/g, /ê/g, /à/g, /â/g, /ù/g, /ü/g, /û/g, /ï/g, /î/g, /ô/g, /ç/g);
var chars_special = new Array(/ /g, /é/g, /è/g, /ê/g, /à/g, /â/g, /ù/g, /ü/g, /û/g, /ï/g, /î/g, /ô/g, /ç/g);
var chars_replace = new Array("-", "e", "e", "e", "a", "a", "u", "u", "u", "i", "i", "o", "c");
var chars_replace = new Array("-", "e", "e", "e", "a", "a", "u", "u", "u", "i", "i", "o", "c");
var nbr_chars = chars_special.length;
var nbr_chars = chars_special.length;
for( var i = 0; i < nbr_chars; i++)
for( var i = 0; i < nbr_chars; i++)
{
{
複製
已複製
複製
已複製
link_name = link_name.replace(chars_special[i], chars_replace[i]);
link_name = link_name.replace(chars_special[i], chars_replace[i]);
}
}
link_name = link_name.replace(/([^a-z0-9]|[\s])/g, '-');
link_name = link_name.replace(/([^a-z0-9]|[\s])/g, '-');
link_name = link_name.replace(/([-]{2,})/g, '-');
link_name = link_name.replace(/([-]{2,})/g, '-');
return link_name.replace(/(^\s*)|(\s*$)/g,'').replace(/(^-)|(-$)/g,'');
return link_name.replace(/(^\s*)|(\s*$)/g,'').replace(/(^-)|(-$)/g,'');
}
}
//Fonction d'insertion du BBcode dans le champs, tient compte du navigateur utilisé.
//Fonction d'insertion du BBcode dans le champs, tient compte du navigateur utilisé.
function insertbbcode(open_balise, close_balise, field)
function insertbbcode(open_balise, close_balise, field)
{
{
var area = document.getElementById(field);
var area = document.getElementById(field);
var nav = navigator.appName; //Recupère le nom du navigateur
var nav = navigator.appName; //Recupère le nom du navigateur
area.focus();
area.focus();
if( nav == 'Microsoft Internet Explorer' ) // Internet Explorer
if( nav == 'Microsoft Internet Explorer' ) // Internet Explorer
ie_sel(area, open_balise, close_balise);
ie_sel(area, open_balise, close_balise);
else if( nav == 'Netscape' || nav == 'Opera' ) //Netscape ou opera
else if( nav == 'Netscape' || nav == 'Opera' ) //Netscape ou opera
netscape_sel(area, open_balise, close_balise);
netscape_sel(area, open_balise, close_balise);
else //insertion normale (autres navigateurs)
else //insertion normale (autres navigateurs)
simple_insert(open_balise, close_balise, field);
simple_insert(open_balise, close_balise, field);
return;
return;
}
}
//Insertion dans le champs des codes de type select.
//Insertion dans le champs des codes de type select.
function insertbbcode_select(id_select, close_balise, field)
function insertbbcode_select(id_select, close_balise, field)
{
{
var select = document.getElementById(id_select + field);
var select = document.getElementById(id_select + field);
複製
已複製
複製
已複製
if( select.value != '' )
if( select.value != '' )
insertbbcode('[' + id_select + '=' + select.value + ']', close_balise, field);
insertbbcode('[' + id_select + '=' + select.value + ']', close_balise, field);
複製
已複製
複製
已複製
//On remet la valeur par défaut.
//On remet la valeur par défaut.
select.options[0].selected = true;
select.options[0].selected = true;
複製
已複製
複製
已複製
return;
return;
複製
已複製
複製
已複製
}
}
//Insertion dans le champs des codes de type select.
//Insertion dans le champs des codes de type select.
function insertbbcode_select2(id_select, field)
function insertbbcode_select2(id_select, field)
{
{
var select = document.getElementById(id_select + field);
var select = document.getElementById(id_select + field);
複製
已複製
複製
已複製
if( select.value != '' )
if( select.value != '' )
insertbbcode('[' + select.value + ']', '[/' + select.value + ']', field);
insertbbcode('[' + select.value + ']', '[/' + select.value + ']', field);
複製
已複製
複製
已複製
//On remet la valeur par défaut.
//On remet la valeur par défaut.
select.options[0].selected = true;
select.options[0].selected = true;
複製
已複製
複製
已複製
return;
return;
}
}
//Conserve la configuration de la barre bbcode.
//Conserve la configuration de la barre bbcode.
function set_bbcode_preference(divID)
function set_bbcode_preference(divID)
{
{
if( getCookie('hide-bbcode') == 0 )
if( getCookie('hide-bbcode') == 0 )
{
{
jQuery('#bbcode-expanded').removeClass('expand');
jQuery('#bbcode-expanded').removeClass('expand');
jQuery( "." + divID).each(function(){
jQuery( "." + divID).each(function(){
jQuery( "." + divID).hide();
jQuery( "." + divID).hide();
});
});
}
}
}
}
//Masquage du div.
//Masquage du div.
function show_bbcode_div(divID)
function show_bbcode_div(divID)
{
{
if( getCookie('hide-bbcode') == 0 )
if( getCookie('hide-bbcode') == 0 )
{
{
jQuery('#bbcode-expanded').addClass('expand');
jQuery('#bbcode-expanded').addClass('expand');
sendCookie('hide-bbcode', 1); //On envoi le cookie pour se souvenir du choix de l'utilisateur.
sendCookie('hide-bbcode', 1); //On envoi le cookie pour se souvenir du choix de l'utilisateur.
jQuery( "." + divID).each(function(){
jQuery( "." + divID).each(function(){
jQuery( "." + divID).fadeIn(300);
jQuery( "." + divID).fadeIn(300);
複製
已複製
複製
已複製
});
});
}
}
else
else
{
{
jQuery( "." + divID).each(function(){
jQuery( "." + divID).each(function(){
jQuery( "." + divID).fadeOut(300);
jQuery( "." + divID).fadeOut(300);
});
});
jQuery('#bbcode-expanded').removeClass('expand');
jQuery('#bbcode-expanded').removeClass('expand');
sendCookie('hide-bbcode', 0); //On envoi le cookie pour se souvenir du choix de l'utilisateur.
sendCookie('hide-bbcode', 0); //On envoi le cookie pour se souvenir du choix de l'utilisateur.
}
}
}
}
function bbcode_color(divID, field, type)
function bbcode_color(divID, field, type)
{
{
var i;
var i;
var br;
var br;
var contents;
var contents;
var color = new Array(
var color = new Array(
'#000000', '#433026', '#333300', '#003300', '#003366', '#000080', '#333399', '#333333',
'#000000', '#433026', '#333300', '#003300', '#003366', '#000080', '#333399', '#333333',
'#800000', '#FFA500', '#808000', '#008000', '#008080', '#0000FF', '#666699', '#808080',
'#800000', '#FFA500', '#808000', '#008000', '#008080', '#0000FF', '#666699', '#808080',
'#F04343', '#FF9900', '#99CC00', '#339966', '#33CCCC', '#3366FF', '#800080', '#ACA899',
'#F04343', '#FF9900', '#99CC00', '#339966', '#33CCCC', '#3366FF', '#800080', '#ACA899',
'#FFC0CB', '#FFCC00', '#FFFF00', '#00FF00', '#00FFFF', '#00CCFF', '#993366', '#C0C0C0',
'#FFC0CB', '#FFCC00', '#FFFF00', '#00FF00', '#00FFFF', '#00CCFF', '#993366', '#C0C0C0',
'#FF99CC', '#FFCC99', '#FFFF99', '#CCFFCC', '#CCFFFF', '#CC99FF', '#E3007B', '#FFFFFF');
'#FF99CC', '#FFCC99', '#FFFF99', '#CCFFCC', '#CCFFFF', '#CC99FF', '#E3007B', '#FFFFFF');
contents = '<table><tr>';
contents = '<table><tr>';
for(i = 0; i < 40; i++)
for(i = 0; i < 40; i++)
{
{
br = (i+1) % 8;
br = (i+1) % 8;
br = (br == 0 && i != 0 && i < 39) ? '</tr><tr>' : '';
br = (br == 0 && i != 0 && i < 39) ? '</tr><tr>' : '';
複製
已複製
複製
已複製
contents += '<td><a href="
" style="background
:' + color[i] + ';" onclick="insertbbcode(\'[' + type + '=' + color[i] + ']\', \'[/' + type + ']\', \'' + field + '\');bb_hide_block(\'' + divID + '\', \'' + field + '\', 0);return false;"></a></td>' + br;
contents += '<td><a href="
" aria-label="' + color[i] + '" title="' + color[i] + '
" style="background
-color
:' + color[i] + ';" onclick="insertbbcode(\'[' + type + '=' + color[i] + ']\', \'[/' + type + ']\', \'' + field + '\');bb_hide_block(\'' + divID + '\', \'' + field + '\', 0);return false;"></a></td>' + br;
}
}
document.getElementById("bb-"+ type + field).innerHTML = contents + '</tr></table>';
document.getElementById("bb-"+ type + field).innerHTML = contents + '</tr></table>';
}
}
function bbcode_table(field, head_name)
function bbcode_table(field, head_name)
{
{
var cols = document.getElementById('bb-cols' + field).value;
var cols = document.getElementById('bb-cols' + field).value;
var lines = document.getElementById('bb-lines' + field).value;
var lines = document.getElementById('bb-lines' + field).value;
var head = document.getElementById('bb-head' + field).checked;
var head = document.getElementById('bb-head' + field).checked;
var code = '';
var code = '';
複製
已複製
複製
已複製
if( cols >= 0 && lines >= 0 )
if( cols >= 0 && lines >= 0 )
{
{
var colspan = cols > 1 ? ' colspan="' + cols + '"' : '';
var colspan = cols > 1 ? ' colspan="' + cols + '"' : '';
var pointor = head ? (59 + colspan.length) : 22;
var pointor = head ? (59 + colspan.length) : 22;
code = head ? '[table]\n\t[row]\n\t\t[head' + colspan + ']'+ head_name +'[/head]\n\t[/row]\n' : '[table]\n';
code = head ? '[table]\n\t[row]\n\t\t[head' + colspan + ']'+ head_name +'[/head]\n\t[/row]\n' : '[table]\n';
複製
已複製
複製
已複製
for(var i = 0; i < lines; i++)
for(var i = 0; i < lines; i++)
{
{
code += '\t[row]\n';
code += '\t[row]\n';
for(var j = 0; j < cols; j++)
for(var j = 0; j < cols; j++)
code += '\t\t[col][/col]\n';
code += '\t\t[col][/col]\n';
code += '\t[/row]\n';
code += '\t[/row]\n';
}
}
code += '[/table]';
code += '[/table]';
複製
已複製
複製
已複製
insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field);
insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field);
}
}
}
}
function bbcode_list(field)
function bbcode_list(field)
{
{
var elements = document.getElementById('bb_list' + field).value;
var elements = document.getElementById('bb_list' + field).value;
var ordered_list = document.getElementById('bb_ordered_list' + field).checked;
var ordered_list = document.getElementById('bb_ordered_list' + field).checked;
if( elements <= 0 )
if( elements <= 0 )
elements = 1;
elements = 1;
複製
已複製
複製
已複製
var pointor = ordered_list ? 19 : 11;
var pointor = ordered_list ? 19 : 11;
複製
已複製
複製
已複製
code = '[list' + (ordered_list ? '=ordered' : '') + ']\n';
code = '[list' + (ordered_list ? '=ordered' : '') + ']\n';
for(var j = 0; j < elements; j++)
for(var j = 0; j < elements; j++)
code += '\t[*]\n';
code += '\t[*]\n';
code += '[/list]';
code += '[/list]';
insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field);
insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field);
}
}
function bbcode_url(field, prompt_text)
function bbcode_url(field, prompt_text)
{
{
var url = prompt(prompt_text, '');
var url = prompt(prompt_text, '');
if(url != '' && url != null)
if(url != '' && url != null)
insertbbcode('[url=' + url + ']', '[/url]', field);
insertbbcode('[url=' + url + ']', '[/url]', field);
}
}
複製
已複製
複製
已複製
function bbcode_quote(field, prompt_text)
{
var author = prompt(prompt_text, '');
if(author != null)
{
if(author != '')
insertbbcode('[quote=' + author + ']', '[/quote]', field);
else
insertbbcode('[quote]', '[/quote]', field);
}
}
function bbcode_lightbox(field, prompt_text)
function bbcode_lightbox(field, prompt_text)
{
{
var url = prompt(prompt_text, '');
var url = prompt(prompt_text, '');
if(url != '' && url != null)
if(url != '' && url != null)
insertbbcode('[lightbox=' + url + '][img style="max-width: 150px;"]' + url, '[/img][/lightbox]', field);
insertbbcode('[lightbox=' + url + '][img style="max-width: 150px;"]' + url, '[/img][/lightbox]', field);
}
}
function bbcode_anchor(field, prompt_text)
function bbcode_anchor(field, prompt_text)
{
{
var anchor = prompt(prompt_text, '');
var anchor = prompt(prompt_text, '');
if(anchor != '' && anchor != null)
if(anchor != '' && anchor != null)
insertbbcode('[anchor=' + url_encode_rewrite(anchor) + ']', '[/anchor]', field);
insertbbcode('[anchor=' + url_encode_rewrite(anchor) + ']', '[/anchor]', field);
else
else
insertbbcode('[anchor]', '[/anchor]', field);
insertbbcode('[anchor]', '[/anchor]', field);
}
}
function bbcode_abbr(field, prompt_text)
function bbcode_abbr(field, prompt_text)
{
{
var desc = prompt(prompt_text, '');
var desc = prompt(prompt_text, '');
複製
已複製
複製
已複製
if(desc != '' && desc != null)
if(desc != '' && desc != null)
insertbbcode('[abbr=' + desc + ']', '[/abbr]', field);
insertbbcode('[abbr=' + desc + ']', '[/abbr]', field);
else
else
insertbbcode('[abbr]', '[/abbr]', field);
insertbbcode('[abbr]', '[/abbr]', field);
}
}
function bbcode_acronym(field, prompt_text)
function bbcode_acronym(field, prompt_text)
{
{
var desc = prompt(prompt_text, '');
var desc = prompt(prompt_text, '');
複製
已複製
複製
已複製
if(desc != '' && desc != null)
if(desc != '' && desc != null)
insertbbcode('[acronym=' + desc + ']', '[/acronym]', field);
insertbbcode('[acronym=' + desc + ']', '[/acronym]', field);
else
else
insertbbcode('[acronym]', '[/acronym]', field);
insertbbcode('[acronym]', '[/acronym]', field);
}
}
function bbcode_fieldset(field, prompt_text)
function bbcode_fieldset(field, prompt_text)
{
{
var legend = prompt(prompt_text, '');
var legend = prompt(prompt_text, '');
if(legend != '' && legend != null)
if(legend != '' && legend != null)
insertbbcode('[fieldset legend="' + legend + '"]', '[/fieldset]', field);
insertbbcode('[fieldset legend="' + legend + '"]', '[/fieldset]', field);
else
else
insertbbcode('[fieldset]', '[/fieldset]', field);
insertbbcode('[fieldset]', '[/fieldset]', field);
}
}
function bbcode_mail(field, prompt_text)
function bbcode_mail(field, prompt_text)
{
{
var mail = prompt(prompt_text, '');
var mail = prompt(prompt_text, '');
if(mail != '' && mail != null)
if(mail != '' && mail != null)
insertbbcode('[mail=' + mail + ']', '[/mail]', field);
insertbbcode('[mail=' + mail + ']', '[/mail]', field);
}
}
function bbcode_feed(field, prompt_text)
function bbcode_feed(field, prompt_text)
{
{
var feed = prompt(prompt_text, '');
var feed = prompt(prompt_text, '');
if(feed != '' && feed != null)
if(feed != '' && feed != null)
insertbbcode('[feed cat="0" number="5"]' + feed.toLowerCase(), '[/feed]', field);
insertbbcode('[feed cat="0" number="5"]' + feed.toLowerCase(), '[/feed]', field);
}
}
已保存差異
原始文本
開啟檔案
/*################################################## * bbcode.js * ------------------- * begin : August 01, 2005 * copyright : (C) 2005 Viarre Régis * email : crowkait@phpboost.com * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ function textarea_resize(id, px, type) { var textarea = document.getElementById(id); if( type == 'height' ) { var current_height = parseInt(textarea.style.height) ? parseInt(textarea.style.height) : 300; var new_height = current_height + px; if( new_height > 40 ) textarea.style.height = new_height + "px"; } else { var current_width = parseInt(textarea.style.width) ? parseInt(textarea.style.width) : 150; var new_width = current_width + px; if( new_width > 40 ) textarea.style.width = new_width + "px"; } return false; } //Insertion dans le champs. function simple_insert(open_balise, close_balise, field) { var textarea = document.getElementById(field); var scroll = textarea.scrollTop; if( close_balise != "" && close_balise != "smile" ) textarea.value += '[' + open_balise + '][/' + close_balise + ']'; else if( close_balise == "smile" ) textarea.value += ' ' + open_balise + ' '; textarea.focus(); textarea.scrollTop = scroll; return; } //Récupération de la sélection sur netscape, ajout des balises autour. function netscape_sel(target, open_balise, close_balise) { var sel_length = target.textLength; var sel_start = target.selectionStart; var sel_end = target.selectionEnd; var scroll = target.scrollTop; //Position verticale. if( sel_end == 1 || sel_end == 2 ) { sel_end = sel_length; } var string_start = (target.value).substring(0, sel_start); var selection = (target.value).substring(sel_start, sel_end); var string_end = (target.value).substring(sel_end, sel_length); if( close_balise != "" && selection == "" && close_balise != "smile" ) { target.value = string_start + open_balise + close_balise + string_end; target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length); target.focus(); } else if( close_balise == "smile" ) { target.value = string_start + selection + ' ' + open_balise + ' ' + string_end; target.setSelectionRange(string_start.length + open_balise.length + 2, target.value.length - string_end.length); target.focus(); } else { target.value = string_start + open_balise + selection + close_balise + string_end; target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length); target.focus(); } target.scrollTop = scroll; //Remet à la bonne position le textarea. return; } //Récupération de la sélection sur IE, ajout des balises autour. function ie_sel(target, open_balise, close_balise) { selText = false; var scroll = target.scrollTop; //Position verticale. selection = document.selection.createRange().text; // Sélection if( close_balise != "" && selection == "" && close_balise != "smile" ) document.selection.createRange().text = open_balise + close_balise; else if( close_balise == "smile" ) document.selection.createRange().text = selection + open_balise + ' '; else document.selection.createRange().text = open_balise + selection + close_balise; target.scrollTop = scroll; //Remet à la bonne position le textarea. selText = ''; return; } //Fonction de remplacement des caractères spéciaux function url_encode_rewrite(link_name) { link_name = link_name.toLowerCase(link_name); var chars_special = new Array(/ /g, /é/g, /è/g, /ê/g, /à/g, /â/g, /ù/g, /ü/g, /û/g, /ï/g, /î/g, /ô/g, /ç/g); var chars_replace = new Array("-", "e", "e", "e", "a", "a", "u", "u", "u", "i", "i", "o", "c"); var nbr_chars = chars_special.length; for( var i = 0; i < nbr_chars; i++) { link_name = link_name.replace(chars_special[i], chars_replace[i]); } link_name = link_name.replace(/([^a-z0-9]|[\s])/g, '-'); link_name = link_name.replace(/([-]{2,})/g, '-'); return link_name.replace(/(^\s*)|(\s*$)/g,'').replace(/(^-)|(-$)/g,''); } //Fonction d'insertion du BBcode dans le champs, tient compte du navigateur utilisé. function insertbbcode(open_balise, close_balise, field) { var area = document.getElementById(field); var nav = navigator.appName; //Recupère le nom du navigateur area.focus(); if( nav == 'Microsoft Internet Explorer' ) // Internet Explorer ie_sel(area, open_balise, close_balise); else if( nav == 'Netscape' || nav == 'Opera' ) //Netscape ou opera netscape_sel(area, open_balise, close_balise); else //insertion normale (autres navigateurs) simple_insert(open_balise, close_balise, field); return; } //Insertion dans le champs des codes de type select. function insertbbcode_select(id_select, close_balise, field) { var select = document.getElementById(id_select + field); if( select.value != '' ) insertbbcode('[' + id_select + '=' + select.value + ']', close_balise, field); //On remet la valeur par défaut. select.options[0].selected = true; return; } //Insertion dans le champs des codes de type select. function insertbbcode_select2(id_select, field) { var select = document.getElementById(id_select + field); if( select.value != '' ) insertbbcode('[' + select.value + ']', '[/' + select.value + ']', field); //On remet la valeur par défaut. select.options[0].selected = true; return; } //Conserve la configuration de la barre bbcode. function set_bbcode_preference(divID) { if( getCookie('hide-bbcode') == 0 ) { jQuery('#bbcode-expanded').removeClass('expand'); jQuery( "." + divID).each(function(){ jQuery( "." + divID).hide(); }); } } //Masquage du div. function show_bbcode_div(divID) { if( getCookie('hide-bbcode') == 0 ) { jQuery('#bbcode-expanded').addClass('expand'); sendCookie('hide-bbcode', 1); //On envoi le cookie pour se souvenir du choix de l'utilisateur. jQuery( "." + divID).each(function(){ jQuery( "." + divID).fadeIn(300); }); } else { jQuery( "." + divID).each(function(){ jQuery( "." + divID).fadeOut(300); }); jQuery('#bbcode-expanded').removeClass('expand'); sendCookie('hide-bbcode', 0); //On envoi le cookie pour se souvenir du choix de l'utilisateur. } } function bbcode_color(divID, field, type) { var i; var br; var contents; var color = new Array( '#000000', '#433026', '#333300', '#003300', '#003366', '#000080', '#333399', '#333333', '#800000', '#FFA500', '#808000', '#008000', '#008080', '#0000FF', '#666699', '#808080', '#F04343', '#FF9900', '#99CC00', '#339966', '#33CCCC', '#3366FF', '#800080', '#ACA899', '#FFC0CB', '#FFCC00', '#FFFF00', '#00FF00', '#00FFFF', '#00CCFF', '#993366', '#C0C0C0', '#FF99CC', '#FFCC99', '#FFFF99', '#CCFFCC', '#CCFFFF', '#CC99FF', '#E3007B', '#FFFFFF'); contents = '<table><tr>'; for(i = 0; i < 40; i++) { br = (i+1) % 8; br = (br == 0 && i != 0 && i < 39) ? '</tr><tr>' : ''; contents += '<td><a href="" style="background:' + color[i] + ';" onclick="insertbbcode(\'[' + type + '=' + color[i] + ']\', \'[/' + type + ']\', \'' + field + '\');bb_hide_block(\'' + divID + '\', \'' + field + '\', 0);return false;"></a></td>' + br; } document.getElementById("bb-"+ type + field).innerHTML = contents + '</tr></table>'; } function bbcode_table(field, head_name) { var cols = document.getElementById('bb-cols' + field).value; var lines = document.getElementById('bb-lines' + field).value; var head = document.getElementById('bb-head' + field).checked; var code = ''; if( cols >= 0 && lines >= 0 ) { var colspan = cols > 1 ? ' colspan="' + cols + '"' : ''; var pointor = head ? (59 + colspan.length) : 22; code = head ? '[table]\n\t[row]\n\t\t[head' + colspan + ']'+ head_name +'[/head]\n\t[/row]\n' : '[table]\n'; for(var i = 0; i < lines; i++) { code += '\t[row]\n'; for(var j = 0; j < cols; j++) code += '\t\t[col][/col]\n'; code += '\t[/row]\n'; } code += '[/table]'; insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field); } } function bbcode_list(field) { var elements = document.getElementById('bb_list' + field).value; var ordered_list = document.getElementById('bb_ordered_list' + field).checked; if( elements <= 0 ) elements = 1; var pointor = ordered_list ? 19 : 11; code = '[list' + (ordered_list ? '=ordered' : '') + ']\n'; for(var j = 0; j < elements; j++) code += '\t[*]\n'; code += '[/list]'; insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field); } function bbcode_url(field, prompt_text) { var url = prompt(prompt_text, ''); if(url != '' && url != null) insertbbcode('[url=' + url + ']', '[/url]', field); } function bbcode_lightbox(field, prompt_text) { var url = prompt(prompt_text, ''); if(url != '' && url != null) insertbbcode('[lightbox=' + url + '][img style="max-width: 150px;"]' + url, '[/img][/lightbox]', field); } function bbcode_anchor(field, prompt_text) { var anchor = prompt(prompt_text, ''); if(anchor != '' && anchor != null) insertbbcode('[anchor=' + url_encode_rewrite(anchor) + ']', '[/anchor]', field); else insertbbcode('[anchor]', '[/anchor]', field); } function bbcode_abbr(field, prompt_text) { var desc = prompt(prompt_text, ''); if(desc != '' && desc != null) insertbbcode('[abbr=' + desc + ']', '[/abbr]', field); else insertbbcode('[abbr]', '[/abbr]', field); } function bbcode_acronym(field, prompt_text) { var desc = prompt(prompt_text, ''); if(desc != '' && desc != null) insertbbcode('[acronym=' + desc + ']', '[/acronym]', field); else insertbbcode('[acronym]', '[/acronym]', field); } function bbcode_fieldset(field, prompt_text) { var legend = prompt(prompt_text, ''); if(legend != '' && legend != null) insertbbcode('[fieldset legend="' + legend + '"]', '[/fieldset]', field); else insertbbcode('[fieldset]', '[/fieldset]', field); } function bbcode_mail(field, prompt_text) { var mail = prompt(prompt_text, ''); if(mail != '' && mail != null) insertbbcode('[mail=' + mail + ']', '[/mail]', field); } function bbcode_feed(field, prompt_text) { var feed = prompt(prompt_text, ''); if(feed != '' && feed != null) insertbbcode('[feed cat="0" number="5"]' + feed.toLowerCase(), '[/feed]', field); }
更改後文本
開啟檔案
/** * @copyright © 2005-2019 PHPBoost * @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0 * @author Regis VIARRE <crowkait@phpboost.com> * @version PHPBoost 5.2 - last update: 2018 11 18 * @since PHPBoost 1.2 - 2005 08 01 * @contributor Julien BRISWALTER <j1.seth@phpboost.com> * @contributor Arnaud GENET <elenwii@phpboost.com> * @contributor Sebastien LARTIGUE <babsolune@phpboost.com> */ function textarea_resize(id, px, type) { var textarea = document.getElementById(id); if( type == 'height' ) { var current_height = parseInt(textarea.style.height) ? parseInt(textarea.style.height) : 300; var new_height = current_height + px; if( new_height > 40 ) textarea.style.height = new_height + "px"; } else { var current_width = parseInt(textarea.style.width) ? parseInt(textarea.style.width) : 150; var new_width = current_width + px; if( new_width > 40 ) textarea.style.width = new_width + "px"; } return false; } //Insertion dans le champs. function simple_insert(open_balise, close_balise, field) { var textarea = document.getElementById(field); var scroll = textarea.scrollTop; if( close_balise != "" && close_balise != "smile" ) textarea.value += '[' + open_balise + '][/' + close_balise + ']'; else if( close_balise == "smile" ) textarea.value += ' ' + open_balise + ' '; textarea.focus(); textarea.scrollTop = scroll; return; } //Récupération de la sélection sur netscape, ajout des balises autour. function netscape_sel(target, open_balise, close_balise) { var sel_length = target.textLength; var sel_start = target.selectionStart; var sel_end = target.selectionEnd; var scroll = target.scrollTop; //Position verticale. if( sel_end == 1 || sel_end == 2 ) { sel_end = sel_length; } var string_start = (target.value).substring(0, sel_start); var selection = (target.value).substring(sel_start, sel_end); var string_end = (target.value).substring(sel_end, sel_length); if( close_balise != "" && selection == "" && close_balise != "smile" ) { target.value = string_start + open_balise + close_balise + string_end; target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length); target.focus(); } else if( close_balise == "smile" ) { target.value = string_start + selection + ' ' + open_balise + ' ' + string_end; target.setSelectionRange(string_start.length + open_balise.length + 2, target.value.length - string_end.length); target.focus(); } else { target.value = string_start + open_balise + selection + close_balise + string_end; target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length); target.focus(); } target.scrollTop = scroll; //Remet à la bonne position le textarea. return; } //Récupération de la sélection sur IE, ajout des balises autour. function ie_sel(target, open_balise, close_balise) { selText = false; var scroll = target.scrollTop; //Position verticale. selection = document.selection.createRange().text; // Sélection if( close_balise != "" && selection == "" && close_balise != "smile" ) document.selection.createRange().text = open_balise + close_balise; else if( close_balise == "smile" ) document.selection.createRange().text = selection + open_balise + ' '; else document.selection.createRange().text = open_balise + selection + close_balise; target.scrollTop = scroll; //Remet à la bonne position le textarea. selText = ''; return; } //Fonction de remplacement des caractères spéciaux function url_encode_rewrite(link_name) { link_name = link_name.toLowerCase(link_name); var chars_special = new Array(/ /g, /é/g, /è/g, /ê/g, /à/g, /â/g, /ù/g, /ü/g, /û/g, /ï/g, /î/g, /ô/g, /ç/g); var chars_replace = new Array("-", "e", "e", "e", "a", "a", "u", "u", "u", "i", "i", "o", "c"); var nbr_chars = chars_special.length; for( var i = 0; i < nbr_chars; i++) { link_name = link_name.replace(chars_special[i], chars_replace[i]); } link_name = link_name.replace(/([^a-z0-9]|[\s])/g, '-'); link_name = link_name.replace(/([-]{2,})/g, '-'); return link_name.replace(/(^\s*)|(\s*$)/g,'').replace(/(^-)|(-$)/g,''); } //Fonction d'insertion du BBcode dans le champs, tient compte du navigateur utilisé. function insertbbcode(open_balise, close_balise, field) { var area = document.getElementById(field); var nav = navigator.appName; //Recupère le nom du navigateur area.focus(); if( nav == 'Microsoft Internet Explorer' ) // Internet Explorer ie_sel(area, open_balise, close_balise); else if( nav == 'Netscape' || nav == 'Opera' ) //Netscape ou opera netscape_sel(area, open_balise, close_balise); else //insertion normale (autres navigateurs) simple_insert(open_balise, close_balise, field); return; } //Insertion dans le champs des codes de type select. function insertbbcode_select(id_select, close_balise, field) { var select = document.getElementById(id_select + field); if( select.value != '' ) insertbbcode('[' + id_select + '=' + select.value + ']', close_balise, field); //On remet la valeur par défaut. select.options[0].selected = true; return; } //Insertion dans le champs des codes de type select. function insertbbcode_select2(id_select, field) { var select = document.getElementById(id_select + field); if( select.value != '' ) insertbbcode('[' + select.value + ']', '[/' + select.value + ']', field); //On remet la valeur par défaut. select.options[0].selected = true; return; } //Conserve la configuration de la barre bbcode. function set_bbcode_preference(divID) { if( getCookie('hide-bbcode') == 0 ) { jQuery('#bbcode-expanded').removeClass('expand'); jQuery( "." + divID).each(function(){ jQuery( "." + divID).hide(); }); } } //Masquage du div. function show_bbcode_div(divID) { if( getCookie('hide-bbcode') == 0 ) { jQuery('#bbcode-expanded').addClass('expand'); sendCookie('hide-bbcode', 1); //On envoi le cookie pour se souvenir du choix de l'utilisateur. jQuery( "." + divID).each(function(){ jQuery( "." + divID).fadeIn(300); }); } else { jQuery( "." + divID).each(function(){ jQuery( "." + divID).fadeOut(300); }); jQuery('#bbcode-expanded').removeClass('expand'); sendCookie('hide-bbcode', 0); //On envoi le cookie pour se souvenir du choix de l'utilisateur. } } function bbcode_color(divID, field, type) { var i; var br; var contents; var color = new Array( '#000000', '#433026', '#333300', '#003300', '#003366', '#000080', '#333399', '#333333', '#800000', '#FFA500', '#808000', '#008000', '#008080', '#0000FF', '#666699', '#808080', '#F04343', '#FF9900', '#99CC00', '#339966', '#33CCCC', '#3366FF', '#800080', '#ACA899', '#FFC0CB', '#FFCC00', '#FFFF00', '#00FF00', '#00FFFF', '#00CCFF', '#993366', '#C0C0C0', '#FF99CC', '#FFCC99', '#FFFF99', '#CCFFCC', '#CCFFFF', '#CC99FF', '#E3007B', '#FFFFFF'); contents = '<table><tr>'; for(i = 0; i < 40; i++) { br = (i+1) % 8; br = (br == 0 && i != 0 && i < 39) ? '</tr><tr>' : ''; contents += '<td><a href="" aria-label="' + color[i] + '" title="' + color[i] + '" style="background-color:' + color[i] + ';" onclick="insertbbcode(\'[' + type + '=' + color[i] + ']\', \'[/' + type + ']\', \'' + field + '\');bb_hide_block(\'' + divID + '\', \'' + field + '\', 0);return false;"></a></td>' + br; } document.getElementById("bb-"+ type + field).innerHTML = contents + '</tr></table>'; } function bbcode_table(field, head_name) { var cols = document.getElementById('bb-cols' + field).value; var lines = document.getElementById('bb-lines' + field).value; var head = document.getElementById('bb-head' + field).checked; var code = ''; if( cols >= 0 && lines >= 0 ) { var colspan = cols > 1 ? ' colspan="' + cols + '"' : ''; var pointor = head ? (59 + colspan.length) : 22; code = head ? '[table]\n\t[row]\n\t\t[head' + colspan + ']'+ head_name +'[/head]\n\t[/row]\n' : '[table]\n'; for(var i = 0; i < lines; i++) { code += '\t[row]\n'; for(var j = 0; j < cols; j++) code += '\t\t[col][/col]\n'; code += '\t[/row]\n'; } code += '[/table]'; insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field); } } function bbcode_list(field) { var elements = document.getElementById('bb_list' + field).value; var ordered_list = document.getElementById('bb_ordered_list' + field).checked; if( elements <= 0 ) elements = 1; var pointor = ordered_list ? 19 : 11; code = '[list' + (ordered_list ? '=ordered' : '') + ']\n'; for(var j = 0; j < elements; j++) code += '\t[*]\n'; code += '[/list]'; insertbbcode(code.substring(0, pointor), code.substring(pointor, code.length), field); } function bbcode_url(field, prompt_text) { var url = prompt(prompt_text, ''); if(url != '' && url != null) insertbbcode('[url=' + url + ']', '[/url]', field); } function bbcode_quote(field, prompt_text) { var author = prompt(prompt_text, ''); if(author != null) { if(author != '') insertbbcode('[quote=' + author + ']', '[/quote]', field); else insertbbcode('[quote]', '[/quote]', field); } } function bbcode_lightbox(field, prompt_text) { var url = prompt(prompt_text, ''); if(url != '' && url != null) insertbbcode('[lightbox=' + url + '][img style="max-width: 150px;"]' + url, '[/img][/lightbox]', field); } function bbcode_anchor(field, prompt_text) { var anchor = prompt(prompt_text, ''); if(anchor != '' && anchor != null) insertbbcode('[anchor=' + url_encode_rewrite(anchor) + ']', '[/anchor]', field); else insertbbcode('[anchor]', '[/anchor]', field); } function bbcode_abbr(field, prompt_text) { var desc = prompt(prompt_text, ''); if(desc != '' && desc != null) insertbbcode('[abbr=' + desc + ']', '[/abbr]', field); else insertbbcode('[abbr]', '[/abbr]', field); } function bbcode_acronym(field, prompt_text) { var desc = prompt(prompt_text, ''); if(desc != '' && desc != null) insertbbcode('[acronym=' + desc + ']', '[/acronym]', field); else insertbbcode('[acronym]', '[/acronym]', field); } function bbcode_fieldset(field, prompt_text) { var legend = prompt(prompt_text, ''); if(legend != '' && legend != null) insertbbcode('[fieldset legend="' + legend + '"]', '[/fieldset]', field); else insertbbcode('[fieldset]', '[/fieldset]', field); } function bbcode_mail(field, prompt_text) { var mail = prompt(prompt_text, ''); if(mail != '' && mail != null) insertbbcode('[mail=' + mail + ']', '[/mail]', field); } function bbcode_feed(field, prompt_text) { var feed = prompt(prompt_text, ''); if(feed != '' && feed != null) insertbbcode('[feed cat="0" number="5"]' + feed.toLowerCase(), '[/feed]', field); }
尋找差異