You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/js/jupyter.js

48 lines
1.1 KiB

(function(open) {
XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
this.addEventListener("load", function() {
if(method === "PUT"){
window.top.postMessage('jupytermessage','*');
}
});
open.call(this, method, url, async, user, password);
};
})(XMLHttpRequest.prototype.open);
(function(fetch) {
window.fetch = function() {
return fetch.apply(this, arguments).then(function(response) {
if(method === "PUT"){
window.top.postMessage('jupytermessage','*');
}
return response;
});
};
})(window.fetch);
function saveCode(){
var saveEvent = new KeyboardEvent('keydown', {
key: 's',
ctrlKey: true
});
document.dispatchEvent(saveEvent);
}
function onReceiveMessage(e) {
try {
if (mes.type === 'saveCode') {
saveCode()
}
} catch (error) {
console.log('error:', error, e);
}
}
(function() {
setInterval(() => {
saveCode()
},5000)
})();
window.addEventListener('message', onReceiveMessage);