diff --git a/public/javascripts/jupyter.js b/public/javascripts/jupyter.js index aa738a644..3141fc3c5 100644 --- a/public/javascripts/jupyter.js +++ b/public/javascripts/jupyter.js @@ -1,18 +1,57 @@ //用于嵌入到jupyter pod中的js //guange 2019.12.18 - +var timebool=false; window.onload=function(){ console.log("开始发送消息了"); + timebool=true; runEvery10Sec(); } function runEvery10Sec() { + // 1000 * 10 = 10 秒钟 console.log("每隔10秒中一次"); require(["base/js/namespace"],function(Jupyter) { Jupyter.notebook.save_checkpoint(); }); window.parent.postMessage('jupytermessage','*'); - setTimeout( runEvery10Sec, 1000 * 10 ); + if(timebool===true){ + setTimeout( runEvery10Sec, 1000 * 10 ); + } + } + +$(function(){ +document.addEventListener('keydown', (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','*'); + } +}); +}) +$(function(){ + window.addEventListener('message', (e) => { + console.log("触发了Parentwindow"); + console.log(e); + if(e){ + if(e.data){ + if(e.data==="Parentwindow"){ + //重置停止 + timebool=false; + console.log("父窗口调我了"); + }else if(e.data==="Parentwindow"){ + console.log("父窗口调我了"); + //取消启动 + timebool=true; + this.runEvery10Sec(); + } + } + + } + + }); +}) + diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index fcff7d1d4..a08825936 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -243,6 +243,15 @@ class Challengesjupyter extends Component { enlarge:bool }) } + daoruzhon=()=>{ + var _iframe = document.getElementById("frame"); + if(_iframe == null || _iframe == undefined || _iframe == ""){ + console.log("framenull"); + return; + } + console.log("framego"); + _iframe.contentWindow.postMessage("Parentwindow", "*"); + } render() { let{ChallengesDataList,booljupyterurls,enlarge}=this.state; @@ -404,9 +413,9 @@ class Challengesjupyter extends Component { marginLeft: '30px', }} onClick={()=>this.onclki(true)}> } - {/*
导入
*/} - {/*this.daoruzhon()}>导入
+