|
6 | 6 | let SideButton = acode.require('sideButton'); |
7 | 7 | var jsonData = {}; //lets initiolize it empty well ad the things further |
8 | 8 | const editorFile = acode.require('editorFile'); |
9 | | - acode.addIcon('full-screen', 'https://ibb.co/knfL8D9'); |
| 9 | + // acode.addIcon('full-screen', 'https://ibb.co/knfL8D9'); |
10 | 10 |
|
11 | 11 | let oldSetting = settings.get('autosave') /// needs menimum valur 1000 mili seconds |
12 | 12 | var e = { |
13 | 13 | "id": "liveserver", |
14 | | - "name": "Live Server", |
15 | | - "main": "main.js", |
16 | | - "version": "2.0.3", |
17 | | - "readme": "readme.md", |
18 | | - "icon": "icon.png", |
19 | | - "files": [], |
20 | | - "minVersionCode": 290, |
21 | | - "license": "", |
22 | | - "changelogs": "changelogs.md", |
23 | | - "keywords": ["Live Server", "live", "HTML Viewer"], |
24 | | - "price": 0, |
25 | | - "repository": "https://github.com/hackesofice/Acode-live-server.git", |
26 | | - "author": { |
27 | | - "name": "HACKESOFICE", |
28 | | - |
29 | | - "github": "hackesofice" |
30 | | - } |
31 | 14 | } |
32 | 15 |
|
33 | 16 | class LiveServer { |
|
40 | 23 | } |
41 | 24 |
|
42 | 25 | async init() { |
43 | | - console.log("LiveServerPlugin initialized!"); |
| 26 | + //console.log("LiveServerPlugin initialized!"); |
44 | 27 | acode.addIcon('liveserver', `${this.baseUrl}icon.png`); |
45 | 28 | // settings.update({ |
46 | 29 | // "Live-Server":{ |
|
50 | 33 | // }) |
51 | 34 | this.reloadFile = () => { |
52 | 35 | try { |
| 36 | + // reload on small screen |
53 | 37 | let iframe = document.getElementById('iframe'); |
54 | 38 | if (iframe) { |
55 | 39 | iframe.src = `http://localhost:${jsonData.port}/${jsonData.fileName}`; |
56 | 40 | } |
| 41 | + // reload on big screen |
| 42 | + // console.log(editorManager.files) |
| 43 | + try{ |
| 44 | + let tab = editorManager.getFile(e.id, 'id') |
| 45 | + //console.log(tab) |
| 46 | + if (tab){ |
| 47 | + tab.content.shadowRoot.querySelector(`#iframe22`).src = `http://localhost:${jsonData.port}/${jsonData.fileName}`; |
| 48 | + } |
| 49 | + }catch (err){ |
| 50 | + //console.log("tab not found ", err) |
| 51 | + } |
| 52 | + |
57 | 53 | } catch (err) { |
58 | | - console.log(`Live server error ${err}`); |
| 54 | + // console.log(`Live server error ${err}`); |
59 | 55 | } |
60 | 56 | } |
| 57 | + //////////////////////////////////// |
| 58 | + //// design the big screen page///// |
| 59 | + //////////////////////////////////// |
61 | 60 | let BigScreenContent = document.createElement('div'); |
62 | | - BigScreenContent.style.cssText = ` |
63 | | - height:100%; |
64 | | - border: 2px solid black; |
65 | | - border-radius: 5px; |
66 | | - `; |
67 | | - var iframe22 = document.createElement('iframe'); |
68 | | - iframe22.className = 'iframe22'; |
69 | | - iframe22.style.cssText = ` |
70 | | - height:90%; |
71 | | - width: 90%; |
72 | | - margin:5% 5% 5% 5%; |
73 | | - border-radius:5px; |
74 | | - `; |
| 61 | + BigScreenContent.style.cssText = ` |
| 62 | + height:100%; |
| 63 | + display:flex; |
| 64 | + flex-direction:column; |
| 65 | + `; |
| 66 | + let top_bar = document.createElement('nav'); |
| 67 | + top_bar.style.cssText = `height: 6%; width:96%; margin-right:auto; margin-left:auto; margin-top:3px; margin-bottom:4px; background-color:gray; position:stiky; display:flex; flex-direction:row; justify-content:space-between; border-radius:10px; border:none; padding:0px 5px`; |
| 68 | + |
| 69 | + let title_container = document.createElement('span'); |
| 70 | + title_container.style.cssText = 'margin-top:auto; margin-bottom:auto; margin-left:5px;' |
| 71 | + let title = document.createElement('p') |
| 72 | + title.style.cssText = 'font-size:22px; font-weight:700;' |
| 73 | + title.innerText = 'Dev Tools'; |
| 74 | + title_container.appendChild(title); |
| 75 | + top_bar.appendChild(title_container); |
| 76 | + |
| 77 | + let tools_container = document.createElement('span'); |
| 78 | + tools_container.style.cssText = 'display:flex; flex-direction:row; column-gap:10px; margin-top:auto; margin-bottom:auto; margin-right:6px;'; |
| 79 | + let tool1 = document.createElement('p'); |
| 80 | + tool1.innerText = 'Console'; |
| 81 | + tool1.style.cssText = 'font-weight:500;' |
| 82 | + tool1.onclick = () => {window.toast('comming soon')} |
| 83 | + let tool2 = document.createElement('p'); |
| 84 | + tool2.innerText = 'Share'; |
| 85 | + tool2.style.cssText = 'font-weight:500;'; |
| 86 | + tool2.onclick = () => {window.toast('comming soon')} |
| 87 | + let tool3 = document.createElement('p'); |
| 88 | + tool3.innerText = 'Open in Browser'; |
| 89 | + tool3.style.cssText = 'font-weight:500;' |
| 90 | + tool3.onclick = () => {window.toast('comming soon')} |
| 91 | + |
| 92 | + tools_container.appendChild(tool1); |
| 93 | + tools_container.appendChild(tool2); |
| 94 | + tools_container.appendChild(tool3); |
| 95 | + top_bar.appendChild(tools_container); |
| 96 | + |
| 97 | + BigScreenContent.appendChild(top_bar); |
| 98 | + |
| 99 | + var iframe22 = document.createElement('iframe'); |
| 100 | + iframe22.className = 'iframe22'; |
| 101 | + iframe22.id = 'iframe22'; |
| 102 | + iframe22.style.cssText = ` |
| 103 | + flex-grow:1; |
| 104 | + `; |
75 | 105 | BigScreenContent.appendChild(iframe22); |
76 | 106 | this.BigScreenContent = BigScreenContent; |
77 | 107 |
|
|
212 | 242 | let maxFullScreen = document.createElement('button'); |
213 | 243 | maxFullScreen.className = 'icon googlechrome'; |
214 | 244 | maxFullScreen.id = 'maxFullScreen'; |
215 | | - maxFullScreen.onclick = addBigScreenPage; |
| 245 | + maxFullScreen.onclick = () => {iframe.src ? addBigScreenPage(iframe.src, iframe) : window.toast('dissabled ! start server first')}; |
216 | 246 | maxFullScreen.style = ` |
217 | 247 | margin-right: 10px; |
218 | 248 | ` |
|
365 | 395 | (async () => { |
366 | 396 | let livePort = await getLivePortIfAvilable(); |
367 | 397 | if (livePort) { |
368 | | - console.log(`live port gotten its ${livePort}`) |
| 398 | + // console.log(`live port gotten its ${livePort}`) |
369 | 399 | jsonData.port = livePort; |
370 | | - console.log(jsonData) |
| 400 | + //console.log(jsonData) |
371 | 401 | checkServer(jsonData); |
372 | 402 | } else { |
373 | | - console.log('port not found showing default window') |
| 403 | + //console.log('port not found showing default window') |
374 | 404 | showDefaultWindow(); |
375 | 405 | } |
376 | 406 | })(); |
|
463 | 493 | }); |
464 | 494 | clearTimeout(timeoutId); |
465 | 495 | if (!response || !response.ok) { |
466 | | - console.log('unable to connect server'); |
| 496 | + //console.log('unable to connect server'); |
467 | 497 | //throw new Error(`Server error: ${response.status}`); |
468 | 498 | return; |
469 | 499 | } |
|
515 | 545 | } else { |
516 | 546 | let iframe = document.getElementById('iframe'); |
517 | 547 | if (iframe) { |
| 548 | + |
518 | 549 | iframe.contentWindow.document.body.innerHTML = default_content; |
519 | 550 | setTimeout(() => { |
520 | 551 | const btn = document.getElementById('closeButton') |
|
533 | 564 | if (iframe22) { |
534 | 565 | iframe22.contentWindow.document.body.innerHTML = default_content; |
535 | 566 | }else { |
536 | | - console.log("iframe22 doesnt exists"); |
| 567 | + //console.log("iframe22 doesnt exists"); |
537 | 568 | } |
538 | 569 |
|
539 | 570 | } |
|
582 | 613 |
|
583 | 614 | ////////////////////))/))////ll/)////////////// |
584 | 615 | // COADING FOR BIG SCREEN |
585 | | - function addBigScreenPage() { |
586 | | - |
587 | | - if (!this.reloadBigScreen){ |
588 | | - this.reloadBigScreen = (() => { |
589 | | - const iframe3 = BigScreenContent.querySelector("iframe.iframe22"); |
590 | | - if (this.isServerOnline){ |
591 | | - iframe3.src = `http://localhost:${jsonData.port}`; |
592 | | - }else { |
593 | | - iframe3.contentWindow.document.body.innerHTML = ` |
594 | | - hello brother server is off |
595 | | - `; |
596 | | - } |
597 | | - }); |
| 616 | + function addBigScreenPage(content_link, resizable_screen) { |
| 617 | + if(editorManager.getFile(e.id, 'id')){ |
| 618 | + return |
598 | 619 | } |
599 | 620 |
|
600 | | - if (!this.isBigScreenEnabled){ |
| 621 | + // if (!this.reloadBigScreen){ |
| 622 | + // this.reloadBigScreen = (() => { |
| 623 | + // const iframe3 = BigScreenContent.querySelector("#iframe22"); |
| 624 | + // if (this.isServerOnline){ |
| 625 | + // iframe3.src = `http://localhost:${jsonData.port}`; |
| 626 | + // }else { |
| 627 | + // iframe3.contentWindow.document.body.innerHTML = ` |
| 628 | + // hello brother server is off |
| 629 | + // `; |
| 630 | + // } |
| 631 | + // }); |
| 632 | + // } |
| 633 | + // console.log(content_link) |
| 634 | + if (content_link){ |
| 635 | + BigScreenContent.querySelector('#iframe22').src = content_link; |
| 636 | + }else{ |
| 637 | + BigScreenContent.querySelector('#iframe22').innerHTML = resizable_screen.contentWindow.document.body.innerHTML |
| 638 | + } |
| 639 | + // if (!this.isBigScreenEnabled){ |
601 | 640 | const bigScreen = new editorFile('Live Server', { |
602 | 641 | type: 'page', |
603 | 642 | render: true, |
604 | 643 | content: BigScreenContent, |
605 | 644 | tabIcon: "icon liveserver", |
| 645 | + id: e.id, |
| 646 | + hideQuickTools:true, |
| 647 | + uri: ' ' |
606 | 648 | }); |
607 | | - this.isBigScreenEnabled = true; |
608 | | - editorManager.on("save-file", this.reloadBigScreen); |
| 649 | + // this.isBigScreenEnabled = true; |
| 650 | + // editorManager.on("save-file", this.reloadBigScreen); |
609 | 651 |
|
610 | | - bigScreen.on('close', () => { |
611 | | - this.isBigScreenEnabled = false; |
612 | | - editorManager.off("save-file", this.reloadBigScreen); |
613 | | - }); |
614 | | - } |
| 652 | + // bigScreen.on('close', () => { |
| 653 | + // this.isBigScreenEnabled = false; |
| 654 | + // editorManager.off("save-file", this.reloadBigScreen); |
| 655 | + // }); |
| 656 | + // } |
615 | 657 |
|
616 | 658 |
|
617 | 659 |
|
|
620 | 662 | }// cloasing of init functio9n |
621 | 663 |
|
622 | 664 | async destroy() { |
623 | | - console.log('destroyed'); |
624 | | - console.log(this); |
| 665 | + // console.log('destroyed'); |
| 666 | + // console.log(this); |
625 | 667 | document.getElementById('live-server-window')?.remove(); |
626 | 668 | if (this.liveServerButton) { |
627 | 669 | this.liveServerButton.hide(); |
|
0 commit comments