mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-11 09:54:41 +00:00
link include styles to extract css
This commit is contained in:
parent
475ea4c158
commit
3c626ac2bc
1 changed files with 29 additions and 54 deletions
|
@ -325,63 +325,38 @@ function jsonToCss(jsonObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractCss(callback) {
|
function extractCss(callback) {
|
||||||
// getIncludeStyle(function (result) {
|
getIncludeStyle(function (result) {
|
||||||
// if (result) {
|
if (result) {
|
||||||
// $('body').find('*').each(function (i, pre) {
|
$('body').find('*').each(function (i, pre) {
|
||||||
// if (!$(pre).is(':visible')) {
|
if (!$(pre).is(':visible')) {
|
||||||
// $(pre).replaceWith('');
|
$(pre).replaceWith('');
|
||||||
// } else {
|
} else {
|
||||||
// var classNames = pre.getAttribute('class');
|
var classNames = pre.getAttribute('class');
|
||||||
// var tmpName = cssClassesToTmpIds[classNames];
|
if (!classNames) {
|
||||||
// var tmpNewCss = tmpIdsToNewCss[tmpName];
|
return;
|
||||||
// if (!tmpName) {
|
}
|
||||||
// tmpName = 'class-' + Math.floor(Math.random()*100000);
|
var tmpName = cssClassesToTmpIds[classNames];
|
||||||
// cssClassesToTmpIds[classNames] = tmpName;
|
var tmpNewCss = tmpIdsToNewCss[tmpName];
|
||||||
// tmpIdsToNewCss[tmpName] = {};
|
if (!tmpName) {
|
||||||
// }
|
tmpName = 'class-' + Math.floor(Math.random()*100000);
|
||||||
// if (!tmpNewCss) {
|
cssClassesToTmpIds[classNames] = tmpName;
|
||||||
// var style = window.getComputedStyle(pre);
|
}
|
||||||
// tmpNewCss = {};
|
if (!tmpNewCss) {
|
||||||
// for (var cssTagName of supportedCss) {
|
var style = window.getComputedStyle(pre);
|
||||||
// tmpNewCss[cssTagName] = style.getPropertyValue(cssTagName);
|
tmpNewCss = {};
|
||||||
// }
|
for (var cssTagName of supportedCss) {
|
||||||
// tmpIdsToNewCss[tmpName] = tmpNewCss;
|
tmpNewCss[cssTagName] = style.getPropertyValue(cssTagName);
|
||||||
// }
|
}
|
||||||
// pre.setAttribute('data-class', tmpName);
|
tmpIdsToNewCss[tmpName] = tmpNewCss;
|
||||||
// }
|
}
|
||||||
// });
|
pre.setAttribute('data-class', tmpName);
|
||||||
// callback(jsonToCss(tmpIdsToNewCss));
|
|
||||||
// } else {
|
|
||||||
// callback();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
$('body').find('*').each(function (i, pre) {
|
|
||||||
if (!$(pre).is(':visible')) {
|
|
||||||
$(pre).replaceWith('');
|
|
||||||
} else {
|
|
||||||
var classNames = pre.getAttribute('class');
|
|
||||||
if (!classNames) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var tmpName = cssClassesToTmpIds[classNames];
|
|
||||||
var tmpNewCss = tmpIdsToNewCss[tmpName];
|
|
||||||
if (!tmpName) {
|
|
||||||
tmpName = 'class-' + Math.floor(Math.random()*100000);
|
|
||||||
cssClassesToTmpIds[classNames] = tmpName;
|
|
||||||
}
|
|
||||||
if (!tmpNewCss) {
|
|
||||||
var style = window.getComputedStyle(pre);
|
|
||||||
tmpNewCss = {};
|
|
||||||
for (var cssTagName of supportedCss) {
|
|
||||||
tmpNewCss[cssTagName] = style.getPropertyValue(cssTagName);
|
|
||||||
}
|
}
|
||||||
tmpIdsToNewCss[tmpName] = tmpNewCss;
|
});
|
||||||
}
|
callback(jsonToCss(tmpIdsToNewCss));
|
||||||
pre.setAttribute('data-class', tmpName);
|
} else {
|
||||||
|
callback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
callback(jsonToCss(tmpIdsToNewCss));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue