View Code
proto.initProcess =
function
(){
var
self =
this
,
prev =
null
,
curr =
null
,
next =
null
;
debug.group(
"start of init process"
);
var
idx = self.chapterIndex;
debug.info(
"PageBase: 执行初始化之前的操作!"
);
self.initProcessBefore();
if
(idx == 0){
debug.info(
"PageBase: 初始化入口点从第一章开始进入"
);
debug.info(
"PageBase: 解析器解析第一章数据!"
);
curr = self.process(self.chapters[idx]);
curr.then(
function
(pages){
debug.info(self.format(
"PageBase: 第一章数据解析完成,解析页面数为{0}"
, pages.length));
self.cPages = pages;
if
(self.isChangeFont){
self.idx = Math.ceil((pages.length - 1) * self.idx);
}
self.cPages.idx = idx;
if
(1 === self.chapters.length){
deferred.all([curr]).then(self.steup.bind(self));
}
else
{
debug.info(
"PageBase:解析器解析后一章数据!"
);
next = self.loadNextData(idx + 1);
next.then(
function
(args){
debug.info(self.format(
"PageBase: 后一章数据解析完成,解析页面数为{0}"
, args.pages.length));
self.nPages = args.pages;
self.nPages.idx = idx + args.index;
debug.info(self.format(
"PageBase: 初始化数据解析完成, 当章索引{0} 当章页数{1} 下章索引{2} 下章页数{3}"
, self.cPages.idx , self.cPages.length , self.nPages.idx , self.nPages.length));
debug.info(
"PageBase: 初始化数据解析完成,即将生成结构操作!"
);
});
deferred.all([curr , next]).then(self.steup.bind(self));
}
});
}
else
if
(idx == self.chapters.length -1){
debug.info(
"PageBase: 初始化入口点从最后一章开始进入"
);
debug.info(
"PageBase:解析器解析最后一章数据!"
);
prev = self.loadPrevData(idx - 1);
prev.then(
function
(args){
self.pPages = args.pages;
self.pPages.idx = args.index + 1;
debug.info(self.format(
"PageBase: 最后一章的前一章数据解析完成,解析页面数为{0}"
, args.pages.length));
curr = self.process(self.chapters[idx]);
curr.then(
function
(pages , data){
if
(self.isChangeFont){
self.idx = Math.ceil((pages.length - 1) * self.idx);
}
self.cPages = pages ;
self.cPages.idx = idx;
debug.info(self.format(
"PageBase: 最后一章数据解析完成,解析页面数为{0}"
, pages.length));
debug.info(self.format(
"PageBase: 初始化数据解析完成, 前章索引{0} 前章页数{1} 当章索引{2} 当章页数{3} "
, self.pPages.idx , self.pPages.length , self.cPages.idx , self.cPages.length ));
debug.info(
"PageBase: 初始化数据解析完成,即将生成结构操作!"
);
});
deferred.all([prev , curr]).then(self.steup.bind(self));
});
}
else
{
debug.info(
"PageBase: 初始化入口点从中间章开始进入"
);
prev = self.loadPrevData(idx - 1);
debug.info(
"PageBase:解析器解析中间章的前一章数据!"
);
prev.then(
function
(args){
self.pPages = args.pages ;
self.pPages.idx = args.index;
debug.info(self.format(
"PageBase: 中间章前一章数据解析完成,解析页面数为{0}"
, args.pages.length));
debug.info(
"PageBase:解析器解析中间章数据!"
);
curr = self.process(self.chapters[idx]);
curr.then(
function
(pages , data){
if
(self.isChangeFont){
self.idx = Math.ceil((pages.length) * self.idx);
}
self.cPages = pages ;
self.cPages.idx = idx;
debug.info(self.format(
"PageBase: 中间章数据解析完成,解析页面数为{0}"
,pages.length));
debug.info(
"PageBase:解析器解析中间章的后一章数据!"
);
next = self.loadNextData(idx + 1);
next.then(
function
(args){
self.nPages = args.pages ;
self.nPages.idx = idx + args.index;
debug.info(self.format(
"PageBase: 中间章后一章数据解析完成,解析页面数为{0}"
, args.pages.length));
debug.info(self.format(
"PageBase: 初始化数据解析完成, 前章索引{0} 前章页数{1} 当章索引{2} 当章页数{3} 下章索引{4} 下章页数{5}"
, self.pPages.idx , self.pPages.length , self.cPages.idx , self.cPages.length , self.nPages.idx , self.nPages.length));
debug.info(
"PageBase: 初始化数据解析完成,即将生成结构操作!"
)
});
deferred.all([prev , curr , next]).then(self.steup.bind(self));
});
});
}