Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Bug 1225492 - XHTML files contain errorprone javascript calls
Browse files Browse the repository at this point in the history
errorprone calls replaced with safe function
  • Loading branch information
Libor Zoubek authored and Simeon Pinder committed Jul 14, 2015
1 parent 2f80c8c commit 3e53306
Show file tree
Hide file tree
Showing 27 changed files with 64 additions and 37 deletions.
27 changes: 27 additions & 0 deletions modules/enterprise/gui/portal-war/src/main/webapp/js/rhq.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,33 @@ function hideInitialDivs() {
hidediv('recur');
hidediv('end');
}
/**
* set attribute to given value for element specified by ID
* @param elementId element ID
* @param attribute name
* @param value - attribute value to set
*/
var setAttribute = function(elementId, attribute, value) {
var el = document.getElementById(elementId);
if (el && el != null) {
el.setAttribute(attribute, value);
} else {
console.log('Failed to set ['+attribute+'='+value+'] : node id=[' + elementId + '] not found');
}
}
/**
* set 'action' attributes to elements based on given actionMap. If actionMap is for example
* {elementID:'foo'}, then attribute 'action' is going to be set to 'foo' for element with id 'elementID'
*
* @param actionMap map<elementId,actionValue>
*/
var setFormActions = function(actionMap) {
for (key in actionMap) {
if (actionMap.hasOwnProperty(key)) {
setAttribute(key,'action',actionMap[key]);
}
}
}

