mediawiki-extensions-Visual.../cut-copy-paste.js

31 lines
636 B
JavaScript
Raw Normal View History

2012-02-07 22:15:04 +00:00
$(function() {
var paste = {};
$('#editor')
.on('copy', function(event) {
var range = rangy.getSelection().getRangeAt(0);
var key = range.toString().replace(/( |\r\n|\n|\r|\t)/gm,"");
paste = {};
paste[key] = 'some wikidom';
})
2012-02-07 22:22:41 +00:00
.on('beforepaste paste', function(event) {
2012-02-07 22:15:04 +00:00
$('#paste').html('');
$('#paste').focus();
setTimeout(function() {
var key = $('#paste').text().replace(/( |\r\n|\n|\r|\t)/gm,"");
console.log(paste);
if (paste[key]) {
alert('you pasted from wikidom');
} else {
alert('i don\'t know where you pasted from');
}
}, 1);
});
});