Skip to content

Commit adf4c74

Browse files
author
Nike
committed
modificando la exportacion de page_not_fount a una funcion, convirtiendo a clase el archivo status
1 parent c56f5b6 commit adf4c74

File tree

4 files changed

+47
-53
lines changed

4 files changed

+47
-53
lines changed

core/global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ import * as http from "./http/todo.js"
33
import * as route from "./route/todo.js"
44
import view from "./view/todo.js"
55

6-
export const Patron = {App, URLStateCapture, http, route, view};
6+
export default {App, URLStateCapture, http, route, view};

core/helpers.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getContainer } from "./container";
1+
import { getContainer } from "./container.js";
22

33
let base_url, assets_location;
44

@@ -111,16 +111,19 @@ export function comparator(value, operator, to) {
111111
}
112112

113113
/**
114-
* @type {HTMLIFrameElement}
114+
* @return {HTMLIFrameElement}
115115
*/
116-
export const page_not_fount = document.createElement('iframe');
117-
page_not_fount.allow = 'fullscreen';
118-
page_not_fount.width = '100%';
119-
page_not_fount.height = '100%';
120-
page_not_fount.src = '/public/404.html';
121-
page_not_fount.style.position = 'absolute';
122-
page_not_fount.style.border = '0';
123-
page_not_fount.style.zIndex = '100';
116+
export const page_not_fount = ()=> {
117+
const public_dir = getContainer().config.public_dir
118+
const iframe = document.createElement('iframe');
119+
iframe.allow = 'fullscreen';
120+
iframe.width = '100%';
121+
iframe.height = '100%';
122+
iframe.src = `${public_dir}/404.html`;
123+
iframe.style.position = 'absolute';
124+
iframe.style.border = '0';
125+
iframe.style.zIndex = '100';return iframe;
126+
}
124127

125128
let style_log = `
126129
<style>

core/http/status.js

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -76,54 +76,44 @@ export const STATUS = {
7676
530: 'User access denied'
7777
};
7878

79-
export function isInfo() {
80-
return this.code >= 100 && this.code <= 102;
81-
}
82-
83-
export function isSuccess() {
84-
return this.code >= 200 && this.code <= 207;
85-
}
79+
class Status {
80+
code = 200;
8681

87-
export function isRedirection() {
88-
return this.code >= 300 && this.code <= 308;
89-
}
82+
isRedirection() {
83+
return this.code >= 300 && this.code <= 308;
84+
}
9085

91-
export function isServerError() {
92-
return this.code >= 400 && this.code <= 498;
93-
}
86+
isOK() {
87+
return this.code === 200;
88+
}
9489

95-
export function isClientError() {
96-
return this.code >= 500 && this.code <= 530;
97-
}
90+
getMessageStatus(code) {
91+
if (!exists_status(code)) {
92+
throw new Error(`code ${code} status no exists`);
93+
}
94+
return STATUS[code];
95+
}
9896

99-
export function exists_status(code) {
100-
return (code in STATUS);
101-
}
97+
isInfo() {
98+
return this.code >= 100 && this.code <= 102;
99+
}
102100

103-
export function getMessageStatus(code) {
104-
if (!exists_status(code)) {
105-
throw new Error(`code ${code} status no exists`);
101+
isSuccess() {
102+
103+
return this.code >= 200 && this.code <= 207;
104+
}
105+
106+
isServerError() {
107+
return this.code >= 400 && this.code <= 498;
106108
}
107-
return status[code];
108-
}
109109

110-
export function isOK() {
111-
return this.code === 200;
112-
}
110+
isClientError() {
111+
return this.code >= 500 && this.code <= 530;
112+
}
113113

114-
function Status () {
115-
this.code = 200;
114+
exists_status(code) {
115+
return (code in STATUS);
116+
}
116117
}
117118

118-
Status.prototype = {
119-
STATUS,
120-
isOK,
121-
isInfo,
122-
isSuccess,
123-
isClientError,
124-
isRedirection,
125-
isServerError,
126-
getMessageStatus
127-
};
128-
129119
export default Status;

core/route/dispatcher.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ export default class Dispatcher {
9393
this.response = res;
9494
this.container = container;
9595
this.setNotFount(() => {
96-
this.page = page_not_fount;
96+
const iframe = page_not_fount();
97+
this.page = iframe;
9798
this.html = document.body.innerHTML;
9899
document.body.innerHTML = '';
99-
document.body.appendChild(page_not_fount);
100+
document.body.appendChild(iframe);
100101
});
101102
}
102103

0 commit comments

Comments
 (0)