/**
* WindowResizeTracker can be used by scripts that need to keep track
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ THIS TEXT WILL BE REMOVED.

</h:form>
<script>
document.getElementById('editContentProviderConfigurationForm').setAttribute('action', 'contentProvider-add-map-plain.xhtml');
setFormActions({editContentProviderConfigurationForm:'contentProvider-add-map-plain.xhtml'});
</script>
</ui:define>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ THIS TEXT WILL BE REMOVED.

</h:form>
<script>
document.getElementById('editContentProviderConfigurationForm').setAttribute('action', 'contentProvider-edit-map-plain.xhtml');
setFormActions({editContentProviderConfigurationForm:'contentProvider-edit-map-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,11 @@
</rich:panel>
</h:form>
<script>
document.getElementById('pollerForm').setAttribute('action', 'contentProvider-plain.xhtml');
document.getElementById('contentProviderDetailsForm').setAttribute('action', 'contentProvider-plain.xhtml');
document.getElementById('contentSourceSyncResultsListForm').setAttribute('action', 'contentProvider-plain.xhtml');
document.getElementById('contentSourceRepoListForm').setAttribute('action', 'contentProvider-plain.xhtml');
setFormActions({
pollerForm:'contentProvider-plain.xhtml',
contentProviderDetailsForm: 'contentProvider-plain.xhtml',
contentSourceSyncResultsListForm: 'contentProvider-plain.xhtml',
contentSourceRepoListForm: 'contentProvider-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ THIS TEXT WILL BE REMOVED.

</h:form>
<script>
document.getElementById('editContentProviderConfigurationForm').setAttribute('action', 'contentProvider-view-map-plain.xhtml');
setFormActions({editContentProviderConfigurationForm: 'contentProvider-view-map-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ THIS TEXT WILL BE REMOVED.

</h:form>
<script>
document.getElementById('editContentProviderConfigurationForm').setAttribute('action', 'createContentProvider-add-map-plain.xhtml');
setFormActions({editContentProviderConfigurationForm: 'createContentProvider-add-map-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ THIS TEXT WILL BE REMOVED.

</h:form>
<script>
document.getElementById('editContentProviderConfigurationForm').setAttribute('action', 'createContentProvider-edit-map-plain.xhtml');
setFormActions({editContentProviderConfigurationForm': 'createContentProvider-edit-map-plain.xhtml'});
</script>
</ui:define>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@

</h:form>
<script>
document.getElementById('setContentSourceType').setAttribute('action', 'createContentProvider-plain.xhtml');
setFormActions({setContentSourceType: 'createContentProvider-plain.xhtml'});
</script>
</ui:define>
</ui:composition>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

</h:form>
<script>
document.getElementById('createRepoDetailsForm').setAttribute('action', 'createRepo-plain.xhtml');
setFormActions({createRepoDetailsForm: 'createRepo-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
</rich:panel>
</h:form>
<script>
document.getElementById('importRepoForm').setAttribute('action', 'importRepos-plain.xhtml');
setFormActions({importRepoForm: 'importRepos-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
</rich:panel>
</h:form>
<script>
document.getElementById('contentProvidersListForm').setAttribute('action', 'listContentProviders-plain.xhtml');
setFormActions({contentProvidersListForm: 'listContentProviders-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@

</h:form>
<script>
document.getElementById('reposListForm').setAttribute('action', 'listRepos-plain.xhtml');
setFormActions({reposListForm: 'listRepos-plain.xhtml'});
</script>
</ui:define>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@

</h:form>
<script>
document.getElementById('repoDetailsForm').setAttribute('action', 'packageVersion-plain.xhtml');
setFormActions({repoDetailsForm: 'packageVersion-plain.xhtml'});
</script>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,13 +894,14 @@
</h:form>

<script>
document.getElementById('repoDetailsForm').setAttribute('action', 'repo-plain.xhtml');
document.getElementById('repoContentProvidersListForm').setAttribute('action', 'repo-plain.xhtml');
document.getElementById('repoResourcesListForm').setAttribute('action', 'repo-plain.xhtml');
document.getElementById('repoPackageVersionsListForm').setAttribute('action', 'repo-plain.xhtml');
document.getElementById('formFoo').setAttribute('action', 'repo-plain.xhtml');
document.getElementById('repoDistributionListForm').setAttribute('action', 'repo-plain.xhtml');
document.getElementById('repoAdvisoryListForm').setAttribute('action', 'repo-plain.xhtml');
setFormActions({
repoDetailsForm: 'repo-plain.xhtml',
repoContentProvidersListForm: 'repo-plain.xhtml',
repoResourcesListForm: 'repo-plain.xhtml',
repoPackageVersionsListForm: 'repo-plain.xhtml',
formFoo: 'repo-plain.xhtml',
repoDistributionListForm: 'repo-plain.xhtml',
repoAdvisoryListForm: 'repo-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@
</rich:panel>
</h:form>
<script>
document.getElementById('repoDisassociationsListForm').setAttribute('action', 'repoAssociations-plain.xhtml');
document.getElementById('repoAssociationsListForm').setAttribute('action', 'repoAssociations-plain.xhtml');
setFormActions({repoDisassociationsListForm: 'repoAssociations-plain.xhtml',repoAssociationsListForm: 'repoAssociations-plain.xhtml'});
</script>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@
</rich:panel>
</h:form>
<script>
document.getElementById('repoSubscriptionsListForm').setAttribute('action', 'repoSubscriptions-plain.xhtml');
document.getElementById('repoUnsubscriptionsListForm').setAttribute('action', 'repoSubscriptions-plain.xhtml');
setFormActions({repoSubscriptionsListForm: 'repoSubscriptions-plain.xhtml', repoUnsubscriptionsListForm: 'repoSubscriptions-plain.xhtml'});
</script>
</ui:define>
</ui:composition>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

</h:form>
<script>
document.getElementById('contentRequestsForm').setAttribute('action', 'audit-trail-item-plain.xhtml');
setFormActions({contentRequestsForm: 'audit-trail-item-plain.xhtml'});
</script>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
</h:form>

<script>
document.getElementById('confirmCreateForm').setAttribute('action', 'confirm-create-plain.xhtml');
setFormActions({confirmCreateForm: 'confirm-create-plain.xhtml'});
</script>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

</h:form>
<script>
document.getElementById('confirmDeleteForm').setAttribute('action', 'confirm-delete-plain.xhtml');
setFormActions({confirmDeleteForm: 'confirm-delete-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@

</h:form>
<script>
document.getElementById('uploadForm').setAttribute('action', 'create-plain.xhtml');
setFormActions({uploadForm: 'create-plain.xhtml'});
</script>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
</h:form>

<script>
document.getElementById('currentPackageVersionsForm').setAttribute('action', 'deploy-plain.xhtml');
setFormActions({'currentPackageVersionsForm': 'deploy-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@

</h:form>
<script>
document.getElementById('contentaRequestsForm').setAttribute('action', 'history-plain.xhtml');
setFormActions({contentaRequestsForm: 'history-plain.xhtml'});
</script>

</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

</h:form>
<script>
document.getElementById('contentRequestsForm').setAttribute('action', 'history-request-item-plain.xhtml');
setFormActions({contentRequestsForm: 'history-request-item-plain.xhtml'});
</script>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@

</h:form>
<script>
document.getElementById('contentRequestsForm').setAttribute('action', 'history-request-plain.xhtml');
setFormActions({contentRequestsForm: 'history-request-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

</h:form>
<script>
document.getElementById('contentRequestsForm').setAttribute('action', 'history-request-step-details-plain.xhtml');
setFormActions({contentRequestsForm: 'history-request-step-details-plain.xhtml'});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@

</h:form>
<script>
document.getElementById('availableRepoForm').setAttribute('action', window.location.href);
setFormActions({availableRepoForm: window.location.href});
</script>

</ui:define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</rich:panel>
</h:form>
<script>
document.getElementById('contentForm').setAttribute('action', 'view-plain.xhtml');
setFormActions({contentForm: 'view-plain.xhtml'});
</script>
</ui:define>
</ui:composition>

0 comments on commit 3e53306

Please sign in to comment.