2016-08-21 12:05:23 +00:00
|
|
|
var fd_loadedHash={}, fd_loadedList=[], fd_all={}, fd_allCnt, fd_progress=0,
|
|
|
|
fd_lang, fd_offsets=[], fd_scrolled=0, fd_modLinks={};
|
2016-08-19 12:47:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
function
|
|
|
|
fd_status(txt)
|
|
|
|
{
|
|
|
|
var errmsg = $("#errmsg");
|
|
|
|
if(!$(errmsg).length) {
|
|
|
|
$('#menuScrollArea').append('<div id="errmsg">');
|
|
|
|
errmsg = $("#errmsg");
|
|
|
|
}
|
|
|
|
if(txt == "")
|
|
|
|
$(errmsg).remove();
|
|
|
|
else
|
|
|
|
$(errmsg).html(txt);
|
|
|
|
}
|
|
|
|
|
|
|
|
function
|
|
|
|
fd_fC(fn, callback)
|
|
|
|
{
|
|
|
|
var p = location.pathname;
|
|
|
|
var cmd = p.substr(0,p.indexOf('/doc'))+
|
|
|
|
'?cmd='+fn+
|
|
|
|
(typeof(csrfToken)!='undefined'?csrfToken:'')+
|
|
|
|
'&XHR=1';
|
|
|
|
var ax = $.ajax({ cache:false, url:cmd });
|
|
|
|
ax.done(callback);
|
|
|
|
ax.fail(function(req, stat, err) {
|
|
|
|
console.log("FAIL ERR:"+err+" STAT:"+stat);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function
|
|
|
|
loadOneDoc(mname, lang)
|
|
|
|
{
|
2016-08-21 12:05:23 +00:00
|
|
|
var origLink = mname;
|
|
|
|
|
2016-08-19 12:47:50 +00:00
|
|
|
function
|
|
|
|
done(err, calc)
|
|
|
|
{
|
2016-08-21 12:05:23 +00:00
|
|
|
if(fd_progress) {
|
|
|
|
fd_status(fd_progress+" / "+fd_allCnt);
|
|
|
|
if(++fd_progress > fd_allCnt) {
|
|
|
|
fd_progress = 0;
|
2016-08-19 12:47:50 +00:00
|
|
|
setTimeout(calcOffsets,100); // Firefox returns wrong offsets
|
|
|
|
fd_status("");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(calc)
|
|
|
|
setTimeout(calcOffsets,100);
|
|
|
|
if(!err)
|
2016-08-21 12:05:23 +00:00
|
|
|
setTimeout(function(){location.href = "#"+origLink;}, 100);
|
2016-08-19 12:47:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-21 12:05:23 +00:00
|
|
|
if(fd_modLinks[mname])
|
|
|
|
mname = fd_modLinks[mname];
|
|
|
|
if(fd_loadedHash[mname] && fd_loadedHash[mname] == lang)
|
2016-08-19 12:47:50 +00:00
|
|
|
return done(false, false);
|
|
|
|
|
|
|
|
fd_fC("help "+mname+" "+lang, function(ret){
|
|
|
|
//console.log(mname+" "+lang+" => "+ret.length);
|
|
|
|
if(ret.indexOf("<html>") != 0 || ret.indexOf("<html>No help found") == 0)
|
|
|
|
return done(true, false);
|
|
|
|
ret = ret.replace(/<\/?html>/g,'');
|
|
|
|
ret = ret.replace(/Keine deutsche Hilfe gefunden!<br\/>/,'');
|
|
|
|
ret = '<div id="FD_'+mname+'">'+ret+'</div>';
|
2016-08-21 12:05:23 +00:00
|
|
|
ret = ret.replace(/target="_blank"/g, ''); // revert help URL rewrite
|
2016-11-20 18:24:36 +00:00
|
|
|
ret = ret.replace(/href=".*?commandref.*?.html#/g, 'href="#');
|
2016-08-19 12:47:50 +00:00
|
|
|
|
2016-08-21 12:05:23 +00:00
|
|
|
if(fd_loadedHash[mname])
|
2016-08-19 12:47:50 +00:00
|
|
|
$("div#FD_"+mname).remove();
|
|
|
|
|
2016-08-21 12:05:23 +00:00
|
|
|
if(!fd_loadedHash[mname])
|
|
|
|
fd_loadedList.push(mname);
|
|
|
|
fd_loadedHash[mname] = lang;
|
|
|
|
fd_loadedList.sort();
|
2016-08-19 12:47:50 +00:00
|
|
|
var idx=0;
|
2016-08-21 12:05:23 +00:00
|
|
|
while(fd_loadedList[idx] != mname)
|
2016-08-19 12:47:50 +00:00
|
|
|
idx++;
|
|
|
|
var toIns = "perl";
|
2016-08-21 12:05:23 +00:00
|
|
|
if(idx < fd_loadedList.length-1)
|
|
|
|
toIns = fd_loadedList[idx+1];
|
2016-08-19 12:47:50 +00:00
|
|
|
console.log("insert "+mname+" before "+toIns);
|
2016-08-21 12:05:23 +00:00
|
|
|
$(ret).insertBefore("a[name="+toIns+"]");
|
|
|
|
addAHooks("div#FD_"+mname);
|
2016-08-19 12:47:50 +00:00
|
|
|
return done(false, true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-08-21 12:05:23 +00:00
|
|
|
function
|
|
|
|
addAHooks(el)
|
|
|
|
{
|
|
|
|
$(el).find("a[href]").each(function(){
|
|
|
|
var href = $(this).attr("href");
|
|
|
|
if(!href || href.indexOf("#") != 0)
|
|
|
|
return;
|
|
|
|
href = href.substr(1);
|
|
|
|
if(fd_modLinks[href] && !fd_loadedHash[href]) {
|
|
|
|
$(this).click(function(){
|
|
|
|
$("a[href=#"+href+"]").unbind('click');
|
|
|
|
loadOneDoc(href, fd_lang);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-08-19 12:47:50 +00:00
|
|
|
function
|
|
|
|
calcOffsets()
|
|
|
|
{
|
2016-08-21 12:05:23 +00:00
|
|
|
fd_offsets=[];
|
|
|
|
for(var i1=0; i1<fd_loadedList.length; i1++) {
|
|
|
|
var cr = $("a[name="+fd_loadedList[i1]+"]").offset();
|
|
|
|
fd_offsets.push(cr ? cr.top : -1);
|
2016-08-19 12:47:50 +00:00
|
|
|
}
|
|
|
|
checkScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
function
|
|
|
|
checkScroll()
|
|
|
|
{
|
2016-08-21 12:05:23 +00:00
|
|
|
if(!fd_scrolled) {
|
2016-08-19 12:47:50 +00:00
|
|
|
setTimeout(checkScroll, 500);
|
|
|
|
return;
|
|
|
|
}
|
2016-08-21 12:05:23 +00:00
|
|
|
fd_scrolled = 0;
|
2016-08-19 12:47:50 +00:00
|
|
|
var viewTop=$(window).scrollTop(), viewBottom=viewTop+$(window).height();
|
|
|
|
var idx=0;
|
2016-08-21 12:05:23 +00:00
|
|
|
while(idx<fd_offsets.length) {
|
|
|
|
if(fd_offsets[idx] >= viewTop && viewBottom > fd_offsets[idx]+30)
|
2016-08-19 12:47:50 +00:00
|
|
|
break;
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
|
2016-08-21 12:05:23 +00:00
|
|
|
if(idx >= fd_offsets.length) {
|
2016-08-19 12:47:50 +00:00
|
|
|
$("a#otherLang").hide();
|
|
|
|
|
|
|
|
} else {
|
2016-08-21 12:05:23 +00:00
|
|
|
var mname = fd_loadedList[idx];
|
|
|
|
var l1 = fd_loadedHash[mname], l2 = (l1=="EN" ? "DE" : "EN");
|
2016-08-19 12:47:50 +00:00
|
|
|
$("a#otherLang span.mod").html(mname);
|
|
|
|
$("a#otherLang span[lang="+l1+"]").hide();
|
|
|
|
$("a#otherLang span[lang="+l2+"]").show();
|
|
|
|
$("a#otherLang").show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function
|
|
|
|
loadOtherLang()
|
|
|
|
{
|
|
|
|
var mname = $("a#otherLang span.mod").html();
|
2016-08-21 12:05:23 +00:00
|
|
|
loadOneDoc(mname, fd_loadedHash[mname]=="EN" ? "DE" : "EN");
|
2016-08-19 12:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
var p = location.pathname;
|
2016-08-21 12:05:23 +00:00
|
|
|
fd_lang = p.substring(p.indexOf("commandref")+11,p.indexOf(".html"));
|
|
|
|
if(!fd_lang || fd_lang == '.')
|
|
|
|
fd_lang = "EN";
|
|
|
|
|
|
|
|
$("div#modLinks").each(function(){
|
|
|
|
var a1 = $(this).html().split(" ");
|
|
|
|
for(var i1=0; i1<a1.length; i1++) {
|
|
|
|
var a2 = a1[i1].split(/[:,]/);
|
|
|
|
var mName = a2.shift();
|
|
|
|
for(var i2=0; i2<a2.length; i2++)
|
|
|
|
if(!fd_modLinks[a2[i2]])
|
|
|
|
fd_modLinks[a2[i2]] = mName;
|
|
|
|
}
|
|
|
|
});
|
2016-08-19 12:47:50 +00:00
|
|
|
|
2016-08-21 12:05:23 +00:00
|
|
|
$("a[name]").each(function(){ fd_loadedHash[$(this).attr("name")]=fd_lang; });
|
2016-08-19 12:47:50 +00:00
|
|
|
$("table.summary td.modname a")
|
2016-08-21 12:05:23 +00:00
|
|
|
.each(function(){
|
|
|
|
var mod = $(this).html();
|
|
|
|
fd_all[mod]=1;
|
|
|
|
fd_modLinks[mod] = fd_modLinks[mod+"define"] = fd_modLinks[mod+"get"] =
|
|
|
|
fd_modLinks[mod+"set"] = fd_modLinks[mod+"attribute"]= mod;
|
|
|
|
})
|
2016-08-19 12:47:50 +00:00
|
|
|
.click(function(e){
|
|
|
|
e.preventDefault();
|
2016-08-21 12:05:23 +00:00
|
|
|
loadOneDoc($(this).html(), fd_lang);
|
2016-08-19 12:47:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if(location.hash)
|
2016-08-21 12:05:23 +00:00
|
|
|
loadOneDoc(location.hash.substr(1), fd_lang);
|
2016-08-19 12:47:50 +00:00
|
|
|
|
|
|
|
$("a[name=loadAll]").show().click(function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
$("a[name=loadAll]").hide();
|
|
|
|
location.href = "#doctop";
|
2016-08-21 12:05:23 +00:00
|
|
|
fd_allCnt = 0;
|
|
|
|
for(var m in fd_all) fd_allCnt++
|
|
|
|
fd_progress = 1;
|
|
|
|
for(var mname in fd_all)
|
|
|
|
loadOneDoc(mname, fd_lang);
|
2016-08-19 12:47:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$("a#otherLang").click(loadOtherLang);
|
2016-08-21 12:05:23 +00:00
|
|
|
addAHooks("body");
|
2016-08-19 12:47:50 +00:00
|
|
|
|
|
|
|
window.onscroll = function(){
|
2016-08-21 12:05:23 +00:00
|
|
|
if(!fd_scrolled++)
|
2016-08-19 12:47:50 +00:00
|
|
|
setTimeout(checkScroll, 500);
|
|
|
|
};
|
|
|
|
});
|