Skip to content

Commit a3ac421

Browse files
committed
fixed big screen bug
1 parent 0c8929c commit a3ac421

File tree

3 files changed

+108
-63
lines changed

3 files changed

+108
-63
lines changed

changelogs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOGS
22

3+
# 2.0.3
4+
> fixed big screen now it's functional
5+
> additionally ready to add some new features
36
# 2.0.3
47
> used plugin icon as tab icon
58

main.js

Lines changed: 104 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,11 @@
66
let SideButton = acode.require('sideButton');
77
var jsonData = {}; //lets initiolize it empty well ad the things further
88
const editorFile = acode.require('editorFile');
9-
acode.addIcon('full-screen', 'https://ibb.co/knfL8D9');
9+
// acode.addIcon('full-screen', 'https://ibb.co/knfL8D9');
1010

1111
let oldSetting = settings.get('autosave') /// needs menimum valur 1000 mili seconds
1212
var e = {
1313
"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-
"email": "[email protected]",
29-
"github": "hackesofice"
30-
}
3114
}
3215

3316
class LiveServer {
@@ -40,7 +23,7 @@
4023
}
4124

4225
async init() {
43-
console.log("LiveServerPlugin initialized!");
26+
//console.log("LiveServerPlugin initialized!");
4427
acode.addIcon('liveserver', `${this.baseUrl}icon.png`);
4528
// settings.update({
4629
// "Live-Server":{
@@ -50,28 +33,75 @@
5033
// })
5134
this.reloadFile = () => {
5235
try {
36+
// reload on small screen
5337
let iframe = document.getElementById('iframe');
5438
if (iframe) {
5539
iframe.src = `http://localhost:${jsonData.port}/${jsonData.fileName}`;
5640
}
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+
5753
} catch (err) {
58-
console.log(`Live server error ${err}`);
54+
// console.log(`Live server error ${err}`);
5955
}
6056
}
57+
////////////////////////////////////
58+
//// design the big screen page/////
59+
////////////////////////////////////
6160
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+
`;
75105
BigScreenContent.appendChild(iframe22);
76106
this.BigScreenContent = BigScreenContent;
77107

@@ -212,7 +242,7 @@
212242
let maxFullScreen = document.createElement('button');
213243
maxFullScreen.className = 'icon googlechrome';
214244
maxFullScreen.id = 'maxFullScreen';
215-
maxFullScreen.onclick = addBigScreenPage;
245+
maxFullScreen.onclick = () => {iframe.src ? addBigScreenPage(iframe.src, iframe) : window.toast('dissabled ! start server first')};
216246
maxFullScreen.style = `
217247
margin-right: 10px;
218248
`
@@ -365,12 +395,12 @@
365395
(async () => {
366396
let livePort = await getLivePortIfAvilable();
367397
if (livePort) {
368-
console.log(`live port gotten its ${livePort}`)
398+
// console.log(`live port gotten its ${livePort}`)
369399
jsonData.port = livePort;
370-
console.log(jsonData)
400+
//console.log(jsonData)
371401
checkServer(jsonData);
372402
} else {
373-
console.log('port not found showing default window')
403+
//console.log('port not found showing default window')
374404
showDefaultWindow();
375405
}
376406
})();
@@ -463,7 +493,7 @@
463493
});
464494
clearTimeout(timeoutId);
465495
if (!response || !response.ok) {
466-
console.log('unable to connect server');
496+
//console.log('unable to connect server');
467497
//throw new Error(`Server error: ${response.status}`);
468498
return;
469499
}
@@ -515,6 +545,7 @@
515545
} else {
516546
let iframe = document.getElementById('iframe');
517547
if (iframe) {
548+
518549
iframe.contentWindow.document.body.innerHTML = default_content;
519550
setTimeout(() => {
520551
const btn = document.getElementById('closeButton')
@@ -533,7 +564,7 @@
533564
if (iframe22) {
534565
iframe22.contentWindow.document.body.innerHTML = default_content;
535566
}else {
536-
console.log("iframe22 doesnt exists");
567+
//console.log("iframe22 doesnt exists");
537568
}
538569

539570
}
@@ -582,36 +613,47 @@
582613

583614
////////////////////))/))////ll/)//////////////
584615
// 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
598619
}
599620

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){
601640
const bigScreen = new editorFile('Live Server', {
602641
type: 'page',
603642
render: true,
604643
content: BigScreenContent,
605644
tabIcon: "icon liveserver",
645+
id: e.id,
646+
hideQuickTools:true,
647+
uri: ' '
606648
});
607-
this.isBigScreenEnabled = true;
608-
editorManager.on("save-file", this.reloadBigScreen);
649+
// this.isBigScreenEnabled = true;
650+
// editorManager.on("save-file", this.reloadBigScreen);
609651

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+
// }
615657

616658

617659

@@ -620,8 +662,8 @@
620662
}// cloasing of init functio9n
621663

622664
async destroy() {
623-
console.log('destroyed');
624-
console.log(this);
665+
// console.log('destroyed');
666+
// console.log(this);
625667
document.getElementById('live-server-window')?.remove();
626668
if (this.liveServerButton) {
627669
this.liveServerButton.hide();

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id":"liveserver",
33
"name":"Live Server",
44
"main":"main.js",
5-
"version":"2.0.3",
5+
"version":"2.0.4",
66
"readme":"readme.md",
77
"icon":"icon.png",
88
"files":[],

0 commit comments

Comments
 (0)