/*
Cheetah News JS/v2 GUI
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Wojciech Polak.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var sWindow = null;
var sWindowFeeds = null;
var cWindowSaveChanges = null;
var openedLabel = null;
var movContainer = null;
var folderListMenu = null;
var menu = null;
var menuLink = null;
var menuInvt = null;
var sChanged = false;
var mFeed = null;
var con = null;
var reader = null;
var settings = null;
var main = null;
function initGui () {
reader = GID ('reader');
folderListMenu = DCE ('div', {id:'folderListMenu', className:'contextMenu'});
document.body.appendChild (folderListMenu);
topRightInfo = GID ('topRightInfo');
progressBar = GID ('progressBar');
movContainer = GID ('movContainer');
sWindow = createEmptyWindow ('s', null, _('My Stuff'));
var sWindowOptions = GID ('sWindowOptions');
sWindowOptions.style.marginTop = '3px';
sWindowFeeds = document.createElement ('DIV');
sWindowFeeds.id = 'sWindowFeeds';
sWindowFeeds.innerHTML = _('Loading...');
sWindow.appendChild (sWindowOptions);
sWindow.appendChild (sWindowFeeds);
sWindowOptions.style.display = 'block';
sWindowFeeds.style.display = 'block';
registerWindow (sWindow);
prepareWindowClose (GID ('sWindowClose'), closeSWindow);
main = document.createElement ('DIV');
main.id = 'main';
feeds = document.createElement ('DIV');
feeds.id = 'feeds';
var footer = document.createElement ('DIV');
footer.id = 'footer';
footer.style.display = 'none';
main.appendChild (feeds);
main.appendChild (footer);
var aboutLink = DCE ('span', {className: 'link'}, [_('About')]);
aboutLink.onmousedown = openAWindow;
main.appendChild (DCE ('div', {id: 'copyright'},
[DCE ('span', {}, ['© 2005-2010 The Cheetah News Team - ']),
aboutLink]));
reader.appendChild (main);
GID ('welcome').innerHTML = _('Welcome');
prepareLink ('about', 'Cheetah News', _('About Cheetah News'), openAWindow);
prepareBLink ('showAllActive', _('show active'), _('Show all active feeds'), showAllActive);
prepareBLink ('showAllLoaded', _('show loaded'), _('Show all loaded feeds'), showAllLoaded);
prepareBLink ('hideAll', _('hide all'), _('Hide all feeds'), function () {
hideAll ();
WindowSystem.focus (sWindow);
});
prepareBLink ('refreshAll', _('refresh visible'), _('Refresh all visible feeds'), refreshVisible);
if (Modules.Filter) {
prepareBLink ('filterVisible', _('filter visible'), _('Filter visible feeds'), Modules.Filter.shortcut);
GID ('filterVisible').onclick = function (e) {
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation ();
if (msie)
setTimeout (function () { setCaretToEnd (GID ('filterInput')); }, 250);
return false;
};
}
GID ('header').style.display = 'block';
var expFolders = GID ('expandFolders');
expFolders.innerHTML = _('Expand');
expFolders.title = _('Expand folders');
expFolders.onmousedown = expandFolders;
expFolders.onmouseover = styleLink;
expFolders.onmouseout = styleILink;
var cpsFolders = GID ('collapseFolders');
cpsFolders.innerHTML = _('Collapse');
cpsFolders.title = _('Collapse folders');
cpsFolders.onmousedown = collapseFolders;
cpsFolders.onmouseover = styleLink;
cpsFolders.onmouseout = styleILink;
SIH ({'menuOpenSWindow' : ' ' + _('Show My Stuff') + ' ',
'menuOpenCWindow1' : ' ' + _('Add New Feed') + ' ',
'menuOpenCWindow2' : ' ' + _('Manage Subscriptions') + ' ',
'menuOpenCWindow3' : ' ' + _('Manage Folders') + ' ',
'menuOpenCWindow4' : ' ' + _('User Settings') + ' ',
'menuOpenFacebook': ' ' + _('Facebook News Feed') + ' ',
'menuOpenFanbox': ' ' + _('Facebook Fanbox') + ' ',
'logout' : ' ' + _('Logout') + ' '}, true);
initMenu ();
resizeChrome ();
window.onresize = resizeChrome;
setFooter ();
if (linux)
$('.cWindowLabel').css ('margin-top', '5px');
$('#addURLForm,#addFolderForm,#weLocationForm,#nbForm').attr ('autocomplete', 'off');
var whatsnew = GID ('whatsnew');
if (CONF.whatsnew && whatsnew) {
whatsnew.className = 'link';
whatsnew.onmousedown = function () {
openFeedPreview ('http://blog.cheetah-news.com/feed', 'Cheetah News Blog');
return false;
};
}
$(reader).delegate ('div.play-video', 'click', play_video);
try { window.focus (); } catch (E) {}
}
function createEmptyWindow (id, classTitle, title) {
var win = document.createElement ('DIV');
win.id = id + 'Window';
if (classTitle)
win.className = classTitle;
win.style.display = 'none';
var wtb = document.createElement ('DIV');
wtb.id = id + 'WindowTitleBar';
wtb.className = 'WindowTitleBarInactive';
wtb.innerHTML = '<table width="100%"><tr><td align="left">' + title + '</td><td align="right"><span id="'
+ id + 'WindowClose" class="link" title="' + _('Close Window')
+ '"><img class="img-12-remove" src="images/t.gif" width="12" height="12" />'
+ '</span></td></tr></table>';
win.appendChild (wtb);
reader.appendChild (win);
return win;
}
function createBWindow (id, desc) {
var win = document.createElement ('DIV');
win.id = 'bWindow_' + id;
win.className = 'bWindow';
win.style.display = 'none';
var wtb = document.createElement ('DIV');
wtb.className = 'WindowTitleBarInactive';
wtb.innerHTML = '<table width="100%"><tr><td align="left" style="cursor:default"><span id="bWindowTitle_' + id
+ '">' + desc + '</span> <span id="bWindowReload_' + id
+ '" class="link" title="' + _('Reload this feed') +'">'
+ '<img class="img-12-reload" src="images/t.gif" width="12" height="12" /></span><span id="bWindowFiltered_' + id
+ '" class="feedFiltered"></span></td><td align="right"><span id="bWindowClose_' + id
+ '" class="link" title="' + _('Close Window') + '">'
+ '<img class="img-12-remove" src="images/t.gif" width="12" height="12" /></span></td></tr></table>';
wtb.ondblclick = function () {
clearSelection ();
scrollToElement (win);
};
win.appendChild (wtb);
var fw = document.createElement ('DIV');
fw.id = 'feedWaiting_' + id;
fw.className = 'feedWaiting';
fw.innerHTML = _('fetching data...');
if (msie)
fw.style.styleFloat = 'right';
else {
fw.style.position = 'absolute';
fw.style.right = '9px';
}
fw.style.display = 'none';
win.appendChild (fw);
var bc = document.createElement ('DIV');
bc.id = 'bWindowContent_' + id;
bc.className = 'bWindowContent';
win.appendChild (bc);
traverseDOM (win, prepareFeed, id);
registerBWindow (win);
feeds.appendChild (win);
}
function prepareWindowClose (obj, cb) {
if (obj) {
obj.onmousedown = function (e) {
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation ();
return false;
};
obj.onclick = function () {
cb (this);
};
}
}
function prepareLink (id, text, title, fnc) {
var link = GID (id);
if (link) {
link.innerHTML = text;
link.title = title;
link.onmousedown = function (e) {
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation ();
fnc ();
return false;
};
}
}
function prep
|