diff --git a/.gitignore b/.gitignore index 86d943a9b2e8f3bb69fbe37fd8363962646b1d92..6b772c3b1a96c53eb307155fefcf698aef757188 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ # dependencies /node_modules +/publish # profiling files chrome-profiler-events*.json diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index 551319f63d70f44884d5ca898488d60af3e8ff7d..554725dbca43586fbd3edd77470c446f07537d14 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -8,19 +8,37 @@ import * as _ from 'lodash'; }) export class FormComponent implements OnInit, OnChanges, OnDestroy { + // titleObj = { + // audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3', + // content: 'what is this? ', + // icons: [], + // type: 'a' + // }; + titleObj = { - audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3', - content: 'what is this? ', + audio_url: '', + content: '', icons: [], - type: 'a' - }; + type: '' + }; - constructor() { + teststr = ""; + constructor() { } ngOnInit() { + var _this = this; + setTimeout(()=>{ + this.titleObj.content = "Hello world!!!"; + this.teststr = "************" + },2000); + // (<any>window).courseware.getData(function(data){ + // if(data){ + // _this.titleObj.content = data.content; + // } + // }); } ngOnChanges() { @@ -32,15 +50,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { } updateTitleObjSuccess(titleObj) { - + this.titleObj = titleObj; + this.save(); } onTitleAudioUploadSuccess(res) { - + this.titleObj.audio_url = res.url; + this.save(); } - save() { - + save() { + (<any>window).courseware.setData(this.titleObj); } } diff --git a/src/app/play/play.component.ts b/src/app/play/play.component.ts index 98a45d11886f90efef90b917f886b83b727673dc..73991a1c2182277fc6b9896db5a1ca10e47eb841 100644 --- a/src/app/play/play.component.ts +++ b/src/app/play/play.component.ts @@ -20,7 +20,12 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni audioElement: ElementRef; data = { - contentObj:{titleObj:null} + contentObj:{titleObj:{ + audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3', + content: 'what is this? ', + icons: [], + type: 'a' + }} }; letters = []; @@ -36,15 +41,15 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni range(start, end) { return (new Array(end - start + 1)).fill(undefined).map((_, i) => i + start); } - ngOnInit() { - if (!this.data.contentObj.titleObj) { - this.data.contentObj.titleObj = { - audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3', - content: 'what is this? ', - icons: [], - type: 'a' - }; - } + ngOnInit() { + + let _this = this; + (<any>window).courseware.getData(function(data){ + if(data){ + _this.data.contentObj.titleObj = data; + } + }); + // const letters = _.shuffle( [...this.range(97, 122), ...this.range(65, 90)]); [...this.range(97, 122), ...this.range(65, 90)].forEach(c => { this.lettersAscii[c] = String.fromCharCode(c); diff --git a/src/index.html b/src/index.html index 5df7a8f15a7fc70f913f469a054bfb0ae7c951f8..3c10cc5d7e486e1dc79b0eb2881a016bd0904784 100644 --- a/src/index.html +++ b/src/index.html @@ -7,15 +7,66 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> + + <script> + + window.courseware = (function(){ + if(window.parent.net){ + window.net = window.parent.net; + var id = window.frameElement.getAttribute("dataid"); + return { + getData: function(callback){ + net.getData("getCoursewareData",id,function(res){ + if(res){ + res = JSON.parse(res); + if(res.msg==="success"){ + let callData = null; + if(res.data&&res.data!='null'){ + callData = JSON.parse(res.data); + } + callback&&callback(callData); + }else{ + alert('æ•°æ®åŠ è½½å¤±è´¥ï¼'); + } + }else{ + alert('æ•°æ®åŠ è½½å¤±è´¥ï¼'); + } + }); + }, + setData: function(data,callback){ + let str = JSON.stringify(data); + net.getData("setCoursewareData",{id: id,data: str},function(res){ + if(res){ + res = JSON.parse(res); + if(res.msg==="success"){ + callback&&callback(); + }else{ + alert('æ•°æ®ä¿å˜å¤±è´¥ï¼'); + } + }else{ + alert('æ•°æ®ä¿å˜å¤±è´¥ï¼'); + } + }); + } + } + } else { + return { + getData: function(callback){ + let data = localStorage.getItem("courseware_data"); + callback&&callback(data); + }, + setData: function(data,callback){ + localStorage.setItem("courseware_data",data); + callback&&callback(); + } + } + } + })(); + + + </script> </head> <body> <app-root></app-root> -</body> - -<script> - window.net = window.parent.net||{}; - window.net.doUpload = function(){ - console.log("*********"); - } -</script> +</body> </html>