mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +01:00
a0d63322b1
Summary: There are a bunch of unused variables in JavaScript files. These were identified with JSHint. Test Plan: It's pretty hard to test this thoroughly... on inspection, it seems that everything //should// be okay (unless we are doing weird things with the JavaScript). Reviewers: chad, #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9676
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-passphrase-credential-control
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-stratcom
|
|
* javelin-workflow
|
|
* javelin-util
|
|
* javelin-uri
|
|
* @javelin
|
|
*/
|
|
|
|
JX.behavior('passphrase-credential-control', function() {
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'passphrase-credential-add',
|
|
function(e) {
|
|
var control = e.getNode('passphrase-credential-control');
|
|
var data = e.getNodeData('passphrase-credential-control');
|
|
|
|
var uri = JX.$U('/passphrase/edit/');
|
|
uri.setQueryParam('type', data.type);
|
|
uri.setQueryParam('username', data.username);
|
|
|
|
new JX.Workflow(uri)
|
|
.setHandler(JX.bind(null, onadd, control))
|
|
.start();
|
|
|
|
e.kill();
|
|
});
|
|
|
|
function onadd(control, response) {
|
|
var select = JX.DOM.find(control, 'select', 'passphrase-credential-select');
|
|
|
|
var data = JX.Stratcom.getData(control);
|
|
|
|
// If this allows the user to select "No Credential" (`allowNull`),
|
|
// put the new credential in the menu below the "No Credential" option.
|
|
|
|
// Otherwise, remove the "(No Existing Credentials)" if it exists and
|
|
// put the new credential at the top.
|
|
|
|
var target = 0;
|
|
for (var ii = 0; ii < select.options.length; ii++) {
|
|
if (!select.options[ii].value) {
|
|
if (!data.allowNull) {
|
|
select.remove(ii);
|
|
} else {
|
|
target = ii + 1;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
select.add(
|
|
JX.$N('option', {value: response.phid}, response.name),
|
|
select.options[target] || null);
|
|
|
|
select.value = response.phid;
|
|
select.disabled = null;
|
|
}
|
|
|
|
});
|