I have an ePub3 book involving scripting which works fine with Readium, but only partially in iBooks. My guess is that the JavaScript is erroring out at some point (although as a standard web app the exact same code works fine in Safari). Any thoughts on how to go about debugging this?
How to debug scripted ePub3 in iBooks?
Asked Answered
Update: this problem turned out not to be a scripting problem, but rather missing content due to some apparent differences in how iBooks handles overflow in the CSS sense--it seems to hide overflow in some cases even when the CSS would indicate it should not. –
Quadrennial
Good question nevertheless. IBooks does allow for WebSockets so perhaps a solution could be built on top of it to provide debugging.. –
Nel
Good idea. My initial solution was a real simple "console" which allows you to type in and evaluate JS expressions. –
Quadrennial
AlexanderN : Did you manage to establish an external connection from iBooks with WebSockets ? I cannot do that –
Fancyfree
@AlexanderN I did not try, but if someone else manages to make this work, I'd love to hear the details. –
Quadrennial
iBooks will not allow JS to make external network connections of any kind, so WebSockets simply won't work. –
Admissible
Azardi Online can be used to read the file using the browser. The built-in or add-in console can be used from there to debug. Or a console shim can be created:
if(!console) {
console = {
"_log" : [],
"log" : function() {
var arr = [];
for ( var i = 0; i < arguments.length; i++ ) {
arr.push( arguments[ i ] );
}
this._log.push( arr.join( ", ") );
},
"trace" : function() {
var stack;
try {
throw new Error();
} catch( ex ) {
stack = ex.stack;
}
console.log( "console.trace()\n" + stack.split( "\n" ).slice( 2 ).join( " \n" ) );
},
"dir" : function( obj ) {
console.log( "Content of " + obj );
for ( var key in obj ) {
var value = typeof obj[ key ] === "function" ? "function" : obj[ key ];
console.log( " -\"" + key + "\" -> \"" + value + "\"" );
}
},
"show" : function() {
alert( this._log.join( "\n" ) );
this._log = [];
}
};
window.onerror = function( msg, url, line ) {
console.log("ERROR: \"" + msg + "\" at \"" + "\", line " + line);
}
window.addEventListener( "touchstart", function( e ) {
if( e.touches.length === 3 ) {
console.show();
}
} );
}
References
Yes, or I could run it in Readium, but Readium is not iBooks and neithe is Azardi, unfortunately, as fine a product as that is. But running it in the browser on iPad with its minimalistic console support is a useful idea, thanks, accepting this answer. –
Quadrennial
You can enable the Webkit Web Inspector in iBooks with this line in your terminal app to change its settings:
defaults write com.apple.iBooksX WebKitDeveloperExtras -bool YES
You'll find the inspector after re-starting iBooks in the context menu (More > Show Inspector). All the inspector tools are available including console etc.
Doesn't seem to work anymore –
Oligarchy
Azardi Online can be used to read the file using the browser. The built-in or add-in console can be used from there to debug. Or a console shim can be created:
if(!console) {
console = {
"_log" : [],
"log" : function() {
var arr = [];
for ( var i = 0; i < arguments.length; i++ ) {
arr.push( arguments[ i ] );
}
this._log.push( arr.join( ", ") );
},
"trace" : function() {
var stack;
try {
throw new Error();
} catch( ex ) {
stack = ex.stack;
}
console.log( "console.trace()\n" + stack.split( "\n" ).slice( 2 ).join( " \n" ) );
},
"dir" : function( obj ) {
console.log( "Content of " + obj );
for ( var key in obj ) {
var value = typeof obj[ key ] === "function" ? "function" : obj[ key ];
console.log( " -\"" + key + "\" -> \"" + value + "\"" );
}
},
"show" : function() {
alert( this._log.join( "\n" ) );
this._log = [];
}
};
window.onerror = function( msg, url, line ) {
console.log("ERROR: \"" + msg + "\" at \"" + "\", line " + line);
}
window.addEventListener( "touchstart", function( e ) {
if( e.touches.length === 3 ) {
console.show();
}
} );
}
References
Yes, or I could run it in Readium, but Readium is not iBooks and neithe is Azardi, unfortunately, as fine a product as that is. But running it in the browser on iPad with its minimalistic console support is a useful idea, thanks, accepting this answer. –
Quadrennial
© 2022 - 2024 — McMap. All rights reserved.