Skip to content

Commit

Permalink
* remove unused variable
Browse files Browse the repository at this point in the history
* Fix: empty input values don't deleting values in doc
  • Loading branch information
Thomas Mohaupt committed Dec 22, 2009
1 parent 9989885 commit 3e71590
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 6 additions & 7 deletions templates/vendor/couchapp/_attachments/jquery.couchapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,20 @@
// turn the form into deep json
// field names like 'author-email' get turned into json like
// {"author":{"email":"quentin@example.com"}}
// Note: Fields not found in form are ignored.
function formToDeepJSON(form, fields, doc) {
var form = $(form);
opts.fields.forEach(function(field) {
var val = form.find("[name="+field+"]").val()
if (!val) return;
fields.forEach(function(field) {
var elem = form.find("[name="+field+"]");
if (!elem) return;
var parts = field.split('-');
var frontObj = doc, frontName = parts.shift();
while (parts.length > 0) {
frontObj[frontName] = frontObj[frontName] || {}
frontObj = frontObj[frontName];
frontName = parts.shift();
}
frontObj[frontName] = val;
frontObj[frontName] = elem.val();
});
};

Expand All @@ -94,7 +95,7 @@
// fills in forms
opts.fields.forEach(function(field) {
var parts = field.split('-');
var run = true, frontObj = doc, frontName = parts.shift();
var frontObj = doc, frontName = parts.shift();
while (frontObj && parts.length > 0) {
frontObj = frontObj[frontName];
frontName = parts.shift();
Expand Down Expand Up @@ -136,8 +137,6 @@
diff = (((new Date()).getTime() - date.getTime()) / 1000),
day_diff = Math.floor(diff / 86400);

// if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ) return;

return day_diff < 1 && (
diff < 60 && "just now" ||
diff < 120 && "1 minute ago" ||
Expand Down
11 changes: 5 additions & 6 deletions vendor/_attachments/jquery.couchapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,20 @@
// turn the form into deep json
// field names like 'author-email' get turned into json like
// {"author":{"email":"quentin@example.com"}}
// Note: Fields not found in form are ignored.
function formToDeepJSON(form, fields, doc) {
var form = $(form);
fields.forEach(function(field) {
var val = form.find("[name="+field+"]").val()
if (!val) return;
var elem = form.find("[name="+field+"]");
if (!elem) return;
var parts = field.split('-');
var frontObj = doc, frontName = parts.shift();
while (parts.length > 0) {
frontObj[frontName] = frontObj[frontName] || {}
frontObj = frontObj[frontName];
frontName = parts.shift();
}
frontObj[frontName] = val;
frontObj[frontName] = elem.val();
});
};

Expand All @@ -94,7 +95,7 @@
// fills in forms
opts.fields.forEach(function(field) {
var parts = field.split('-');
var run = true, frontObj = doc, frontName = parts.shift();
var frontObj = doc, frontName = parts.shift();
while (frontObj && parts.length > 0) {
frontObj = frontObj[frontName];
frontName = parts.shift();
Expand Down Expand Up @@ -136,8 +137,6 @@
diff = (((new Date()).getTime() - date.getTime()) / 1000),
day_diff = Math.floor(diff / 86400);

// if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ) return;

return day_diff < 1 && (
diff < 60 && "just now" ||
diff < 120 && "1 minute ago" ||
Expand Down

0 comments on commit 3e71590

Please sign in to comment.