<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>Hello APP</title>
<link rel="stylesheet" type="text/css" href="../css/api.css" />
<style>
#con{
margin: 10px;
font-size: 24px;
}
ul{
margin-bottom: 10px;
}
ul li{
margin: 5px 10px;
padding: 5px;
color: #000;
word-wrap: break-word;
}
</style>
</head>
<body>
<label id="con">Hello APP</label>
<div id='sys-info'></div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
apiready = function() {
initBookReader();
}
function initBookReader()
{
var ReadObj = api.require('bookReader');
ReadObj.open({
filePath : "widget://res/test.txt", //默认文档属性
progress : 0,
bg : "#fffff0",
h : api.winHeight,
animType : "curl",
textStyle : {
color : "#333333", //字体色
size : 20 //字体大小
}
}, function(ret, err) {
if (ret) {
//点击了中间,显示工具条
if (ret.eventType == "click") {
changefile();
}
console.log("da"+JSON.stringify(ret));
} else {
alert(err);
}
});
}
function changefile() {
var fileurl = "http://www.151km.cn/xiaoshuo/test.txt";
api.download({
url : fileurl,
//savePath : api.fsDir + "/" + filename,
report : true,
cache : true,
allowResume : true
}, function(ret, err) {
if (ret) {
if (ret.state == 1) {
//下载保存,要阅读的文件
console.log("open:" + ret.savePath);
//var fileUrl="widget://res/book/book02.txt"; //这个是正常的
var bookReader = api.require('bookReader');
bookReader.setValue({
bg: '#f00',
filePath:ret.savePath,
textStyle:{
}
}, function(ret, err) {
if (ret.status) {
alert(JSON.stringify(ret));
} else {
alert("err"+JSON.stringify(err));
}
console.log("set"+JSON.stringify(err));
});
}
console.log("jieg"+JSON.stringify(ret));
} else {
showMsgDown("书籍下载失败", 1000);
}
});
}
</script>
</html>
//
<script type="text/javascript">
apiready = function() {
initBookReader();
}
function initBookReader()
{
var ReadObj = api.require('bookReader');
ReadObj.open({
filePath : "widget://res/test.txt", //默认文档属性
progress : 0,
bg : "#fffff0",
h : api.winHeight,
codingType:'utf8',
animType : "curl",
textStyle : {
color : "#333333", //字体色
size : 20 //字体大小
}
}, function(ret, err) {
if (ret) {
//点击了中间,显示工具条
if (ret.eventType == "click") {
changefile();
}
console.log("da"+JSON.stringify(ret));
} else {
alert(err);
}
});
}
function changefile() {
var fileurl = "http://www.151km.cn/xiaoshuo/2.txt";
api.download({
url : fileurl,
//savePath : api.fsDir + "/" + filename,
report : true,
cache : true,
allowResume : true
}, function(ret, err) {
if (ret) {
if (ret.state == 1) {
//下载保存,要阅读的文件
console.log("open:" + ret.savePath);
//var fileUrl="widget://res/book/book02.txt"; //这个是正常的
var bookReader = api.require('bookReader');
bookReader.setValue({
bg: '#f00',
filePath:ret.savePath,
textStyle:{
}
}, function(ret, err) {
if (ret.status) {
alert(JSON.stringify(ret));
} else {
alert("err"+JSON.stringify(err));
}
console.log("set"+JSON.stringify(err));
});
}
console.log("jieg"+JSON.stringify(ret));
} else {
showMsgDown("书籍下载失败", 1000);
}
});
}
</script>
<script type="text/javascript">
apiready = function() {
readtiku
}
readtiku = function() {
var obj = api.require('bookReader');
obj.open({
x:0,
y:50,
with:'100%',
height:'auto',
codingType:'utf8',
filePath : 'http://www.151km.cn/xiaoshuo/2.txt'
//这里换成widget://url/txt.txt也不行。示例里是widget://res/test.txt;
},function(ret, err){
if(ret){
api.alert({msg:ret.eventType+ret.progress});
}else{
api.alert('NONE');
}
});
}
</script>