Cosas que no se pueden comitar
const fixScripts = (node, fixer) => {
$(node).children('script[src]').each((index, child) => {
let src = $(child).attr('src');
if (/\/.+\.js*/.test(src)) {
src = fixer + src;
}
$(child).attr('src', src);
});
};
const fixStylesheets = (node, fixer) => {
$(node).children('link[rel="stylesheet"]').each(function (index, css) {
$(css).attr('type', 'text/css');
let href = $(css).attr('href');
if (/\/.+\.css*/.test(href)) {
href = fixer + href;
}
$(css).attr('href', href);
});
};
export function testRoomDetail () {
return (dispatch) => {
dispatch({ type: 'test_Celia' });
//http://localhost:8010/api-pb/room/media/1/33/
return api.get('/api-pb/room/media/1/33/', 'es').then(r => {
if (r && r.html) {
const fakeEL = document.createElement('html');
$(fakeEL).html(r.html);
fixStylesheets(fakeEL, 'http://newes.sandos.com');
fixScripts(fakeEL, 'http://newes.sandos.com');
return $(fakeEL).html();
}
return null;
});
}
}