mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-01-06 13:56:14 +08:00
moved template-defined constants to window scope
This commit is contained in:
parent
2f9701d44f
commit
9bc8fd9997
@ -3,11 +3,11 @@ import { apiV2Request } from '@/js/apiRequests';
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var NO_PERMS_SET = null;
|
||||
var NO_NAME_SET = null;
|
||||
var TOO_LONG_NAME = null;
|
||||
var NAMED_USED = null;
|
||||
var DELETE_KEY = null;
|
||||
var NO_PERMS_SET = window.NO_PERMS_SET;
|
||||
var NO_NAME_SET = window.NO_NAME_SET;
|
||||
var TOO_LONG_NAME = window.TOO_LONG_NAME;
|
||||
var NAMED_USED = window.NAMED_USED;
|
||||
var DELETE_KEY = window.DELETE_KEY;
|
||||
|
||||
//=====> HELPER FUNCTIONS
|
||||
|
||||
|
@ -4,6 +4,8 @@ import $ from 'jquery';
|
||||
|
||||
var PROJECT_OWNER = null;
|
||||
var PROJECT_SLUG = null;
|
||||
const DEFAULT_HEX = window.DEFAULT_HEX;
|
||||
const CHANNEL_CREATE_ROUTE = window.CHANNEL_CREATE_ROUTE;
|
||||
|
||||
//=====> HELPER FUNCTIONS
|
||||
|
||||
@ -178,4 +180,16 @@ function initColorPicker() {
|
||||
|
||||
$(function() {
|
||||
initModal();
|
||||
if (window.initChannelManager) {
|
||||
initChannelManager(
|
||||
'#channel-new',
|
||||
'',
|
||||
DEFAULT_HEX,
|
||||
'New channel',
|
||||
CHANNEL_CREATE_ROUTE,
|
||||
'post',
|
||||
'Create channel',
|
||||
false
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -3,8 +3,8 @@ import { sanitize, toggleSpinner } from '@/utils';
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var PROJECT_OWNER = null;
|
||||
var PROJECT_SLUG = null;
|
||||
var PROJECT_OWNER = window.PROJECT_OWNER;
|
||||
var PROJECT_SLUG = window.PROJECT_SLUG;
|
||||
|
||||
//=====> DOCUMENT READY
|
||||
|
||||
|
@ -2,9 +2,9 @@ import $ from 'jquery';
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var pluginId = null;
|
||||
var keyGenText = null;
|
||||
var keyRevokeText = null;
|
||||
var pluginId = window.pluginId;
|
||||
var keyGenText = window.keyGenText;
|
||||
var keyRevokeText = window.keyRevokeText;
|
||||
|
||||
var KEY_TYPE_DEPLOYMENT = 0;
|
||||
|
||||
|
@ -2,8 +2,8 @@ import $ from 'jquery';
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var pluginId = null;
|
||||
var namespace = null;
|
||||
var PLUGIN_ID = window.PLUGIN_ID;
|
||||
var NAMESPACE = window.NAMESPACE;
|
||||
|
||||
//=====> HELPER FUNCTIONS
|
||||
|
||||
@ -14,7 +14,7 @@ function bindExpand(e) {
|
||||
var $this = $(this);
|
||||
$.ajax({
|
||||
method: 'get',
|
||||
url: '/api/v1/projects/' + pluginId + '/pages?parentId=' + pageId,
|
||||
url: '/api/v1/projects/' + PLUGIN_ID + '/pages?parentId=' + pageId,
|
||||
dataType: 'json',
|
||||
success: function(childPages) {
|
||||
console.log(childPages);
|
||||
@ -24,7 +24,7 @@ function bindExpand(e) {
|
||||
var page = childPages[i];
|
||||
var childPage = $('<li class="list-group-item page-item-child">' + '<a href=""></a>' + '</li>');
|
||||
var link = childPage.find('a');
|
||||
link.attr('href', namespace + '/pages/' + page.fullSlug);
|
||||
link.attr('href', NAMESPACE + '/pages/' + page.fullSlug);
|
||||
link.text(page.name); // this will sanitize the input
|
||||
div.append(childPage);
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ import { decodeHtml, numberWithCommas, toggleSpinner } from '@/utils';
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var projectOwner = null;
|
||||
var projectSlug = null;
|
||||
var projectId = null;
|
||||
var alreadyStarred = false;
|
||||
const PROJECT_OWNER = PROJECT_OWNER;
|
||||
const PROJECT_SLUG = PROJECT_SLUG;
|
||||
const PROJECT_ID = PROJECT_ID;
|
||||
const ALREADY_STARRED = window.ALREADY_STARRED;
|
||||
|
||||
//=====> HELPER FUNCTIONS
|
||||
|
||||
@ -236,18 +236,18 @@ $(function() {
|
||||
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: decodeHtml('/' + projectOwner + '/' + projectSlug) + '/watchers/' + !watching
|
||||
url: decodeHtml('/' + PROJECT_OWNER + '/' + PROJECT_SLUG) + '/watchers/' + !watching
|
||||
});
|
||||
});
|
||||
|
||||
// setup star button
|
||||
var increment = alreadyStarred ? -1 : 1;
|
||||
var increment = ALREADY_STARRED ? -1 : 1;
|
||||
$('.btn-star').click(function() {
|
||||
var starred = $(this).find('.starred');
|
||||
starred.html(' ' + (parseInt(starred.text()) + increment).toString());
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: decodeHtml('/' + projectOwner + '/' + projectSlug) + '/stars/toggle'
|
||||
url: decodeHtml('/' + PROJECT_OWNER + '/' + PROJECT_SLUG) + '/stars/toggle'
|
||||
});
|
||||
|
||||
if (increment > 0) {
|
||||
@ -263,14 +263,14 @@ $(function() {
|
||||
increment *= -1;
|
||||
});
|
||||
|
||||
if (projectId) {
|
||||
apiV2Request('projects/' + projectId).then(response => {
|
||||
if (PROJECT_ID) {
|
||||
apiV2Request('projects/' + PROJECT_ID).then(response => {
|
||||
if (response.promoted_versions) {
|
||||
let html = '';
|
||||
response.promoted_versions.forEach(version => {
|
||||
const href = window.jsRoutes.controllers.project.Versions.show(
|
||||
projectOwner,
|
||||
projectSlug,
|
||||
PROJECT_OWNER,
|
||||
PROJECT_SLUG,
|
||||
version.version
|
||||
).absoluteURL();
|
||||
html = html + "<li class='list-group-item'><a href='" + href + "'>" + version.version + '</a></li>';
|
||||
|
@ -6,7 +6,7 @@ var KEY_RETURN = 13;
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var projectName = null;
|
||||
var PROJECT_NAME = window.PROJECT_NAME;
|
||||
|
||||
//=====> DOCUMENT READY
|
||||
|
||||
@ -14,7 +14,7 @@ $(function() {
|
||||
var name = $('#name');
|
||||
name.on('input', function() {
|
||||
var val = $(this).val();
|
||||
$('#btn-rename').prop('disabled', val.length === 0 || val === projectName);
|
||||
$('#btn-rename').prop('disabled', val.length === 0 || val === PROJECT_NAME);
|
||||
});
|
||||
|
||||
name.keydown(function(e) {
|
||||
|
@ -3,7 +3,7 @@ import { go } from '@/utils';
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var CURRENT_PAGE = 0;
|
||||
const CURRENT_PAGE = window.CURRENT_PAGE || 0;
|
||||
|
||||
//=====> DOCUMENT READY
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { initChannelManager } from '@/js/channelManage';
|
||||
|
||||
//=====> EXTERNAL CONSTANTS
|
||||
|
||||
var DEFAULT_COLOR = null;
|
||||
var DEFAULT_COLOR = window.DEFAULT_COLOR;
|
||||
|
||||
//=====> HELPER FUNCTIONS
|
||||
|
||||
|
@ -6,18 +6,14 @@
|
||||
<#import "*/utils/csrf.ftlh" as csrf>
|
||||
|
||||
<#assign scriptsVar>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/channelManage.js" />"></script>
|
||||
<script <#--@CSPNonce.attr-->>
|
||||
PROJECT_OWNER = '${p.project.ownerName}';
|
||||
PROJECT_SLUG = '${p.project.slug}';
|
||||
$(function () {
|
||||
initChannelManager(
|
||||
"#channel-new", "", "${config.channels.colorDefault.hex}", "New channel",
|
||||
"${Routes.CHANNELS_CREATE.getRouteUrl(p.project.ownerName, p.project.slug)}",
|
||||
"post", "Create channel", false
|
||||
);
|
||||
});
|
||||
PROJECT_OWNER = '${p.project.ownerName}';
|
||||
PROJECT_SLUG = '${p.project.slug}';
|
||||
window.initChannelManager = true;
|
||||
window.DEFAULT_HEX = '${config.channels.colorDefault.hex}';
|
||||
window.CHANNEL_CREATE_ROUTE = '${Routes.CHANNELS_CREATE.getRouteUrl(p.project.ownerName, p.project.slug)}';
|
||||
</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/channelManage.js" />"></script>
|
||||
</#assign>
|
||||
|
||||
<#assign message><@spring.messageArgs code="channel.list.title" args=[p.project.ownerName, p.project.slug] /></#assign>
|
||||
|
@ -18,13 +18,13 @@ Documentation page within Project overview.
|
||||
</#function>
|
||||
|
||||
<#assign scriptsVar>
|
||||
<script> <#--@CSPNonce.attr-->
|
||||
window.PLUGIN_ID = '${p.getProject().pluginId}';
|
||||
window.NAMESPACE = '${p.getFullSlug()}';
|
||||
</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/pageCollapse.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/userSearch.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/memberList.js" />"></script>
|
||||
<script> <#--@CSPNonce.attr-->
|
||||
pluginId = '${p.getProject().pluginId}';
|
||||
namespace = '${p.getFullSlug()}';
|
||||
</script>
|
||||
<#if editorOpen>
|
||||
<script <#--@CSPNonce.attr-->>$(function() { $('.btn-edit').click(); });</script>
|
||||
</#if>
|
||||
|
@ -13,20 +13,20 @@
|
||||
request: OreRequest[_], config: OreConfig, renderer: MarkdownRenderer, assetsFinder: AssetsFinder)-->
|
||||
|
||||
<#assign scriptsVar>
|
||||
<script <#--@CSPNonce.attr -->>
|
||||
window.PROJECT_NAME = "${p.project.name}";
|
||||
window.PROJECT_OWNER = "${p.project.ownerName}";
|
||||
window.PROJECT_SLUG = "${p.project.slug}";
|
||||
window.pluginId = "${p.project.pluginId}";
|
||||
window.keyGenText = "<@spring.message "project.settings.genKey" />";
|
||||
window.keyRevokeText = "<@spring.message "project.settings.revokeKey" />";
|
||||
</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/projectManage.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/hideProject.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/iconUpload.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/keyGen.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/userSearch.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/memberList.js" />"></script>
|
||||
<script <#--@CSPNonce.attr -->>
|
||||
projectName = "${p.project.name}";
|
||||
PROJECT_OWNER = "${p.project.ownerName}";
|
||||
PROJECT_SLUG = "${p.project.slug}";
|
||||
pluginId = "${p.project.pluginId}";
|
||||
keyGenText = "<@spring.message "project.settings.genKey" />";
|
||||
keyRevokeText = "<@spring.message "project.settings.revokeKey" />";
|
||||
</script>
|
||||
</#assign>
|
||||
|
||||
<#assign Permission=@helper["io.papermc.hangar.model.Permission"]>
|
||||
|
@ -14,14 +14,13 @@
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/channelManage.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/pluginUpload.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/projectDetail.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/versionCreateChannelNew.js" />"></script>
|
||||
<#if pending?? && !pending.dependencies??>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/platform-choice.js" />"></script>
|
||||
</#if>
|
||||
|
||||
<script>
|
||||
DEFAULT_COLOR = '${config.channels.colorDefault.hex}';
|
||||
window.DEFAULT_COLOR = '${config.channels.colorDefault.hex}';
|
||||
</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/versionCreateChannelNew.js" />"></script>
|
||||
</#assign>
|
||||
|
||||
<#assign message><@spring.message "version.create.pageTitle" /></#assign>
|
||||
|
@ -13,16 +13,16 @@ Base template for Project overview.
|
||||
<#-- @ftlvariable name="p" type="io.papermc.hangar.model.viewhelpers.ProjectData" -->
|
||||
<#-- @ftlvariable name="sp" type="io.papermc.hangar.model.viewhelpers.ScopedProjectData" -->
|
||||
<#assign scriptsVar>
|
||||
<script <#-- @CSPNonce.attr -->>
|
||||
window.PROJECT_OWNER = "${p.project.ownerName}";
|
||||
window.PROJECT_SLUG = "${p.project.slug}";
|
||||
window.PROJECT_ID = "${p.project.pluginId}";
|
||||
window.ALREADY_STARRED = ${sp.starred?c};
|
||||
$(function() { $(".nav").find("${active}").addClass("active"); });
|
||||
</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/projectDetail.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/pageEdit.js" />"></script>
|
||||
${additionalScripts}
|
||||
<script <#-- @CSPNonce.attr -->>
|
||||
var projectOwner = "${p.project.ownerName}";
|
||||
var projectSlug = "${p.project.slug}";
|
||||
var projectId = "${p.project.pluginId}";
|
||||
var alreadyStarred = ${sp.starred?c};
|
||||
$(function() { $(".nav").find("${active}").addClass("active"); });
|
||||
</script>
|
||||
</#assign>
|
||||
|
||||
<#assign metaVar>
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
<#--@(u: UserData, o: Option[(OrganizationData, ScopedOrganizationData)], keys: Seq[ApiKey], perms: Seq[NamedPermission])(implicit messages: Messages, flash: Flash, request: OreRequest[_], config: OreConfig, assetsFinder: AssetsFinder)-->
|
||||
<#assign scriptsVar>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/apiKeysManagement.js" />"></script>
|
||||
<script <#--@CSPNonce.attr-->>
|
||||
NO_PERMS_SET = '<@spring.message "user.apiKeys.error.noPermsSet" />';
|
||||
NO_NAME_SET = '<@spring.message "user.apiKeys.error.noNameSet" />';
|
||||
TOO_LONG_NAME = '<@spring.message "user.apiKeys.error.tooLongName" />';
|
||||
NAMED_USED = '<@spring.message "user.apiKeys.error.nameAlreadyUsed" />';
|
||||
DELETE_KEY = '<@spring.message "user.apiKeys.keyDeleteButton" />';
|
||||
window.NO_PERMS_SET = '<@spring.message "user.apiKeys.error.noPermsSet" />';
|
||||
window.NO_NAME_SET = '<@spring.message "user.apiKeys.error.noNameSet" />';
|
||||
window.TOO_LONG_NAME = '<@spring.message "user.apiKeys.error.tooLongName" />';
|
||||
window.NAMED_USED = '<@spring.message "user.apiKeys.error.nameAlreadyUsed" />';
|
||||
window.DELETE_KEY = '<@spring.message "user.apiKeys.keyDeleteButton" />';
|
||||
</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/apiKeysManagement.js" />"></script>
|
||||
</#assign>
|
||||
|
||||
<#assign NamedPermission=@helper["io.papermc.hangar.model.NamedPermission"] />
|
||||
|
@ -37,8 +37,8 @@
|
||||
</#function>
|
||||
|
||||
<#assign scriptsVar>
|
||||
<script <#--@CSPNonce.attr-->>window.CURRENT_PAGE = ${page};</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/userList.js" />"></script>
|
||||
<script <#--@CSPNonce.attr-->>CURRENT_PAGE = ${page};</script>
|
||||
</#assign>
|
||||
|
||||
<#-- @ftlvariable name="page" type="java.lang.Integer" -->
|
||||
|
@ -19,8 +19,8 @@
|
||||
</#function>
|
||||
|
||||
<#assign scriptsVar>
|
||||
<script <#--@CSPNonce.attr-->>window.CURRENT_PAGE = ${page};</script>
|
||||
<script type="text/javascript" src="<@hangar.url "build/js/userList.js" />"></script>
|
||||
<script <#--@CSPNonce.attr-->>CURRENT_PAGE = ${page};</script>
|
||||
</#assign>
|
||||
|
||||
<@base.base title="Staff - Hangar" additionalScripts=scriptsVar>
|
||||
|
Loading…
Reference in New Issue
Block a user