|
|
|
@ -30,7 +30,9 @@ class Challengesjupyter extends Component {
|
|
|
|
|
ChallengesDataList: undefined,
|
|
|
|
|
operate: true,
|
|
|
|
|
startbtns: false,
|
|
|
|
|
iFrameHeight: '0px'
|
|
|
|
|
iFrameHeight: '0px',
|
|
|
|
|
jupyter_port:0,
|
|
|
|
|
jupyter_url:null,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -57,23 +59,13 @@ class Challengesjupyter extends Component {
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
setTimeout(this.ChallengesList(), 1000);
|
|
|
|
|
// var iframe =
|
|
|
|
|
// document.getElementById('ifr1');
|
|
|
|
|
// console.log("iframe||||||||");
|
|
|
|
|
// console.log(iframe);
|
|
|
|
|
// if(iframe){
|
|
|
|
|
// // var headertest=test.contentWindow.document.getElementById('header');
|
|
|
|
|
// // console.log(headertest);
|
|
|
|
|
// var iwindow = iframe.contentWindow;
|
|
|
|
|
// var idoc = iwindow.document;
|
|
|
|
|
// console.log("window",iwindow);//获取iframe的window对象
|
|
|
|
|
// console.log("windowwindow",iwindow.document.getElementById('header'));//获取iwindow.document对象
|
|
|
|
|
// console.log("document",idoc); //获取iframe的document
|
|
|
|
|
// console.log("documentdocument",idoc.getElementById('header'));
|
|
|
|
|
// console.log("html",idoc.documentElement);//获取iframe的html
|
|
|
|
|
// console.log("head",idoc.head); //获取head
|
|
|
|
|
// console.log("body",idoc.body); //获取body
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("componentDidMount");
|
|
|
|
|
console.log("Challengesjupyter");
|
|
|
|
|
console.log(this.props);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -129,114 +121,32 @@ class Challengesjupyter extends Component {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
modifyjupyter=()=>{
|
|
|
|
|
// var ifr =window.parent.frames["frame"].document;
|
|
|
|
|
// console.log(ifr);
|
|
|
|
|
// var data = JSON.stringify({
|
|
|
|
|
//
|
|
|
|
|
// 'location': window.location
|
|
|
|
|
//
|
|
|
|
|
// // etc
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
// let parentDomain = window.location.hostname;
|
|
|
|
|
// console.log("domain",parentDomain); //localhost
|
|
|
|
|
// document.domain = data;
|
|
|
|
|
// document.domain = 'https://47519.test-jupyter.educoder.net';
|
|
|
|
|
// window.parent.document.contents().find("#ifr1")[0].contentWindow.iframefunction();
|
|
|
|
|
const iframe = document.getElementById('iframe');
|
|
|
|
|
console.log("modifyjupyter");
|
|
|
|
|
// const frameWindow = iframe.contentWindow;
|
|
|
|
|
const frameWindow = iframe.contentWindow.postMessage('setLocation,' + null + "," + null, '*');
|
|
|
|
|
console.log(frameWindow);
|
|
|
|
|
const frameDocument = frameWindow.document;
|
|
|
|
|
console.log(frameDocument);
|
|
|
|
|
|
|
|
|
|
// window.addEventListener('load', () => {
|
|
|
|
|
// console.log('12313页面加载好了');
|
|
|
|
|
// const iframe = document.getElementById('ifr1');
|
|
|
|
|
// if (iframe && iframe.contentWindow && this.props.iframe_src) {
|
|
|
|
|
// console.log('32131231yes mounted');
|
|
|
|
|
// console.log(iframe.contentWindow);
|
|
|
|
|
// } else {
|
|
|
|
|
// console.log('3242242not mounted')
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// var editor;
|
|
|
|
|
// editor = document.getElementById("ifr1").contentWindow;
|
|
|
|
|
// console.log(editor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// window.onload = () => {
|
|
|
|
|
// var testwindow =
|
|
|
|
|
// document.getElementById('ifr1').contentWindow;
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var iframe=window.frames["ifr1"];
|
|
|
|
|
// // var title =${'ifr1'}
|
|
|
|
|
// console.log("iframe");
|
|
|
|
|
// console.log(iframe);
|
|
|
|
|
// var frames = window.frames; // 或 // var frames = window.parent.frames;
|
|
|
|
|
// for (var i = 0; i < frames.length; i++) {
|
|
|
|
|
// // 在这对frames的一个frame做点什么
|
|
|
|
|
// // frames[i].document.body.style.background = "red";
|
|
|
|
|
// console.log(frames[i]);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// var idoc = iframe.document;
|
|
|
|
|
// console.log(idoc);
|
|
|
|
|
// var iwindow = title.contentWindow;
|
|
|
|
|
// console.log("iwindow");
|
|
|
|
|
// console.log(iwindow);
|
|
|
|
|
// var idoc = iwindow.document;
|
|
|
|
|
// console.log(idoc);
|
|
|
|
|
// window.addEventListener('message', receiveMessageFromParent, false);
|
|
|
|
|
//
|
|
|
|
|
// let messageButton = document.getElementById('message_button');
|
|
|
|
|
// /* console.log('msg button', messageButton); annoataion cannot use \/\/ */
|
|
|
|
|
// messageButton.addEventListener('click', function (e) {
|
|
|
|
|
// console.log('iframe send msg');
|
|
|
|
|
// console.log('parent', window.parent);
|
|
|
|
|
// console.log('top container', window.top);
|
|
|
|
|
// window.parent.postMessage('This is child', '*');
|
|
|
|
|
// }, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var iframe = $('#ifr1');
|
|
|
|
|
// console.log(iframe.context.find('#save-notbook'));
|
|
|
|
|
// console.log("iframe");
|
|
|
|
|
// console.log(iframe)
|
|
|
|
|
// title.window.say(); //myFrame.say();也可
|
|
|
|
|
//
|
|
|
|
|
// title.window.document.getElementById("button").value="保存并检查";
|
|
|
|
|
//find button inside iframe
|
|
|
|
|
// let button = iframe.contents().find('#save-notbook');
|
|
|
|
|
// //trigger button click
|
|
|
|
|
// button.trigger("click");
|
|
|
|
|
// console.log("iframe||||||||");
|
|
|
|
|
// if(iframe){
|
|
|
|
|
// var iwindow = iframe.contentWindow;
|
|
|
|
|
// var idoc = iwindow.document;
|
|
|
|
|
// console.log("window",iwindow);//获取iframe的window对象
|
|
|
|
|
// console.log("document",idoc); //获取iframe的document
|
|
|
|
|
// console.log("html",idoc.documentElement);//获取iframe的html
|
|
|
|
|
// console.log("head",idoc.head); //获取head
|
|
|
|
|
// console.log("body",idoc.body); //获取body
|
|
|
|
|
// }
|
|
|
|
|
// var test =
|
|
|
|
|
// document.getElementById('ifr1').contentWindow.document.getElementById('header');
|
|
|
|
|
// test.style.background = "#333";
|
|
|
|
|
modifyjupyter=(propsysl)=>{
|
|
|
|
|
console.log("propsysl");
|
|
|
|
|
console.log(propsysl);
|
|
|
|
|
let id=this.props.match.params.shixunId;
|
|
|
|
|
|
|
|
|
|
const url=`/shixuns/${id}/update_jupyter.json`;
|
|
|
|
|
const data={
|
|
|
|
|
identifier:id,
|
|
|
|
|
jupyter_port:propsysl.shixunsDetails.jupyter_port
|
|
|
|
|
}
|
|
|
|
|
axios.post(url, data)
|
|
|
|
|
.then((result) => {
|
|
|
|
|
if (result.data.status == 0) {
|
|
|
|
|
this.props.showNotification(`应用成功`);
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendToken=()=>{
|
|
|
|
|
// console.log("sendToken");
|
|
|
|
|
// const iframe = document.getElementById('iframe');
|
|
|
|
|
// console.log("modifyjupyter");
|
|
|
|
|
// const frameWindow = iframe.contentWindow;
|
|
|
|
|
// console.log("frameWindow");
|
|
|
|
|
// console.log(frameWindow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
@ -316,7 +226,7 @@ class Challengesjupyter extends Component {
|
|
|
|
|
<div className="renwuxiangssi sortinxdirection">
|
|
|
|
|
<div><p className="renwuxiangqdiv">任务详情</p></div> <div><p className="renwuxiangqdivtest ml24">示例</p></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="renwuxiangssit xaxisreverseorder"><div className="challenbaocun" onClick={()=>this.modifyjupyter()}><p className="challenbaocuntest">保存</p></div></div>
|
|
|
|
|
<div className="renwuxiangssit xaxisreverseorder"><div className="challenbaocun" onClick={()=>this.modifyjupyter(this.props)}><p className="challenbaocuntest">应用到实训</p></div></div>
|
|
|
|
|
</div>
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
@ -343,10 +253,20 @@ class Challengesjupyter extends Component {
|
|
|
|
|
{/*https://48888.jupyter.educoder.net/tree?*/}
|
|
|
|
|
|
|
|
|
|
<div className="pb47">
|
|
|
|
|
<iframe src="https://47524.jupyter.educoder.net/notebooks/data/workspace/myshixun_tpm3575/01.ipynb" sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="frame" name="framename" width="100%" height="700" frameborder="0"
|
|
|
|
|
{
|
|
|
|
|
this.props.shixunsDetails===null || this.props.shixunsDetails===undefined||JSON.stringify(this.props.shixunsDetails)==="{}"?
|
|
|
|
|
""
|
|
|
|
|
:
|
|
|
|
|
(
|
|
|
|
|
this.props&&this.props.shixunsDetails&&this.props.shixunsDetails.jupyter_url?
|
|
|
|
|
<iframe src={this.props.shixunsDetails.jupyter_url}
|
|
|
|
|
sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="frame"
|
|
|
|
|
name="framename" width="100%" height="700" frameBorder="0"
|
|
|
|
|
></iframe>
|
|
|
|
|
:""
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
></iframe>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|