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.
educoder/public/javascripts/jupyter.js

46 lines
975 B

5 years ago
//用于嵌入到jupyter pod中的js
//guange 2019.12.18
5 years ago
window.onload=function(){
5 years ago
console.log("开始发送消息了");
5 years ago
runEvery10Sec();
5 years ago
}
5 years ago
function runEvery10Sec() {
// 1000 * 10 = 10 秒钟
5 years ago
console.log("每隔10秒中一次");
require(["base/js/namespace"],function(Jupyter) {
Jupyter.notebook.save_checkpoint();
});
5 years ago
window.parent.postMessage('jupytermessage','*');
5 years ago
setTimeout( runEvery10Sec, 1000 * 10 );
}
5 years ago
$(function(){
document.addEventListener('keydown', function(e){
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)){
e.preventDefault();
console.log("点击了ctrl+s");
console.log("开始发送消息了ctrl+s");
window.parent.postMessage('jupytermessage','*');
}
});
})
5 years ago
$(function(){
window.addEventListener('message', (e) => {
console.log("触发了Parentwindow");
console.log(e);
if(e){
if(e.data){
if(e.data==="Parentwindow"){
console.log("父窗口调我了");
}
}
}
});
})