Variable cleanups and formatting

This commit is contained in:
Bryan Housel
2018-01-04 16:13:13 -05:00
parent 954227be53
commit 8914d1ce36
3 changed files with 65 additions and 65 deletions
+26 -26
View File
@@ -16,9 +16,9 @@ import { utilDetect } from '../util/detect';
import { utilRebind } from '../util';
var changeset;
var _changeset;
var readOnlyTags = [
/^changesets_count$/,
/^_changesets_count$/,
/^created_by$/,
/^ideditor:/,
/^imagery_used$/,
@@ -32,9 +32,9 @@ var hashtagRegex = /(#[^\u2000-\u206F\u2E00-\u2E7F\s\\'!"#$%()*,.\/:;<=>?@\[\]^`
export function uiCommit(context) {
var dispatch = d3_dispatch('cancel', 'save'),
userDetails,
_selection;
var dispatch = d3_dispatch('cancel', 'save');
var _userDetails;
var _selection;
var changesetEditor = uiChangesetEditor(context)
.on('change', changeTags);
@@ -51,16 +51,16 @@ export function uiCommit(context) {
if (!osm) return;
// expire stored comment and hashtags after cutoff datetime - #3947
var commentDate = +context.storage('commentDate') || 0,
currDate = Date.now(),
cutoff = 2 * 86400 * 1000; // 2 days
var commentDate = +context.storage('commentDate') || 0;
var currDate = Date.now();
var cutoff = 2 * 86400 * 1000; // 2 days
if (commentDate > currDate || currDate - commentDate > cutoff) {
context.storage('comment', null);
context.storage('hashtags', null);
}
var tags;
if (!changeset) {
if (!_changeset) {
var detected = utilDetect();
tags = {
comment: context.storage('comment') || '',
@@ -78,12 +78,12 @@ export function uiCommit(context) {
tags.hashtags = hashtags;
}
changeset = new osmChangeset({ tags: tags });
_changeset = new osmChangeset({ tags: tags });
}
tags = _clone(changeset.tags);
tags = _clone(_changeset.tags);
tags.imagery_used = context.history().imageryUsed().join(';').substr(0, 255);
changeset = changeset.update({ tags: tags });
_changeset = _changeset.update({ tags: tags });
var header = selection.selectAll('.header')
.data([0]);
@@ -114,7 +114,7 @@ export function uiCommit(context) {
changesetSection
.call(changesetEditor
.changesetID(changeset.id)
.changesetID(_changeset.id)
.tags(tags)
);
@@ -146,7 +146,7 @@ export function uiCommit(context) {
var userLink = d3_select(document.createElement('div'));
userDetails = user;
_userDetails = user;
if (user.image_url) {
userLink
@@ -195,7 +195,7 @@ export function uiCommit(context) {
.merge(requestReviewEnter);
var requestReviewInput = requestReview.selectAll('input')
.property('checked', isReviewRequested(changeset.tags))
.property('checked', isReviewRequested(_changeset.tags))
.on('change', toggleRequestReview);
@@ -238,7 +238,7 @@ export function uiCommit(context) {
return (n && n.value.length) ? null : true;
})
.on('click.save', function() {
dispatch.call('save', this, changeset);
dispatch.call('save', this, _changeset);
});
@@ -256,7 +256,7 @@ export function uiCommit(context) {
.call(rawTagEditor
.expanded(expanded)
.readOnlyTags(readOnlyTags)
.tags(_clone(changeset.tags))
.tags(_clone(_changeset.tags))
);
@@ -273,7 +273,7 @@ export function uiCommit(context) {
.call(rawTagEditor
.expanded(expanded)
.readOnlyTags(readOnlyTags)
.tags(_clone(changeset.tags))
.tags(_clone(_changeset.tags))
);
}
}
@@ -299,8 +299,8 @@ export function uiCommit(context) {
function findHashtags(tags, commentOnly) {
var inComment = commentTags(),
inHashTags = hashTags();
var inComment = commentTags();
var inHashTags = hashTags();
if (inComment !== null) { // when hashtags are detected in comment...
context.storage('hashtags', null); // always remove stored hashtags - #4304
@@ -340,7 +340,7 @@ export function uiCommit(context) {
function updateChangeset(changed, onInput) {
var tags = _clone(changeset.tags);
var tags = _clone(_changeset.tags);
_forEach(changed, function(v, k) {
k = k.trim().substr(0, 255);
@@ -371,8 +371,8 @@ export function uiCommit(context) {
}
// always update userdetails, just in case user reauthenticates as someone else
if (userDetails && userDetails.changesets_count !== undefined) {
var changesetsCount = parseInt(userDetails.changesets_count, 10) + 1; // #4283
if (_userDetails && _userDetails.changesets_count !== undefined) {
var changesetsCount = parseInt(_userDetails.changesets_count, 10) + 1; // #4283
tags.changesets_count = String(changesetsCount);
// first 100 edits - new user
@@ -397,14 +397,14 @@ export function uiCommit(context) {
delete tags.changesets_count;
}
if (!_isEqual(changeset.tags, tags)) {
changeset = changeset.update({ tags: tags });
if (!_isEqual(_changeset.tags, tags)) {
_changeset = _changeset.update({ tags: tags });
}
}
commit.reset = function() {
changeset = null;
_changeset = null;
};