Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/RemarkupMetadata.js
- This file was added.
/** | |||||||||||||||||
Lint: `javelinsymbols` Not In Path: The 'javelinsymbols' binary in the Javelin project is not available in $PATH, so the Javelin… | |||||||||||||||||
* @requires javelin-install | |||||||||||||||||
* javelin-dom | |||||||||||||||||
* javelin-json | |||||||||||||||||
* @provides phabricator-remarkup-metadata | |||||||||||||||||
* @javelin | |||||||||||||||||
*/ | |||||||||||||||||
JX.install('RemarkupMetadata', { | |||||||||||||||||
construct: function(metadataValue, metadataID) { | |||||||||||||||||
if (JX.RemarkupMetadata._metadataValue == null) { | |||||||||||||||||
JX.RemarkupMetadata._metadataValue = []; | |||||||||||||||||
JX.RemarkupMetadata._metadataValue[metadataID] = metadataValue; | |||||||||||||||||
} else if (!JX.RemarkupMetadata._metadataValue.hasOwnProperty(metadataID)) { | |||||||||||||||||
JX.RemarkupMetadata._metadataValue[metadataID] = metadataValue; | |||||||||||||||||
} | |||||||||||||||||
this._metadataNode = JX.$(metadataID); | |||||||||||||||||
Done Inline Actions
Thanks. In short, this is the proposed change. Taking this: if (JX.RemarkupMetadata._metadataValue == null) { JX.RemarkupMetadata._metadataValue = []; JX.RemarkupMetadata._metadataValue[metadataID] = metadataValue; } else if (!JX.RemarkupMetadata._metadataValue.hasOwnProperty(metadataID)) { JX.RemarkupMetadata._metadataValue[metadataID] = metadataValue; } And simplifying it to this: if (JX.RemarkupMetadata._metadataValue == null) { JX.RemarkupMetadata._metadataValue = {}; } if (!JX.RemarkupMetadata._metadataValue.hasOwnProperty(metadataID)) { JX.RemarkupMetadata._metadataValue[metadataID] = metadataValue; } Reasons:
valerio.bozzolan: Thanks. In short, this is the proposed change. Taking this:
```
if (JX.RemarkupMetadata. | |||||||||||||||||
Done Inline ActionsHi @Dylsss do you agree with the inline comments here? You can also say "Yeah I don't care" ihih and I will amend that for you, no problem valerio.bozzolan: Hi @Dylsss do you agree with the inline comments here?
You can also say "Yeah I don't care"… | |||||||||||||||||
this._metadataID = metadataID; | |||||||||||||||||
}, | |||||||||||||||||
statics: { | |||||||||||||||||
_metadataValue: null | |||||||||||||||||
}, | |||||||||||||||||
members: { | |||||||||||||||||
_metadataNode: null, | |||||||||||||||||
_metadataID: null, | |||||||||||||||||
_writeMetadata: function() { | |||||||||||||||||
this._metadataNode.value = JX.JSON.stringify( | |||||||||||||||||
JX.RemarkupMetadata._metadataValue[this._metadataID]); | |||||||||||||||||
}, | |||||||||||||||||
getMetadata: function(key, default_value) { | |||||||||||||||||
if (JX.RemarkupMetadata._metadataValue[this._metadataID] | |||||||||||||||||
.hasOwnProperty(key)) { | |||||||||||||||||
return JX.RemarkupMetadata._metadataValue[this._metadataID][key]; | |||||||||||||||||
} | |||||||||||||||||
return default_value; | |||||||||||||||||
}, | |||||||||||||||||
setMetadata: function(key, value) { | |||||||||||||||||
JX.RemarkupMetadata._metadataValue[this._metadataID][key] = value; | |||||||||||||||||
this._writeMetadata(); | |||||||||||||||||
} | |||||||||||||||||
} | |||||||||||||||||
}); |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
The 'javelinsymbols' binary in the Javelin project is not available in $PATH, so the Javelin linter can't run. This isn't a big concern, but means some Javelin problems can't be automatically detected.