Diff
checker
文本
文本
圖像
文檔
Excel
文件夾
Legal
Enterprise
桌面版
定價
登入
下載 Diffchecker 桌面版
比較文本
尋找兩個文字檔案之間的差異
工具
歷史
即時編輯器
隱藏空白變更
摺疊未變更行
關閉換行
檢視
拆分
統一
比對精度
智能
單詞
字符
文字樣式
變更外觀
語法突出顯示
選擇語法
忽略
文字轉換
前往第一個差異
編輯輸入
Diffchecker Desktop
執行Diffchecker最安全的方式。取得Diffchecker桌面應用程式:您的差異永遠不會離開您的電腦!
取得桌面版
Untitled diff
建立於
11 年前
差異永不過期
清除
匯出
分享
解釋
0 刪除
行
總計
刪除
字符
總計
刪除
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
204 行
全部複製
1 新增
行
總計
新增
字符
總計
新增
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
205 行
全部複製
/**
/**
* Plugin: jquery.zGlossary
* Plugin: jquery.zGlossary
*
*
* Version: 1.0.2
* Version: 1.0.2
* (c) Copyright 2011-2013, Zazar Ltd
* (c) Copyright 2011-2013, Zazar Ltd
*
*
* Description: jQuery plugin to find and display term definitions in HTML text
* Description: jQuery plugin to find and display term definitions in HTML text
*
*
* History:
* History:
* 1.0.2 - Added show once option
* 1.0.2 - Added show once option
* 1.0.1 - Correct mistype to _addTerm function (Thanks Aldopaolo)
* 1.0.1 - Correct mistype to _addTerm function (Thanks Aldopaolo)
* 1.0.0 - Initial release
* 1.0.0 - Initial release
*
*
**/
**/
(function($){
(function($){
$.fn.glossary = function(url, options) {
$.fn.glossary = function(url, options) {
// Set plugin defaults
// Set plugin defaults
var defaults = {
var defaults = {
ignorecase: false,
ignorecase: false,
tiptag: 'h6',
tiptag: 'h6',
excludetags: [],
excludetags: [],
linktarget: '_blank',
linktarget: '_blank',
showonce: false
showonce: false
};
};
var options = $.extend(defaults, options);
var options = $.extend(defaults, options);
var id = 1;
var id = 1;
// Functions
// Functions
return this.each(function(i, e) {
return this.each(function(i, e) {
// Ensure any exclude tags are uppercase for comparisons
// Ensure any exclude tags are uppercase for comparisons
$.each(options.excludetags, function(i,e) { options.excludetags[i] = e.toUpperCase(); });
$.each(options.excludetags, function(i,e) { options.excludetags[i] = e.toUpperCase(); });
// Function to find and add term
// Function to find and add term
var _addTerm = function(e, term, type, def) {
var _addTerm = function(e, term, type, def) {
var patfmt = term;
var patfmt = term;
var skip = 0;
var skip = 0;
// Check the element is a text node
// Check the element is a text node
if (e.nodeType == 3) {
if (e.nodeType == 3) {
// Case insensistive matching option
// Case insensistive matching option
if (options.ignorecase) {
if (options.ignorecase) {
var pos = e.data.toLowerCase().indexOf(patfmt.toLowerCase());
var pos = e.data.toLowerCase().indexOf(patfmt.toLowerCase());
} else {
} else {
var pos = e.data.indexOf(patfmt);
var pos = e.data.indexOf(patfmt);
}
}
// Check if the term is found
// Check if the term is found
if (pos >= 0) {
if (pos >= 0) {
// Check for excluded tags
// Check for excluded tags
if (jQuery.inArray($(e).parent().get(0).tagName,options.excludetags) > -1) {
if (jQuery.inArray($(e).parent().get(0).tagName,options.excludetags) > -1) {
} else {
} else {
// Create link element
// Create link element
var spannode = document.createElement('a');
var spannode = document.createElement('a');
spannode.className = 'glossaryTerm';
spannode.className = 'glossaryTerm';
if (type == '0') {
if (type == '0') {
// Popup definition
// Popup definition
spannode.id = "glossaryID" + id;
spannode.id = "glossaryID" + id;
spannode.href = '#';
spannode.href = '#';
spannode.title = 'Click for \''+ term +'\' definition';
spannode.title = 'Click for \''+ term +'\' definition';
spannode.className = 'glossaryTerm';
spannode.className = 'glossaryTerm';
$(spannode).click(function(e) {
$(spannode).click(function(e) {
$.glossaryTip('<'+ options.tiptag +'>'+ term + '</'+ options.tiptag +'><p>'+ def +'</p>', {mouse_event: e})
$.glossaryTip('<'+ options.tiptag +'>'+ term + '</'+ options.tiptag +'><p>'+ def +'</p>', {mouse_event: e})
return false;
return false;
});
});
} else if (type == '1') {
} else if (type == '1') {
// Wikipedia definition
// Wikipedia definition
spannode.title = 'Click to look up \''+ term+'\' in Wikipedia';
spannode.title = 'Click to look up \''+ term+'\' in Wikipedia';
term = term.replace(/ /g, "_");
term = term.replace(/ /g, "_");
spannode.href = 'http://en.wikipedia.org/wiki/'+term;
spannode.href = 'http://en.wikipedia.org/wiki/'+term;
spannode.target = options.linktarget;
spannode.target = options.linktarget;
} else if (type == '2') {
} else if (type == '2') {
// Google search
// Google search
spannode.title = 'Click to search for \''+ term +'\' in Google';
spannode.title = 'Click to search for \''+ term +'\' in Google';
term = term.replace(/ /g, "+");
term = term.replace(/ /g, "+");
spannode.href = 'http://www.google.co.uk/search?q='+term;
spannode.href = 'http://www.google.co.uk/search?q='+term;
spannode.target = options.linktarget;
spannode.target = options.linktarget;
} else if (type == '3') {
} else if (type == '3') {
// Custom external link
// Custom external link
spannode.title = 'Click to view \''+ term +'\' definition';
spannode.title = 'Click to view \''+ term +'\' definition';
spannode.href = def;
spannode.href = def;
spannode.target = options.linktarget;
spannode.target = options.linktarget;
}
}
var middlebit = e.splitText(pos);
var middlebit = e.splitText(pos);
var endbit = middlebit.splitText(patfmt.length);
var endbit = middlebit.splitText(patfmt.length);
var middleclone = middlebit.cloneNode(true);
var middleclone = middlebit.cloneNode(true);
spannode.appendChild(middleclone);
spannode.appendChild(middleclone);
middlebit.parentNode.replaceChild(spannode, middlebit);
middlebit.parentNode.replaceChild(spannode, middlebit);
skip = 1;
skip = 1;
id += 1;
id += 1;
}
}
}
}
}
}
else if (e.nodeType == 1 && e.childNodes && !/(script|style)/i.test(e.tagName)) {
else if (e.nodeType == 1 && e.childNodes && !/(script|style)/i.test(e.tagName)) {
// Search child nodes
// Search child nodes
for (var i = 0; i < e.childNodes.length; ++i) {
for (var i = 0; i < e.childNodes.length; ++i) {
var ret = _addTerm(e.childNodes[i], term, type, def);
var ret = _addTerm(e.childNodes[i], term, type, def);
// If term found and show once option go to next term
// If term found and show once option go to next term
if (options.showonce && ret == 1) {
if (options.showonce && ret == 1) {
i = e.childNodes.length;
i = e.childNodes.length;
skip = 1;
skip = 1;
} else {
} else {
i += ret;
i += ret;
}
}
}
}
}
}
return skip;
return skip;
};
};
// Get glossary list items
// Get glossary list items
$.ajax({
$.ajax({
type: 'GET',
type: 'GET',
url: url,
url: url,
dataType: 'json',
dataType: 'json',
success: function(data) {
success: function(data) {
if (data) {
if (data) {
var count = data.length;
var count = data.length;
for (var i=0; i<count; i++) {
for (var i=0; i<count; i++) {
// Find term in text
// Find term in text
var item = data[i];
var item = data[i];
_addTerm(e, item.term, item.type, item.definition);
_addTerm(e, item.term, item.type, item.definition);
}
}
}
}
複製
已複製
複製
已複製
typeof options.callback == 'function' && options.callback();
},
},
error: function() {}
error: function() {}
});
});
});
});
};
};
// Glossary tip popup
// Glossary tip popup
var glossaryTip = function() {}
var glossaryTip = function() {}
$.extend(glossaryTip.prototype, {
$.extend(glossaryTip.prototype, {
setup: function(){
setup: function(){
if ($('#glossaryTip').length) {
if ($('#glossaryTip').length) {
$('#glossaryTip').remove();
$('#glossaryTip').remove();
}
}
glossaryTip.holder = $('<div id="glossaryTip" style="max-width:260px;"><div id="glossaryClose"></div></div>');
glossaryTip.holder = $('<div id="glossaryTip" style="max-width:260px;"><div id="glossaryClose"></div></div>');
glossaryTip.content = $('<div id="glossaryContent"></div>');
glossaryTip.content = $('<div id="glossaryContent"></div>');
$('body').append(glossaryTip.holder.append(glossaryTip.content));
$('body').append(glossaryTip.holder.append(glossaryTip.content));
},
},
show: function(content, event){
show: function(content, event){
glossaryTip.content.html(content);
glossaryTip.content.html(content);
// Display tip at mouse cursor
// Display tip at mouse cursor
var x = parseInt(event.mouse_event.pageX) + 15
var x = parseInt(event.mouse_event.pageX) + 15
var y = parseInt(event.mouse_event.pageY) + 5
var y = parseInt(event.mouse_event.pageY) + 5
glossaryTip.holder.css({top: y, left: x});
glossaryTip.holder.css({top: y, left: x});
// Display the tip
// Display the tip
if (glossaryTip.holder.is(':hidden')) {
if (glossaryTip.holder.is(':hidden')) {
glossaryTip.holder.show();
glossaryTip.holder.show();
}
}
// Add click handler to close
// Add click handler to close
glossaryTip.holder.bind('click', function(){
glossaryTip.holder.bind('click', function(){
glossaryTip.holder.stop(true).fadeOut(200);
glossaryTip.holder.stop(true).fadeOut(200);
return false;
return false;
});
});
}
}
});
});
$.glossaryTip = function(content, event) {
$.glossaryTip = function(content, event) {
var tip = $.glossaryTip.instance;
var tip = $.glossaryTip.instance;
if (!tip) { tip = $.glossaryTip.instance = new glossaryTip(); }
if (!tip) { tip = $.glossaryTip.instance = new glossaryTip(); }
tip.setup();
tip.setup();
tip.show(content, event);
tip.show(content, event);
return tip;
return tip;
}
}
})(jQuery);
})(jQuery);
已保存差異
原始文本
開啟檔案
/** * Plugin: jquery.zGlossary * * Version: 1.0.2 * (c) Copyright 2011-2013, Zazar Ltd * * Description: jQuery plugin to find and display term definitions in HTML text * * History: * 1.0.2 - Added show once option * 1.0.1 - Correct mistype to _addTerm function (Thanks Aldopaolo) * 1.0.0 - Initial release * **/ (function($){ $.fn.glossary = function(url, options) { // Set plugin defaults var defaults = { ignorecase: false, tiptag: 'h6', excludetags: [], linktarget: '_blank', showonce: false }; var options = $.extend(defaults, options); var id = 1; // Functions return this.each(function(i, e) { // Ensure any exclude tags are uppercase for comparisons $.each(options.excludetags, function(i,e) { options.excludetags[i] = e.toUpperCase(); }); // Function to find and add term var _addTerm = function(e, term, type, def) { var patfmt = term; var skip = 0; // Check the element is a text node if (e.nodeType == 3) { // Case insensistive matching option if (options.ignorecase) { var pos = e.data.toLowerCase().indexOf(patfmt.toLowerCase()); } else { var pos = e.data.indexOf(patfmt); } // Check if the term is found if (pos >= 0) { // Check for excluded tags if (jQuery.inArray($(e).parent().get(0).tagName,options.excludetags) > -1) { } else { // Create link element var spannode = document.createElement('a'); spannode.className = 'glossaryTerm'; if (type == '0') { // Popup definition spannode.id = "glossaryID" + id; spannode.href = '#'; spannode.title = 'Click for \''+ term +'\' definition'; spannode.className = 'glossaryTerm'; $(spannode).click(function(e) { $.glossaryTip('<'+ options.tiptag +'>'+ term + '</'+ options.tiptag +'><p>'+ def +'</p>', {mouse_event: e}) return false; }); } else if (type == '1') { // Wikipedia definition spannode.title = 'Click to look up \''+ term+'\' in Wikipedia'; term = term.replace(/ /g, "_"); spannode.href = 'http://en.wikipedia.org/wiki/'+term; spannode.target = options.linktarget; } else if (type == '2') { // Google search spannode.title = 'Click to search for \''+ term +'\' in Google'; term = term.replace(/ /g, "+"); spannode.href = 'http://www.google.co.uk/search?q='+term; spannode.target = options.linktarget; } else if (type == '3') { // Custom external link spannode.title = 'Click to view \''+ term +'\' definition'; spannode.href = def; spannode.target = options.linktarget; } var middlebit = e.splitText(pos); var endbit = middlebit.splitText(patfmt.length); var middleclone = middlebit.cloneNode(true); spannode.appendChild(middleclone); middlebit.parentNode.replaceChild(spannode, middlebit); skip = 1; id += 1; } } } else if (e.nodeType == 1 && e.childNodes && !/(script|style)/i.test(e.tagName)) { // Search child nodes for (var i = 0; i < e.childNodes.length; ++i) { var ret = _addTerm(e.childNodes[i], term, type, def); // If term found and show once option go to next term if (options.showonce && ret == 1) { i = e.childNodes.length; skip = 1; } else { i += ret; } } } return skip; }; // Get glossary list items $.ajax({ type: 'GET', url: url, dataType: 'json', success: function(data) { if (data) { var count = data.length; for (var i=0; i<count; i++) { // Find term in text var item = data[i]; _addTerm(e, item.term, item.type, item.definition); } } }, error: function() {} }); }); }; // Glossary tip popup var glossaryTip = function() {} $.extend(glossaryTip.prototype, { setup: function(){ if ($('#glossaryTip').length) { $('#glossaryTip').remove(); } glossaryTip.holder = $('<div id="glossaryTip" style="max-width:260px;"><div id="glossaryClose"></div></div>'); glossaryTip.content = $('<div id="glossaryContent"></div>'); $('body').append(glossaryTip.holder.append(glossaryTip.content)); }, show: function(content, event){ glossaryTip.content.html(content); // Display tip at mouse cursor var x = parseInt(event.mouse_event.pageX) + 15 var y = parseInt(event.mouse_event.pageY) + 5 glossaryTip.holder.css({top: y, left: x}); // Display the tip if (glossaryTip.holder.is(':hidden')) { glossaryTip.holder.show(); } // Add click handler to close glossaryTip.holder.bind('click', function(){ glossaryTip.holder.stop(true).fadeOut(200); return false; }); } }); $.glossaryTip = function(content, event) { var tip = $.glossaryTip.instance; if (!tip) { tip = $.glossaryTip.instance = new glossaryTip(); } tip.setup(); tip.show(content, event); return tip; } })(jQuery);
更改後文本
開啟檔案
/** * Plugin: jquery.zGlossary * * Version: 1.0.2 * (c) Copyright 2011-2013, Zazar Ltd * * Description: jQuery plugin to find and display term definitions in HTML text * * History: * 1.0.2 - Added show once option * 1.0.1 - Correct mistype to _addTerm function (Thanks Aldopaolo) * 1.0.0 - Initial release * **/ (function($){ $.fn.glossary = function(url, options) { // Set plugin defaults var defaults = { ignorecase: false, tiptag: 'h6', excludetags: [], linktarget: '_blank', showonce: false }; var options = $.extend(defaults, options); var id = 1; // Functions return this.each(function(i, e) { // Ensure any exclude tags are uppercase for comparisons $.each(options.excludetags, function(i,e) { options.excludetags[i] = e.toUpperCase(); }); // Function to find and add term var _addTerm = function(e, term, type, def) { var patfmt = term; var skip = 0; // Check the element is a text node if (e.nodeType == 3) { // Case insensistive matching option if (options.ignorecase) { var pos = e.data.toLowerCase().indexOf(patfmt.toLowerCase()); } else { var pos = e.data.indexOf(patfmt); } // Check if the term is found if (pos >= 0) { // Check for excluded tags if (jQuery.inArray($(e).parent().get(0).tagName,options.excludetags) > -1) { } else { // Create link element var spannode = document.createElement('a'); spannode.className = 'glossaryTerm'; if (type == '0') { // Popup definition spannode.id = "glossaryID" + id; spannode.href = '#'; spannode.title = 'Click for \''+ term +'\' definition'; spannode.className = 'glossaryTerm'; $(spannode).click(function(e) { $.glossaryTip('<'+ options.tiptag +'>'+ term + '</'+ options.tiptag +'><p>'+ def +'</p>', {mouse_event: e}) return false; }); } else if (type == '1') { // Wikipedia definition spannode.title = 'Click to look up \''+ term+'\' in Wikipedia'; term = term.replace(/ /g, "_"); spannode.href = 'http://en.wikipedia.org/wiki/'+term; spannode.target = options.linktarget; } else if (type == '2') { // Google search spannode.title = 'Click to search for \''+ term +'\' in Google'; term = term.replace(/ /g, "+"); spannode.href = 'http://www.google.co.uk/search?q='+term; spannode.target = options.linktarget; } else if (type == '3') { // Custom external link spannode.title = 'Click to view \''+ term +'\' definition'; spannode.href = def; spannode.target = options.linktarget; } var middlebit = e.splitText(pos); var endbit = middlebit.splitText(patfmt.length); var middleclone = middlebit.cloneNode(true); spannode.appendChild(middleclone); middlebit.parentNode.replaceChild(spannode, middlebit); skip = 1; id += 1; } } } else if (e.nodeType == 1 && e.childNodes && !/(script|style)/i.test(e.tagName)) { // Search child nodes for (var i = 0; i < e.childNodes.length; ++i) { var ret = _addTerm(e.childNodes[i], term, type, def); // If term found and show once option go to next term if (options.showonce && ret == 1) { i = e.childNodes.length; skip = 1; } else { i += ret; } } } return skip; }; // Get glossary list items $.ajax({ type: 'GET', url: url, dataType: 'json', success: function(data) { if (data) { var count = data.length; for (var i=0; i<count; i++) { // Find term in text var item = data[i]; _addTerm(e, item.term, item.type, item.definition); } } typeof options.callback == 'function' && options.callback(); }, error: function() {} }); }); }; // Glossary tip popup var glossaryTip = function() {} $.extend(glossaryTip.prototype, { setup: function(){ if ($('#glossaryTip').length) { $('#glossaryTip').remove(); } glossaryTip.holder = $('<div id="glossaryTip" style="max-width:260px;"><div id="glossaryClose"></div></div>'); glossaryTip.content = $('<div id="glossaryContent"></div>'); $('body').append(glossaryTip.holder.append(glossaryTip.content)); }, show: function(content, event){ glossaryTip.content.html(content); // Display tip at mouse cursor var x = parseInt(event.mouse_event.pageX) + 15 var y = parseInt(event.mouse_event.pageY) + 5 glossaryTip.holder.css({top: y, left: x}); // Display the tip if (glossaryTip.holder.is(':hidden')) { glossaryTip.holder.show(); } // Add click handler to close glossaryTip.holder.bind('click', function(){ glossaryTip.holder.stop(true).fadeOut(200); return false; }); } }); $.glossaryTip = function(content, event) { var tip = $.glossaryTip.instance; if (!tip) { tip = $.glossaryTip.instance = new glossaryTip(); } tip.setup(); tip.show(content, event); return tip; } })(jQuery);
尋找差異