cockpit/js/ui.js in cpee-1.4.31 vs cockpit/js/ui.js in cpee-1.4.32
- old
+ new
@@ -16,28 +16,55 @@
});
} else {
$.ajax({
url: "config.json",
success: function(res){
- $("input[name=repo-url]").val(res['repo-url']);
+ $("input[name=res-url]").val(res['res-url']);
$("input[name=base-url]").val(res['base-url']);
- $("body").attr('current-repo',res['repo-url']);
+ $("body").attr('current-resources',res['res-url']);
$("body").attr('current-base',res['base-url']);
$("body").attr('current-testsets',res['testsets-url']);
cockpit();
},
error: function(){
$("body").attr('current-testsets','testsets/');
if (location.protocol.match(/^file/)) {
- $("body").attr('current-repo',"http://localhost:" + $('body').data('res-port'));
+ $("body").attr('current-resources',"http://localhost:" + $('body').data('res-port'));
$("body").attr('current-base',"http://localhost:" + $('body').data('base-port'));
} else {
- $("body").attr('current-repo',location.protocol + "//" + location.hostname + ":" + $('body').data('res-port'));
+ $("body").attr('current-resources',location.protocol + "//" + location.hostname + ":" + $('body').data('res-port'));
$("body").attr('current-base',location.protocol + "//" + location.hostname + ":" + $('body').data('base-port'));
}
- $("input[name=repo-url]").val($("body").attr('current-repo'));
+ $("input[name=res-url]").val($("body").attr('current-resources'));
$("input[name=base-url]").val($("body").attr('current-base'));
cockpit();
}
});
}
+});
+
+$(document).on('copy', '[contenteditable]', function (e) {
+ e = e.originalEvent;
+ var selectedText = window.getSelection();
+ var range = selectedText.getRangeAt(0);
+ var selectedTextReplacement = range.toString()
+ e.clipboardData.setData('text/plain', selectedTextReplacement);
+ e.preventDefault(); // default behaviour is to copy any selected text
+});
+
+// Paste fix for contenteditable
+$(document).on('paste', '[contenteditable]', function (e) {
+ e.preventDefault();
+
+ if (window.clipboardData) {
+ content = window.clipboardData.getData('Text');
+ if (window.getSelection) {
+ var selObj = window.getSelection();
+ var selRange = selObj.getRangeAt(0);
+ selRange.deleteContents();
+ selRange.insertNode(document.createTextNode(content));
+ }
+ } else if (e.originalEvent.clipboardData) {
+ content = (e.originalEvent || e).clipboardData.getData('text/plain');
+ document.execCommand('insertText', false, content);
+ }
});