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);
查找差异