r7509 - in dumbhippo/trunk/server: src/com/dumbhippo/server/blocks src/com/dumbhippo/server/impl src/com/dumbhippo/server/views src/com/dumbhippo/web/pages web/javascript/dh web/jsp3 web/tags/3 web/tags/gnome
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7509 - in dumbhippo/trunk/server: src/com/dumbhippo/server/blocks src/com/dumbhippo/server/impl src/com/dumbhippo/server/views src/com/dumbhippo/web/pages web/javascript/dh web/jsp3 web/tags/3 web/tags/gnome
- Date: Sun, 21 Sep 2008 23:19:01 -0500 (CDT)
Author: marinaz
Date: 2008-09-21 23:19:00 -0500 (Sun, 21 Sep 2008)
New Revision: 7509
Added:
dumbhippo/trunk/server/web/tags/3/loveEntry.tag
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractExternalThumbnailedPersonBlockHandlerBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractSingleBlockForFeedBlockHandlerBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/views/ExternalAccountView.java
dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AccountPage.java
dumbhippo/trunk/server/web/javascript/dh/account.js
dumbhippo/trunk/server/web/javascript/dh/formtable.js
dumbhippo/trunk/server/web/javascript/dh/love.js
dumbhippo/trunk/server/web/javascript/dh/lovehate.js
dumbhippo/trunk/server/web/jsp3/account.jsp
dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag
dumbhippo/trunk/server/web/tags/gnome/loveEntry.tag
Log:
Allow displaying and editing multiple acounts of the same type on online.gnome.org and mugshot pages.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractExternalThumbnailedPersonBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractExternalThumbnailedPersonBlockHandlerBean.java 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractExternalThumbnailedPersonBlockHandlerBean.java 2008-09-22 04:19:00 UTC (rev 7509)
@@ -77,8 +77,13 @@
// Note that we create the block even if the new account is not loved-and-enabled
if (external.getAccountType() != accountType)
return;
- Block block = stacker.createBlock(getKey(user));
- stacker.stack(block, System.currentTimeMillis(), user, false, StackReason.NEW_BLOCK);
+
+ try {
+ stacker.queryBlock(getKey(user));
+ } catch (NotFoundException e) {
+ Block block = stacker.createBlock(getKey(user));
+ stacker.stack(block, System.currentTimeMillis(), user, false, StackReason.NEW_BLOCK);
+ }
}
public void onExternalAccountLovedAndEnabledMaybeChanged(User user, ExternalAccount external) {
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractSingleBlockForFeedBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractSingleBlockForFeedBlockHandlerBean.java 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractSingleBlockForFeedBlockHandlerBean.java 2008-09-22 04:19:00 UTC (rev 7509)
@@ -94,7 +94,16 @@
// Note that we create the block even if the new account is not loved-and-enabled
if (external.getAccountType() != getAccountType())
return;
- stacker.createBlock(getKey(user));
+
+ try {
+ stacker.queryBlock(getKey(user));
+ } catch (NotFoundException e) {
+ // Make sure we only try to create a block once for all the external accounts of a given type.
+ // Will need to create multiple blocks and change what we use as a key if we decide to support
+ // multiple accounts of the same type per user for Mugshot. The key can probably be externalAccount,
+ // or a combination of user and externalAccount if we want to include the user.
+ stacker.createBlock(getKey(user));
+ }
}
public void onExternalAccountFeedEntry(User user, ExternalAccount external, FeedEntry entry, int entryPosition) {
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java 2008-09-22 04:19:00 UTC (rev 7509)
@@ -118,8 +118,10 @@
if (!em.contains(a))
throw new RuntimeException("detached account in getOrCreateExternalAccount");
+ logger.debug("in createExternalAccount");
ExternalAccount external = new ExternalAccount();
external.setOnlineAccountType(type);
+ external.setAccountType(type.getAccountType()); // it's ok if this is null
external.setAccount(a);
em.persist(external);
a.getExternalAccounts().add(external);
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java 2008-09-22 04:19:00 UTC (rev 7509)
@@ -1614,9 +1614,12 @@
// not Mugshot enabled, so we eed to make sure it's not possible to hate an account type in the UI when
// you have accounts of this type listed.
Set<ExternalAccount> allExternals = externalAccountSystem.lookupExternalAccounts(viewpoint, viewpoint.getViewer(), onlineAccountType);
+ boolean foundOneLovedAccount = false;
for (ExternalAccount external : allExternals) {
- if (external.getSentiment() == Sentiment.LOVE) {
+ if (external.getSentiment() == Sentiment.LOVE && foundOneLovedAccount) {
throw new RuntimeException("Can't allow hating an external account of type " + onlineAccountType + " because other loved accounts of this type exist.");
+ } else if (external.getSentiment() == Sentiment.LOVE) {
+ foundOneLovedAccount = true;
}
}
ExternalAccount external = externalAccountSystem.getOrCreateExternalAccount(viewpoint, onlineAccountType.getAccountType());
@@ -1654,14 +1657,13 @@
private ExternalAccount getOrCreateExternalAccount(UserViewpoint viewpoint, ExternalAccountType externalAccountType, String id) {
OnlineAccountType onlineAccountType = externalAccountSystem.getOnlineAccountType(externalAccountType);
-
ExternalAccount external = null;
if (id == "mugshot") {
// id = "mugshot" means we want to set the value for the mugshot enabled account
external = externalAccountSystem.getOrCreateExternalAccount(viewpoint, externalAccountType);
} else if (id == "") {
try {
- ExternalAccount mugshotEnabledExternal = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), ExternalAccountType.YOUTUBE);
+ ExternalAccount mugshotEnabledExternal = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), externalAccountType);
// we shouldn't allow hating an account type and having some accounts of that type listed, so we just override the value on the
// hated account if one exists
if (mugshotEnabledExternal.getSentiment() == Sentiment.INDIFFERENT || mugshotEnabledExternal.getSentiment() == Sentiment.HATE) {
@@ -1679,7 +1681,6 @@
throw new RuntimeException(e.getMessage());
}
}
-
return external;
}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/views/ExternalAccountView.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/views/ExternalAccountView.java 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/views/ExternalAccountView.java 2008-09-22 04:19:00 UTC (rev 7509)
@@ -19,6 +19,10 @@
private OnlineAccountType onlineAccountType;
private String link;
private Thumbnails thumbnails;
+ private boolean hateAllowed;
+ // this is used when we construct a list of accounts and we want to indicate that there are several accounts
+ // of the same type in a row
+ private boolean newType;
private class ExternalAccountThumbnails extends BasicThumbnails {
ExternalAccountThumbnails(List<? extends Thumbnail> thumbnails, int thumbnailTotalItems, int thumbnailWidth, int thumbnailHeight) {
@@ -37,7 +41,13 @@
}
}
+ private ExternalAccountView() {
+ this.hateAllowed = true;
+ this.newType = true;
+ }
+
public ExternalAccountView(ExternalAccount externalAccount) {
+ this();
this.externalAccount = externalAccount;
this.externalAccountType = externalAccount.getAccountType();
this.onlineAccountType = externalAccount.getOnlineAccountType();
@@ -54,6 +64,7 @@
* @param externalAccountType
*/
public ExternalAccountView(OnlineAccountType onlineAccountType) {
+ this();
this.onlineAccountType = onlineAccountType;
this.externalAccountType = onlineAccountType.getAccountType();
}
@@ -69,7 +80,23 @@
public OnlineAccountType getOnlineAccountType() {
return onlineAccountType;
}
+
+ public void setAllowHate(boolean hateAllowed) {
+ this.hateAllowed = hateAllowed;
+ }
+
+ public boolean isHateAllowed() {
+ return hateAllowed;
+ }
+ public void setNewType(boolean newType) {
+ this.newType = newType;
+ }
+
+ public boolean isNewType() {
+ return newType;
+ }
+
public String getSiteName() {
return onlineAccountType.getSiteName();
}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AccountPage.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AccountPage.java 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AccountPage.java 2008-09-22 04:19:00 UTC (rev 7509)
@@ -127,6 +127,71 @@
}
return external.getHandle();
}
+
+ private List<ExternalAccountView> getAccountsListForType(OnlineAccountType onlineAccountType) {
+ Set<ExternalAccount> externalAccountsSet =
+ externalAccounts.lookupExternalAccounts(signin.getViewpoint(), signin.getUser(), onlineAccountType);
+
+ List<ExternalAccountView> accountsList= new ArrayList<ExternalAccountView>();
+ ExternalAccountView indifferentAccount = null;
+
+ for (ExternalAccount externalAccount : externalAccountsSet) {
+ if (externalAccount.getSentiment() == Sentiment.LOVE) {
+ if (externalAccount.isMugshotEnabled()) {
+ // always list the Mugshot enabled account first
+ accountsList.add(0, new ExternalAccountView(externalAccount));
+ } else {
+ accountsList.add(new ExternalAccountView(externalAccount));
+ }
+ } else if (externalAccount.getSentiment() == Sentiment.HATE) {
+ // if there is a hated account, we want to return it on its own
+ // if you hate this account type, you can't have other accounts of this type that you love or
+ // add new accounts of this type, you can edit the hated account type in place though
+ accountsList.clear();
+ accountsList.add(new ExternalAccountView(externalAccount));
+ return accountsList;
+ } else {
+ // we don't return here because it is possible to have old indifferent accounts,
+ // but also have some loved accounts or one hated account
+ indifferentAccount = new ExternalAccountView(externalAccount);
+ }
+ }
+
+ if (accountsList.size() > 1) {
+ boolean isFirstLovedAccount = true;
+ for (ExternalAccountView lovedAccount : accountsList) {
+ lovedAccount.setAllowHate(false);
+
+ if (!isFirstLovedAccount)
+ lovedAccount.setNewType(false);
+ else
+ isFirstLovedAccount = false;
+ }
+ }
+
+ ExternalAccountView viewForAddingNewAccount = null;
+ // we should only allow the user to edit one indifferent account at a time; since we never delete accounts, this
+ // is a way to allow reusing accounts
+ if (indifferentAccount != null) {
+ viewForAddingNewAccount = indifferentAccount;
+ } else {
+ viewForAddingNewAccount = new ExternalAccountView(onlineAccountType);
+ }
+
+ if (accountsList.size() != 0) {
+ viewForAddingNewAccount.setAllowHate(false);
+ viewForAddingNewAccount.setNewType(false);
+ }
+
+ accountsList.add(viewForAddingNewAccount);
+
+ if (onlineAccountType.getAccountType() != null && onlineAccountType.getAccountType() == ExternalAccountType.FACEBOOK) {
+ // make sure we only list one account for Facebook, because we don't support adding multiple Facebook accounts at the moment
+ return accountsList.subList(0, 1);
+ }
+
+ return accountsList;
+ }
/**
* Returns a list of supported account views; with the ExternalAccount information for the
@@ -141,32 +206,7 @@
for (ExternalAccountType type : ExternalAccountType.alphabetizedValues()) {
if (type.isSupported()) {
OnlineAccountType onlineAccountType = externalAccounts.getOnlineAccountType(type);
-
- Set<ExternalAccount> externalAccountsSet =
- externalAccounts.lookupExternalAccounts(signin.getViewpoint(), signin.getUser(), onlineAccountType);
-
- ExternalAccountView indifferentAccount = null;
- boolean foundLovedOrHatedAccount = false;
- for (ExternalAccount externalAccount : externalAccountsSet) {
- // normally we shouldn't have some accounts that are hated and some that are loved of the same time,
- // but we don't have to check for it here
- if (externalAccount.getSentiment() == Sentiment.LOVE || externalAccount.getSentiment() == Sentiment.HATE) {
- supportedAccounts.add(new ExternalAccountView(externalAccount));
- foundLovedOrHatedAccount = true;
- } else {
- indifferentAccount = new ExternalAccountView(externalAccount);
- }
- }
-
- // we should only allow the user to edit one indifferent account at a time; since we never delete accounts, this
- // is a way to allow reusing accounts
- if (!foundLovedOrHatedAccount && indifferentAccount != null) {
- supportedAccounts.add(indifferentAccount);
- }
-
- if (externalAccountsSet.isEmpty()) {
- supportedAccounts.add(new ExternalAccountView(onlineAccountType));
- }
+ supportedAccounts.addAll(getAccountsListForType(onlineAccountType));
}
}
@@ -186,31 +226,7 @@
for (OnlineAccountType type : alphabetizedTypes) {
if (type.isSupported()) {
- Set<ExternalAccount> externalAccountsSet =
- externalAccounts.lookupExternalAccounts(signin.getViewpoint(), signin.getUser(), type);
-
- ExternalAccountView indifferentAccount = null;
- boolean foundLovedOrHatedAccount = false;
- for (ExternalAccount externalAccount : externalAccountsSet) {
- // normally we shouldn't have some accounts that are hated and some that are loved of the same time,
- // but we don't have to check for it here
- if (externalAccount.getSentiment() == Sentiment.LOVE || externalAccount.getSentiment() == Sentiment.HATE) {
- supportedAccounts.add(new ExternalAccountView(externalAccount));
- foundLovedOrHatedAccount = true;
- } else {
- indifferentAccount = new ExternalAccountView(externalAccount);
- }
- }
-
- // we should only allow the user to edit one indifferent account at a time; since we never delete accounts, this
- // is a way to allow reusing accounts
- if (!foundLovedOrHatedAccount && indifferentAccount != null) {
- supportedAccounts.add(indifferentAccount);
- }
-
- if (externalAccountsSet.isEmpty()) {
- supportedAccounts.add(new ExternalAccountView(type));
- }
+ supportedAccounts.addAll(getAccountsListForType(type));
}
}
Modified: dumbhippo/trunk/server/web/javascript/dh/account.js
===================================================================
--- dumbhippo/trunk/server/web/javascript/dh/account.js 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/javascript/dh/account.js 2008-09-22 04:19:00 UTC (rev 7509)
@@ -368,15 +368,17 @@
entry.setBusy();
dh.account.hateExternalAccount(accountType, value,
function(childNodes, http) {
- entry.setMode('hate');
- if (mugshotEnabled && accountType == 'AMAZON') {
- var amazonDetailsNodes = dh.html.getElementsByClass('dh-amazon-details');
- var i = 0;
- for (i = 0; i < amazonDetailsNodes.length; ++i) {
- var amazonDetailsNode = amazonDetailsNodes[i];
- dh.dom.removeChildren(amazonDetailsNode);
- }
- }
+ // if we leave entry mode as "busy" we get weird problems with css styling,
+ // so we set it to the new mode in all cases
+ entry.setMode('hate');
+ if (entry.getInitialMode() == "love") {
+ // There is also no need to reload if the account was already hated
+ // or the user was indifferent to it because we don't allow adding more accounts
+ // if you hate one of the type.
+ // But if you hate an account that you used to love, we want to make sure you are not
+ // able to add other accounts of this type, so we need to refresh.
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -391,19 +393,14 @@
entry.setBusy();
dh.account.removeExternalAccount(id,
function(childNodes, http) {
- entry.setMode('indifferent');
- if (mugshotEnabled && accountType == 'amazon') {
- var amazonDetailsNodes = dh.html.getElementsByClass('dh-amazon-details');
- var i = 0;
- for (i = 0; i < amazonDetailsNodes.length; ++i) {
- var amazonDetailsNode = amazonDetailsNodes[i];
- dh.dom.removeChildren(amazonDetailsNode);
- }
- }
+ entry.setMode('indifferent');
+ if (entry.getInitialMode() == "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
- alert(msg);
- entry.setMode(oldMode);
+ alert(msg);
+ entry.setMode(oldMode);
});
}
}
@@ -433,7 +430,10 @@
dh.account.setFlickrAccount(id, nsid, value,
function(childNodes, http) {
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -463,7 +463,10 @@
break;
}
}
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -476,7 +479,10 @@
entry.setBusy();
dh.account.setYouTubeName(id, value,
function(childNodes, http) {
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -489,11 +495,13 @@
entry.setBusy();
dh.account.setLastFmName(id, value,
function(childNodes, http) {
- entry.setError(null);
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
- entry.setError(msg);
+ alert(msg); // entry.setError(msg);
entry.setMode(oldMode);
});
}
@@ -503,19 +511,22 @@
entry.setBusy();
dh.account.setLinkedInProfile(id, value,
function(childNodes, http) {
- var username = null;
- var i = 0;
- for (i = 0; i < childNodes.length; ++i) {
- var child = childNodes.item(i);
- if (child.nodeType != dh.dom.ELEMENT_NODE)
- continue;
+ var username = null;
+ var i = 0;
+ for (i = 0; i < childNodes.length; ++i) {
+ var child = childNodes.item(i);
+ if (child.nodeType != dh.dom.ELEMENT_NODE)
+ continue;
- if (child.nodeName == "username") {
- username = dh.dom.textContent(child);
- }
- }
- entry.setLoveValueAlreadySaved(username);
- entry.setMode('love');
+ if (child.nodeName == "username") {
+ username = dh.dom.textContent(child);
+ }
+ }
+ entry.setLoveValueAlreadySaved(username);
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -528,7 +539,10 @@
entry.setBusy();
dh.account.setRhapsodyUrl(id, value,
function(childNodes, http) {
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -541,19 +555,22 @@
entry.setBusy();
dh.account.setDeliciousName(id, value,
function(childNodes, http) {
- var username = null;
- var i = 0;
- for (i = 0; i < childNodes.length; ++i) {
- var child = childNodes.item(i);
- if (child.nodeType != dh.dom.ELEMENT_NODE)
- continue;
+ var username = null;
+ var i = 0;
+ for (i = 0; i < childNodes.length; ++i) {
+ var child = childNodes.item(i);
+ if (child.nodeType != dh.dom.ELEMENT_NODE)
+ continue;
- if (child.nodeName == "username") {
- username = dh.dom.textContent(child);
- }
- }
- entry.setLoveValueAlreadySaved(username);
- entry.setMode('love');
+ if (child.nodeName == "username") {
+ username = dh.dom.textContent(child);
+ }
+ }
+ entry.setLoveValueAlreadySaved(username);
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -582,8 +599,11 @@
alert(msg);
}
}
- entry.setLoveValueAlreadySaved(username);
- entry.setMode('love');
+ entry.setLoveValueAlreadySaved(username);
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -596,19 +616,22 @@
entry.setBusy();
dh.account.setDiggName(id, value,
function(childNodes, http) {
- var username = null;
- var i = 0;
- for (i = 0; i < childNodes.length; ++i) {
- var child = childNodes.item(i);
- if (child.nodeType != dh.dom.ELEMENT_NODE)
- continue;
+ var username = null;
+ var i = 0;
+ for (i = 0; i < childNodes.length; ++i) {
+ var child = childNodes.item(i);
+ if (child.nodeType != dh.dom.ELEMENT_NODE)
+ continue;
- if (child.nodeName == "username") {
- username = dh.dom.textContent(child);
- }
- }
- entry.setLoveValueAlreadySaved(username);
- entry.setMode('love');
+ if (child.nodeName == "username") {
+ username = dh.dom.textContent(child);
+ }
+ }
+ entry.setLoveValueAlreadySaved(username);
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -637,8 +660,11 @@
alert(msg);
}
}
- entry.setLoveValueAlreadySaved(username);
- entry.setMode('love');
+ entry.setLoveValueAlreadySaved(username);
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -651,7 +677,10 @@
entry.setBusy();
dh.account.setNetflixUrl(id, value,
function(childNodes, http) {
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -664,7 +693,10 @@
entry.setBusy();
dh.account.setGoogleReaderUrl(id, value,
function(childNodes, http) {
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -677,19 +709,22 @@
entry.setBusy();
dh.account.setPicasaName(id, value,
function(childNodes, http) {
- var username = null;
- var i = 0;
- for (i = 0; i < childNodes.length; ++i) {
- var child = childNodes.item(i);
- if (child.nodeType != dh.dom.ELEMENT_NODE)
- continue;
+ var username = null;
+ var i = 0;
+ for (i = 0; i < childNodes.length; ++i) {
+ var child = childNodes.item(i);
+ if (child.nodeType != dh.dom.ELEMENT_NODE)
+ continue;
- if (child.nodeName == "username") {
- username = dh.dom.textContent(child);
- }
- }
- entry.setLoveValueAlreadySaved(username);
- entry.setMode('love');
+ if (child.nodeName == "username") {
+ username = dh.dom.textContent(child);
+ }
+ }
+ entry.setLoveValueAlreadySaved(username);
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -751,6 +786,10 @@
break;
}
}
+
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -763,7 +802,10 @@
entry.setBusy();
dh.account.setOnlineAccountValue(type, id, value,
function(childNodes, http) {
- entry.setMode('love');
+ entry.setMode('love');
+ if (entry.getInitialMode() != "love") {
+ dh.util.refresh();
+ }
},
function(code, msg, http) {
alert(msg);
@@ -857,17 +899,24 @@
if (dh.account.dhMugshotEnabledFlags != null) {
for (var i = 0; i < dh.account.dhNames.length; ++i) {
if (dh.account.dhNames[i] == "facebook")
- continue;
-
- var onlineAccountEntry = new dh.lovehate.Entry('dh' + dh.account.dhDomIds[i], dh.account.dhUserInfoTypes[i], dh.account.dhValues[i],
+ continue;
+
+ var onlineAccountEntry = null;
+
+ if (dh.account.dhHateAllowedFlags[i]) {
+ onlineAccountEntry = new dh.lovehate.Entry('dh' + dh.account.dhDomIds[i], dh.account.dhUserInfoTypes[i], dh.account.dhValues[i],
dh.account.hateQuipsArray[dh.account.dhNames[i]], dh.account.dhHateQuips[i], dh.account.whatWillHappenArray[dh.account.dhNames[i]],
dh.account.helpLinkArray[dh.account.dhNames[i]]);
-
+ onlineAccountEntry.onHateSaved = dh.account.createExternalAccountOnHateSavedFunc(onlineAccountEntry, dh.account.dhNames[i], dh.account.dhIds[i], dh.account.dhMugshotEnabledFlags[i]);
+ } else {
+ onlineAccountEntry = new dh.love.Entry('dh' + dh.account.dhDomIds[i], dh.account.dhUserInfoTypes[i], dh.account.dhValues[i],
+ dh.account.whatWillHappenArray[dh.account.dhNames[i]], dh.account.helpLinkArray[dh.account.dhNames[i]]);
+ }
+
if (dh.account.specialLoveValuesArray[dh.account.dhNames[i]] != null)
onlineAccountEntry.setSpecialLoveValue(dh.account.specialLoveValuesArray[dh.account.dhNames[i]]);
onlineAccountEntry.onLoveSaved = dh.account.createExternalAccountOnLoveSavedFunc(onlineAccountEntry, dh.account.dhNames[i], dh.account.dhIds[i], dh.account.dhMugshotEnabledFlags[i]);
- onlineAccountEntry.onHateSaved = dh.account.createExternalAccountOnHateSavedFunc(onlineAccountEntry, dh.account.dhNames[i], dh.account.dhIds[i], dh.account.dhMugshotEnabledFlags[i]);
onlineAccountEntry.onCanceled = dh.account.createExternalAccountOnCanceledFunc(onlineAccountEntry, dh.account.dhNames[i], dh.account.dhIds[i], dh.account.dhMugshotEnabledFlags[i]);
dh.account.onlineAccountEntries.push(onlineAccountEntry)
}
Modified: dumbhippo/trunk/server/web/javascript/dh/formtable.js
===================================================================
--- dumbhippo/trunk/server/web/javascript/dh/formtable.js 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/javascript/dh/formtable.js 2008-09-22 04:19:00 UTC (rev 7509)
@@ -123,18 +123,23 @@
}
dh.formtable.setExpandedError = function(controlId, active) {
+ var container = document.getElementById(controlId + "FormContainer");
var label = document.getElementById(controlId + "FormLabel");
var content = document.getElementById(controlId + "FormContent");
if (active) {
- dh.util.removeClass(label.parentNode, "dh-account-editing-box-success");
dh.util.removeClass(content.parentNode, "dh-account-editing-box-success");
- dh.util.prependClass(label.parentNode, "dh-account-editing-box-error");
dh.util.prependClass(content.parentNode, "dh-account-editing-box-error");
+ if (container.dhExpandedLabel) {
+ dh.util.removeClass(label.parentNode, "dh-account-editing-box-success");
+ dh.util.prependClass(label.parentNode, "dh-account-editing-box-error");
+ }
} else {
- dh.util.removeClass(label.parentNode, "dh-account-editing-box-error");
- dh.util.removeClass(content.parentNode, "dh-account-editing-box-error");
- dh.util.prependClass(label.parentNode, "dh-account-editing-box-success");
- dh.util.prependClass(content.parentNode, "dh-account-editing-box-success");
+ dh.util.removeClass(content.parentNode, "dh-account-editing-box-error");
+ dh.util.prependClass(content.parentNode, "dh-account-editing-box-success");
+ if (container.dhExpandedLabel) {
+ dh.util.removeClass(label.parentNode, "dh-account-editing-box-error");
+ dh.util.prependClass(label.parentNode, "dh-account-editing-box-success");
+ }
}
}
Modified: dumbhippo/trunk/server/web/javascript/dh/love.js
===================================================================
--- dumbhippo/trunk/server/web/javascript/dh/love.js 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/javascript/dh/love.js 2008-09-22 04:19:00 UTC (rev 7509)
@@ -7,7 +7,7 @@
dh.love.allEntries = {}
-dh.love.Entry = function(baseId, defaultLoveText, currentLoveValue)
+dh.love.Entry = function(baseId, defaultLoveText, currentLoveValue, loveTip, accountHelp)
{
dh.love.allEntries[baseId] = this;
@@ -22,6 +22,7 @@
this._busyNode = document.getElementById(baseId + 'BusyId');
this._loveEntryNode = document.getElementById(baseId + 'LoveEntryId');
+ // alert("searched for " + baseId + "LoveEntryId" + " found " + this._loveEntryNode);
this._defaultLoveText = defaultLoveText;
@@ -33,8 +34,9 @@
this._allNodes = [me._loveNode, me._loveEditNode, me._indifferentNode, me._busyNode];
this._errorText = "";
+ this._initialMode = "";
- dh.formtable.initExpanded(me._baseId, true);
+ dh.formtable.initExpanded(me._baseId, false);
// Traverse root node of this widget, calling function on each node
this._foreachDhIdNode = function(id, func) {
@@ -44,6 +46,24 @@
});
}
+ if (loveTip)
+ this._foreachDhIdNode("LoveTipId", function (node) { node.appendChild(document.createTextNode(loveTip)); });
+
+ if (accountHelp)
+ this._foreachDhIdNode("AccountHelpId",
+ function(node) {
+ var span = document.createElement("span");
+ span.appendChild(document.createTextNode(" ("));
+ var a = document.createElement("a");
+ a.setAttribute("target", "_blank");
+ a.setAttribute("href", accountHelp);
+ dh.util.prependClass(a, "dh-text-input-help");
+ a.appendChild(document.createTextNode("help me find it"));
+ span.appendChild(a);
+ span.appendChild(document.createTextNode(")"));
+ node.appendChild(span);
+ });
+
this._loveEntryNode.onkeydown = function(ev) {
var key = dh.event.getKeyCode(ev);
if (key == ENTER) {
@@ -113,6 +133,7 @@
me.setMode('busy');
}
+ // this is currently not enabled for loveEntry
this.setError = function(msg) {
if (msg) {
me._foreachDhIdNode("DescriptionError",
@@ -179,6 +200,12 @@
this.setError(null);
this.setMode(this.getMode());
+ this._initialMode = this.getMode();
+
+ this.getInitialMode = function() {
+ return this._initialMode;
+ }
+
return this;
}
Modified: dumbhippo/trunk/server/web/javascript/dh/lovehate.js
===================================================================
--- dumbhippo/trunk/server/web/javascript/dh/lovehate.js 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/javascript/dh/lovehate.js 2008-09-22 04:19:00 UTC (rev 7509)
@@ -26,6 +26,9 @@
this._loveEntryNode = document.getElementById(baseId + 'LoveEntryId');
this._hateEntryNode = document.getElementById(baseId + 'HateEntryId');
+
+ // alert("searched for " + baseId + "LoveEntryId" + " found " + this._loveEntryNode);
+ // alert("searched for " + baseId + "HateEntryId" + " found " + this._hateEntryNode);
this._defaultLoveText = defaultLoveText;
this._defaultHateText = defaultHateText;
@@ -40,8 +43,9 @@
this._allNodes = [me._loveNode, me._hateNode, me._loveEditNode, me._hateEditNode, me._indifferentNode, me._indifferentInfoNode, me._busyNode];
this._errorText = "";
+ this._initialMode = "";
- dh.formtable.initExpanded(me._baseId, true);
+ dh.formtable.initExpanded(me._baseId, false);
// Traverse root node of this widget, calling function on each node
this._foreachDhIdNode = function(id, func) {
@@ -236,6 +240,12 @@
this.setError(null);
this.setMode(this.getMode());
+ this._initialMode = this.getMode();
+
+ this.getInitialMode = function() {
+ return this._initialMode;
+ }
+
return this;
}
Modified: dumbhippo/trunk/server/web/jsp3/account.jsp
===================================================================
--- dumbhippo/trunk/server/web/jsp3/account.jsp 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/jsp3/account.jsp 2008-09-22 04:19:00 UTC (rev 7509)
@@ -34,7 +34,8 @@
dh.account.dhHateQuips = [ <c:forEach items="${account.supportedAccounts.list}" var="supportedAccount" varStatus="status"><dh:jsString value="${supportedAccount.hateQuip}"/> ${status.last ? '];' : ','}</c:forEach>
dh.account.dhIds = [ <c:forEach items="${account.supportedAccounts.list}" var="supportedAccount" varStatus="status"><dh:jsString value="${supportedAccount.id}"/> ${status.last ? '];' : ','}</c:forEach>
dh.account.dhDomIds = [ <c:forEach items="${account.supportedAccounts.list}" var="supportedAccount" varStatus="status"><dh:jsString value="${supportedAccount.domNodeIdName}"/> ${status.last ? '];' : ','}</c:forEach>
- dh.account.dhMugshotEnabledFlags = [ <c:forEach items="${account.supportedAccounts.list}" var="supportedAccount" varStatus="status"><dh:jsString value="${supportedAccount.mugshotEnabled}"/> ${status.last ? '];' : ','}</c:forEach>
+ dh.account.dhMugshotEnabledFlags = [ <c:forEach items="${account.supportedAccounts.list}" var="supportedAccount" varStatus="status">${supportedAccount.mugshotEnabled} ${status.last ? '];' : ','}</c:forEach>
+ dh.account.dhHateAllowedFlags = [ <c:forEach items="${account.supportedAccounts.list}" var="supportedAccount" varStatus="status">${supportedAccount.hateAllowed} ${status.last ? '];' : ','}</c:forEach>
</script>
<head>
Modified: dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag 2008-09-22 04:19:00 UTC (rev 7509)
@@ -130,8 +130,13 @@
</dht2:formTableRow>
<c:if test="${dh:enumIs(site, 'GNOME')}">
<c:forEach items="${account.gnomeSupportedAccounts.list}" var="supportedAccount">
+ <%-- icon is only used when label is set, otherwise we'd also have to set it to "" here --%>
+ <c:set var="label" value=""/>
+ <c:if test="${supportedAccount.newType}">
+ <c:set var="label" value="${supportedAccount.siteName}"/>
+ </c:if>
<dht2:formTableRow controlId="dh${supportedAccount.domNodeIdName}"
- label="${supportedAccount.siteName}"
+ label="${label}"
icon="/images3/${buildStamp}/${supportedAccount.iconName}">
<gnome:loveEntry name="${supportedAccount.siteName}"
userInfoType="${supportedAccount.userInfoType}"
@@ -181,13 +186,17 @@
<c:set var="prefixIcon" value="" />
<c:set var="prefixIconWidth" value="" />
<c:set var="prefixIconHeight" value="" />
- <c:if test="${supportedAccount.externalAccountType.new}">
+ <c:if test="${supportedAccount.externalAccountType.new && supportedAccount.newType}">
<c:set var="prefixIcon" value="/images3/${buildStamp}/new_icon.png" />
<c:set var="prefixIconWidth" value="31" />
<c:set var="prefixIconHeight" value="10" />
- </c:if>
+ </c:if>
+ <c:set var="label" value=""/>
+ <c:if test="${supportedAccount.newType}">
+ <c:set var="label" value="${supportedAccount.siteName}"/>
+ </c:if>
<dht2:formTableRow controlId="dh${supportedAccount.domNodeIdName}"
- label="${supportedAccount.siteName}"
+ label="${label}"
icon="/images3/${buildStamp}/${supportedAccount.iconName}"
info="${facebookAppInfo}"
infoLink ="${facebookAppInfoLink}"
@@ -209,23 +218,36 @@
<c:otherwise>
<%-- it's ok to assume that supportedAccount.externalAccountType is not null here --%>
<%-- because the list of supported accounts for Mugshot is generated based on the ExternalAccountType enumeration --%>
- <dht2:loveHateEntry name="${supportedAccount.siteName}"
- userInfoType="${supportedAccount.externalAccountType.siteUserInfoType}"
- isInfoTypeProvidedBySite="${supportedAccount.externalAccountType.infoTypeProvidedBySite}"
- link="${supportedAccount.externalAccountType.siteLink}"
- baseId="dh${supportedAccount.domNodeIdName}"
- mode="${supportedAccount.sentiment}">
+ <c:choose>
+ <c:when test="${supportedAccount.hateAllowed}">
+ <dht2:loveHateEntry name="${supportedAccount.siteName}"
+ userInfoType="${supportedAccount.externalAccountType.siteUserInfoType}"
+ isInfoTypeProvidedBySite="${supportedAccount.externalAccountType.infoTypeProvidedBySite}"
+ link="${supportedAccount.externalAccountType.siteLink}"
+ baseId="dh${supportedAccount.domNodeIdName}"
+ mode="${supportedAccount.sentiment}">
- <c:if test="${supportedAccount.siteName == 'Amazon'}">
- <div class="dh-amazon-details">
- <c:forEach items="${account.amazonLinks}" var="amazonLinkPair">
- <div>
- <a href="${amazonLinkPair.second}">${amazonLinkPair.first}</a>
- </div>
- </c:forEach>
- </div>
- </c:if>
- </dht2:loveHateEntry>
+ <c:if test="${supportedAccount.siteName == 'Amazon' && supportedAccount.mugshotEnabled}">
+ <div class="dh-amazon-details">
+ <c:forEach items="${account.amazonLinks}" var="amazonLinkPair">
+ <div>
+ <a href="${amazonLinkPair.second}">${amazonLinkPair.first}</a>
+ </div>
+ </c:forEach>
+ </div>
+ </c:if>
+ </dht2:loveHateEntry>
+ </c:when>
+ <c:otherwise>
+ <dht3:loveEntry name="${supportedAccount.siteName}"
+ userInfoType="${supportedAccount.externalAccountType.siteUserInfoType}"
+ isInfoTypeProvidedBySite="${supportedAccount.externalAccountType.infoTypeProvidedBySite}"
+ link="${supportedAccount.externalAccountType.siteLink}"
+ baseId="dh${supportedAccount.domNodeIdName}"
+ mode="${supportedAccount.sentiment}">
+ </dht3:loveEntry>
+ </c:otherwise>
+ </c:choose>
</c:otherwise>
</c:choose>
</dht2:formTableRow>
Added: dumbhippo/trunk/server/web/tags/3/loveEntry.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/3/loveEntry.tag 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/tags/3/loveEntry.tag 2008-09-22 04:19:00 UTC (rev 7509)
@@ -0,0 +1,74 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/jsp/dumbhippo.tld" prefix="dh" %>
+<%@ taglib tagdir="/WEB-INF/tags/2" prefix="dht" %>
+
+<%@ attribute name="name" required="true" type="java.lang.String" %>
+<%@ attribute name="userInfoType" required="true" type="java.lang.String" %>
+<%@ attribute name="isInfoTypeProvidedBySite" required="true" type="java.lang.Boolean" %>
+<%@ attribute name="link" required="true" type="java.lang.String" %>
+<%@ attribute name="baseId" required="true" type="java.lang.String" %>
+<%@ attribute name="mode" required="true" type="java.lang.String" %>
+
+<%-- the Javascript manages this visibility also, but we want to get it right on page load --%>
+<c:choose>
+ <c:when test="${mode == 'love'}">
+ <c:set var="loveDisplay" value="block" scope="page"/>
+ <c:set var="indifferentDisplay" value="none" scope="page"/>
+ </c:when>
+ <c:when test="${mode == 'hate' || mode == 'indifferent'}">
+ <c:set var="loveDisplay" value="none" scope="page"/>
+ <c:set var="indifferentDisplay" value="block" scope="page"/>
+ </c:when>
+ <c:otherwise>
+ <dht:errorPage>Internal error (mode = ${mode}), sorry!</dht:errorPage>
+ </c:otherwise>
+</c:choose>
+
+<div id="${baseId}AllId" class="dh-love-hate">
+ <div id="${baseId}LoveId" style="display: ${loveDisplay};">
+ <a href="javascript:dh.love.setMode('${baseId}', 'loveEdit')" title="Click to change">
+ <dh:png klass="dh-love-hate-icon" src="/images3/${buildStamp}/quiplove_icon.png" style="width: 12; height: 11; overflow: hidden;"/>
+ <span id="${baseId}LoveValueId"></span>
+ </a>
+ </div>
+ <div id="${baseId}IndifferentId" style="display: ${indifferentDisplay};">
+ <a href="javascript:dh.love.setMode('${baseId}', 'loveEdit')" title="Add another account"><dh:png klass="dh-add-icon" src="/images3/${buildStamp}/quiplove_icon.png" style="width: 12; height: 11; overflow: hidden;"/>Add another account</a>
+ </div>
+ <div id="${baseId}LoveEditId" style="display: none;">
+ <dh:png klass="dh-love-hate-icon" src="/images3/${buildStamp}/quiplove_icon.png" style="width: 12; height: 11; overflow: hidden;"/>
+ <dht:textInput id="${baseId}LoveEntryId" maxlength="255"/>
+ <img src="/images3/${buildStamp}/save_button.gif" onclick="dh.love.saveClicked('${baseId}', 'love')"/>
+ <a href="javascript:dh.love.cancelClicked('${baseId}')" title="Remove the account"><img src="/images3/${buildStamp}/x_button.gif"/></a>
+ <div dhId="DescriptionNormal">
+ <div class="dh-love-hate-instruction-editing">
+ Editing <c:out value="${name}"/>.<br/>
+ </div>
+ <a style="font-weight: bold;" href="javascript:dh.lovehate.setMode('${baseId}', 'loveEdit')" title="Click to change">
+ <dh:png src="/images3/${buildStamp}/quiplove_icon.png" style="width: 12; height: 11; overflow: hidden;"/> Love it
+ </a>: Enter your
+ <c:choose>
+ <c:when test="${isInfoTypeProvidedBySite}">
+ <jsp:element name="a">
+ <jsp:attribute name="href"><c:out value="${link}"/></jsp:attribute>
+ <jsp:attribute name="target">_blank</jsp:attribute>
+ <jsp:body><c:out value="${name}"/></jsp:body>
+ </jsp:element> <c:out value="${userInfoType}"/><span dhId="AccountHelpId"></span>.
+ </c:when>
+ <c:otherwise>
+ <c:out value="${userInfoType}"/>
+ <jsp:element name="a">
+ <jsp:attribute name="href"><c:out value="${link}"/></jsp:attribute>
+ <jsp:attribute name="target">_blank</jsp:attribute>
+ <jsp:body><c:out value="${name}"/></jsp:body>
+ </jsp:element>
+ account<span dhId="AccountHelpId"></span>.
+ </c:otherwise>
+ </c:choose>
+ <%-- We use dhId because this tag is used in multiple places. Not sure if this is currently used. --%>
+ <span dhId="LoveTipId"></span>
+ </div>
+ </div>
+ <div id="${baseId}BusyId" style="display: none;">
+ <img src="/images2/${buildStamp}/feedspinner.gif"/> Please wait...
+ </div>
+</div>
\ No newline at end of file
Modified: dumbhippo/trunk/server/web/tags/gnome/loveEntry.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/gnome/loveEntry.tag 2008-09-20 00:31:07 UTC (rev 7508)
+++ dumbhippo/trunk/server/web/tags/gnome/loveEntry.tag 2008-09-22 04:19:00 UTC (rev 7509)
@@ -42,9 +42,8 @@
<jsp:element name="a">
<jsp:attribute name="href"><c:out value="${link}"/></jsp:attribute>
<jsp:attribute name="target">_blank</jsp:attribute>
- <jsp:body><c:out value="${name}"/></jsp:body>
- </jsp:element>
- <c:out value="${userInfoType}"/>
+ <jsp:body><c:out value="${userInfoType}"/></jsp:body>
+ </jsp:element>.
</div>
</div>
<div id="${baseId}BusyId" style="display: none;">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]