📄 app.js
字号:
var proxyURL = 'xmlProxy.asp?url=';
var User = new Object();
User.feedsId = null;
App.moduleList = [];
var appLocation = window.location.href;
var URLDomain = appLocation.substring(0,appLocation.indexOf("/", 7));
if (!URLDomain) URLDomain = appLocation;
App.location = URLDomain;
App.Modules = new Object();
App.Modules.RssReaderInfos = {
infos: App.Loc.defaultRssReader_infos,
defaultObj: {status:1, share:0, title:"", moduleName:"RssReader", data:{}}
}
App.Modules.GmailInfos = {
title: App.Loc.defaultGmail_title,
infos: App.Loc.defaultGmail_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultGmail_title, moduleName:"Gmail", data:{}},
path: "modules/gmail/gmail.js"
}
App.Modules.WeatherInfos = {
title: App.Loc.defaultWeather_title,
infos: App.Loc.defaultWeather_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultWeather_title, moduleName:"Weather", data:{town:"FRXX0076"}},
path: "modules/weather/weather.js"
}
App.Modules.PriceWatchInfos = {
title: App.Loc.defaultPriceWatch_title,
infos: App.Loc.defaultPriceWatch_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultPriceWatch_title, moduleName:"PriceWatch", data:{query:"ipod nano", catId:"120501", nbOffers:"4"}},
path: "modules/priceWatch/priceWatch.js"
}
App.Modules.WebSearchInfos = {
title: App.Loc.defaultWebSearch_title,
infos: App.Loc.defaultWebSearch_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultWebSearch_title, moduleName:"WebSearch", data:{}},
path: "modules/webSearch/webSearch.js"
}
App.Modules.MyBookmarksInfos = {
title: App.Loc.defaultMyBookmarks_title,
infos: App.Loc.defaultMyBookmarks_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultMyBookmarks_title, moduleName:"MyBookmarks", data:{}}
}
App.Modules.PublicBookmarksInfos = {
title: App.Loc.defaultPublicBookmarks_title,
infos: App.Loc.defaultPublicBookmarks_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultPublicBookmarks_title, moduleName:"PublicBookmarks", data:{}}
}
App.Modules.FlickrInfos = {
title: App.Loc.defaultFlickr_title,
infos: App.Loc.defaultFlickr_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultFlickr_title, moduleName:"Flickr", data:{}}
}
App.Modules.PostItInfos = {
title: App.Loc.defaultPostIt_title,
infos: App.Loc.defaultPostIt_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultPostIt_title, moduleName:"PostIt", data:{}},
path: "modules/postIt/postIt.js"
}
App.Modules.TodoListInfos = {
title: App.Loc.defaultTodoList_title,
infos: App.Loc.defaultTodoList_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultTodoList_title, moduleName:"TodoList", data:{}}
}
App.Modules.WritelyInfos = {
title: App.Loc.defaultWritely_title,
infos: App.Loc.defaultWritely_infos,
defaultObj:{status:1, share:0, title:App.Loc.defaultWritely_title, moduleName:"Writely", data:{}},
path: "modules/writely/writely.js"
}
// ========= MISC ====================================================
App.CollapseAllModules = function() {
var ln = App.moduleList.length;
for (var z=0; z<ln; z++) {
App.moduleList[z].showHideModule(false, "nosave");
}
App.saveUserData("collapseExpand", 0);
}
App.ExpandAllModules = function() {
var ln = App.moduleList.length;
for (var z=0; z<ln; z++) {
App.moduleList[z].showHideModule(true, "nosave");
}
App.saveUserData("collapseExpand", 1);
}
// ========= NAVIGATION MENU ====================================================
App.Nav = new Object();
App.Nav.isOpen = false;
App.Nav.isModuleBox = false;
App.Nav.width = 220;
App.Nav.isFeedsUpdated = false;
App.Nav.openCloseSelection = function() {
var divTree = document.getElementById("nav");
if (divTree.hasChildNodes()) {
var tree = document.getElementById("selectionTree");
if (divTree.firstChild.style.display=="none") {
divTree.firstChild.style.display = "block";
tree.style.width = App.Nav.width+"px";
App.Nav.isOpen = true;
} else {
divTree.firstChild.style.display = "none";
tree.style.width = "9px";
App.Nav.removeModuleBox();
App.Nav.isOpen = false;
}
} else {
divTree.style.width = App.Nav.width+"px";
App.Nav.build();
App.Nav.isOpen = true;
}
App.FeedReader.resize();
}
App.Nav.removeInfosBox = function() {
var div = document.getElementById("navInfosBox");
div.innerHTML = "";
div.style.display = "none";
}
App.Nav.removeModuleBox = function() {
var div = document.getElementById("navModuleBox");
div.innerHTML = "";
div.style.display = "none";
App.Nav.isModuleBox = false;
}
App.Nav.drawModuleBox = function(node) {
App.Nav.removeModuleBox();
App.Nav.isModuleBox = true;
App.Nav.removeInfosBox();
var div = document.getElementById("navModuleBox");
div.style.display = "block";
div.style.left = (App.Nav.width-2)+"px";
div.style.top = (findPosY(node)-12)+"px";
var frame = document.createElement("div");
frame.className = "frame";
var frame2 = document.createElement("div");
frame2.className = "frame2";
frame2.id = "pickupZone";
frame.appendChild(frame2);
div.appendChild(frame);
}
App.Nav.openMyFeeds = function() {
var div = document.getElementById("myFeeds");
if (div) div.firstChild.onclick();
}
App.Nav.build = function() {
var moduleSelection = document.createElement("div");
moduleSelection.id = "moduleSelection";
var selectionFrame = document.createElement("div");
selectionFrame.id = "moduleSelectionFrame";
var frame2 = document.createElement("div");
frame2.id = "widgetsList";
frame2.style.margin = "3px";
var moduleListContent = '<div class="separator"></div>'+
'<div mod="WebSearch" ico="img/search.gif" class="liLike"><div class="itemLineMain"><div class="folderIcon"></div><div class="text">'+App.Modules.WebSearchInfos.title+'</div></div></div>'+
'<div mod="Weather" ico="img/weather.gif" class="liLike"><div class="itemLineMain"><div class="folderIcon"></div><div class="text">'+App.Modules.WeatherInfos.title+'</div></div></div>'+
'<div mod="Gmail" ico="http://mail.google.com/favicon.ico" class="liLike"><div class="itemLineMain"><div class="folderIcon"></div><div class="text">'+App.Modules.GmailInfos.title+'</div></div></div>'+
'<div mod="PostIt" ico="img/postit.gif" class="liLike"><div class="itemLineMain"><div class="folderIcon"></div><div class="text">'+App.Modules.PostItInfos.title+'</div></div></div>';
moduleListContent += '<div mod="PriceWatch" class="liLike"><div class="itemLineMain"><div class="folderIcon"></div><div class="text">'+App.Modules.PriceWatchInfos.title+'</div></div></div>';
var content = '<div style="padding: 0 0 5px;height:100%;">'+
'<div style="float:right;padding:2px"><img src="img/closeMod.gif" /></div>'+
'<div mod="RssReader" ico="img/add2.gif" style="padding: 5px 2px 0 7px"><div class="itemLineMain"><div class="folderIcon"></div><div class="text">'+App.Loc.navAddFeed+'</div></div></div>'+
'<div class="separator"></div>'+
'<div id="myFeeds" sub="0" class="liLike"><div class="itemLineMain"><div class="showSub"></div><div class="text">'+App.Loc.navMyFeeds+'</div></div></div>'+
'<div id="featuredFeeds" sub="1" class="liLike"><div class="itemLineMain"><div class="showSub"></div><div class="text">'+App.Loc.navFeaturedFeeds+'</div></div></div>'+
'<div sub="2" class="liLike"><div class="itemLineMain"><div class="showSub"></div><div class="text">'+App.Loc.navCategories+'</div></div></div>'+
moduleListContent+
'</div>';
var contentInFeaturedPageMode = '<div style="padding: 0 0 5px;height:100%;">'+
'<div style="float:right;padding:2px"><img src="img/closeMod.gif" /></div>'+
'<div id="featuredFeeds" sub="1" style="padding: 5px 2px 0 7px"><div class="itemLineMain"><div class="showSub"></div><div class="text">'+App.Loc.navFeaturedFeeds+'</div></div></div>'+
'</div>';
frame2.innerHTML = (App.mode=='userPage') ? content : contentInFeaturedPageMode;
var closeNode = frame2.firstChild.firstChild;
closeNode.style.cursor = "pointer";
closeNode.onclick = function() {
App.Nav.openCloseSelection();
}
var itms = frame2.firstChild.childNodes;
var items = [];
for (var z=0; z<itms.length; z++) {
if (itms[z].getAttribute("mod") || itms[z].getAttribute("sub")) {
items.push(itms[z]);
}
}
var ln = items.length;
for (var z=0; z<ln; z++) {
var lnk = items[z].getAttribute("sub");
var ico = items[z].getAttribute("ico");
items[z].firstChild.style.cursor = "pointer";
items[z].firstChild.lastChild.style.borderBottom = "1px solid #DDD";
if (ico) {
items[z].firstChild.firstChild.style.backgroundImage = "url("+ico+")";
}
items[z].firstChild.onclick = function() {
if (this.parentNode.getAttribute("sub")) {
if (this.nextSibling && !App.Nav.isFeedsUpdated) {
if (this.nextSibling.style.display=="none") {
this.nextSibling.style.display = "block";
this.firstChild.className = "hideSub";
App.FeedReader.resize();
} else {
this.nextSibling.style.display = "none";
this.firstChild.className = "showSub";
App.FeedReader.resize();
}
} else {
App.Nav.isFeedsUpdated = false;
var span = document.createElement("span");
span.className = "navLoading";
span.innerHTML = App.Loc.loading;
if (this.parentNode.childNodes.length==2) this.parentNode.lastChild.removeNode(true);
this.parentNode.appendChild(span);
switch(this.parentNode.getAttribute("sub")) {
case "0":
var id = User.feedsId;
break;
case "1":
var id = App.Nav.featuredFeedsId;
break;
case "2":
var id = App.Nav.defaultFeedsId;
break;
}
if (id != null) {
Request.sendGET("getUserFeed.php?id="+id, displaySubCat, this);
} else {
span.innerHTML = " "+App.Loc.navNoFeeds;
this.parentNode.appendChild(span);
}
}
} else {
App.Nav.drawModuleBox(this);
var pickupZone = document.getElementById("pickupZone");
pickupZone.style.paddingTop = "2px";
var div = document.createElement("div");
var modName = this.parentNode.getAttribute("mod");
if (modName && modName=="RssReader") {
div.innerHTML = '<div style="float:right; cursor:pointer"><img src="img/closeMod.gif"/></div>'+
'<div style="padding:10px">'+
'<div class="formLabelUp">'+App.Loc.enterFeedURL+' :</div>'+
'<table cellpadding="0" cellspacing="0"><tr>'+
'<td><input type="text" class="inputClean" value="" style="width:180px"/></td>'+
'<td><input type="submit" value="'+App.Loc.add+'" class="buttonClean"/></td>'+
'</tr>'+
'</table>'+
'<div id="addNewFeedCheckMsg" style="color:#900;margin:5px 0 5px 0"></div>'+
'<div style="height:5px"></div>'+
'<div class="formLabelUp">'+App.Loc.orImportOPML+' :</div>'+
'<form method="post" enctype="multipart/form-data" action="uploadOPML.php" target="target_upload">'+
'<table cellpadding="0" cellspacing="0"><tr>'+
'<td><input type="file" name="userfile" class="inputFileClean"/></td>'+
'<td><input type="submit" value="'+App.Loc.importLabel+'" class="buttonClean"/></td>'+
'</tr>'+
'</table>'+
'<input type="hidden" name="MAX_FILE_SIZE" value="500000" />'+
'<input type="hidden" name="userFeedsId" value="'+User.feedsId+'" />'+
'</form>'+
'<iframe name="target_upload" src="" style="width:1px;height:1px;border:0;visibility:hidden;float:right"></iframe>'+
'</div><div style="margin-top:5px"></div>';
div.firstChild.onclick = function() {
App.Nav.removeModuleBox();
}
var inputs = div.getElementsByTagName("input");
var form = div.getElementsByTagName("form")[0];
form.onsubmit = function() {
if (inputs[2].value != '') {
div.lastChild.innerHTML = '<div style="padding:0 0 10px 10px">'+App.Loc.importing+'...</div>';
return true;
}
}
App.uploadDone = function(success, feedsId) {
if (success) {
App.Nav.isFeedsUpdated = true;
User.feedsId = feedsId;
setTimeout(App.Nav.openMyFeeds,1);
App.Nav.removeModuleBox();
} else {
div.lastChild.innerHTML = '<div style="padding:0 0 10px 10px">'+App.Loc.errorImport+'</div>';
}
}
function addFeedResponse(response, feedUrl, id) {
if (response.responseText == '' || response.responseXML.documentElement==null || response.responseXML.documentElement.nodeName=="parsererror") { // si le flux n'est pas valide
document.getElementById("addNewFeedCheckMsg").innerHTML = App.Loc.feedNotValid;
} else {
App.Nav.isFeedsUpdated = true;
setTimeout(App.Nav.openMyFeeds,1);
var defaultDataObj = App.Modules.RssReaderInfos.defaultObj;
var dataObj = new Object();
for (var i in defaultDataObj) dataObj[i] = defaultDataObj[i];
dataObj.data = new Object();
var feed = new Feed(response);
dataObj.title = feed.title;
dataObj.feedUrl = feedUrl;
dataObj.data.feedId = id;
dataObj.container = 2;
dataObj.admin = false;
dataObj.isNew = true;
var mod = new Module(dataObj);
App.moduleList.push(mod);
App.Nav.removeModuleBox();
App.saveUserData('new', mod);
}
}
var inputFeed = inputs[0];
var inputFeedSave = inputs[1];
var self = this;
inputFeedSave.onclick = function() {
if (inputFeed.value != '') {
document.getElementById("addNewFeedCheckMsg").innerHTML = App.Loc.checkFeed;
App.addNewFeed(inputFeed.value, addFeedResponse);
}
}
pickupZone.appendChild(div);
} else {
div.style.paddingBottom = "4px";
div.innerHTML = '<div style="float:right; cursor:pointer"><img src="img/closeMod.gif"/></div>'+
'<div class="addToPage"><span class="addToPageLinkOut">'+App.Loc.add2MyPage+'</span></div>'+
'<div style="clear:both"></div><div></div>';
div.firstChild.onclick = function() {
App.Nav.removeModuleBox();
}
var linkNode = div.firstChild.nextSibling.firstChild;
linkNode.onmouseover = function() {
this.className = "addToPageLinkOver";
}
linkNode.onmouseout = function() {
this.className = "addToPageLinkOut";
}
linkNode.onclick = function() {
var defaultDataObj = div.lastChild.firstChild.dataObj;
var dataObj = new Object();
for (var i in defaultDataObj) dataObj[i] = defaultDataObj[i];
dataObj.data = new Object();
for (var i in defaultDataObj.data) dataObj.data[i] = defaultDataObj.data[i];
dataObj.container = 2;
dataObj.admin = false;
dataObj.isNew = true;
var mod = new Module(dataObj);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -