Skip to content

Commit

Permalink
New rest_api() function to get endpoint URL
Browse files Browse the repository at this point in the history
  • Loading branch information
dregad committed Feb 25, 2018
1 parent 602708f commit 9981a88
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions files/announce.js
Expand Up @@ -2,6 +2,22 @@
// Copyright (c) 2017 Damien Regad
// Licensed under the MIT license

/**
* Namespace for global function used in list_action.js
*/
var Announce = Announce || {};

/**
* Return MantisBT REST API URL for given endpoint
* @param {string} endpoint
* @returns {string} REST API URL
*/
Announce.rest_api = function(endpoint) {
// Using the full URL (through index.php) to avoid issues on sites
// where URL rewriting is not working (#31)
return "api/rest/index.php/plugins/Announce/" + endpoint;
};

jQuery(document).ready(function($) {
var announcement = $('div.announcement');

Expand Down Expand Up @@ -45,9 +61,7 @@ jQuery(document).ready(function($) {

$.ajax({
type: 'POST',
// Using the full URL (through index.php) to avoid issues on sites
// where URL rewriting is not working (#31)
url: 'api/rest/index.php/plugins/Announce/dismiss/' + context_id,
url: Announce.rest_api('dismiss/') + context_id,
success: function() {
$(announcement).fadeOut();
},
Expand Down

0 comments on commit 9981a88

Please sign in to comment.