Page History
...
HTML |
---|
<script> function download_file(data, fileName) { var fileData = data; var byteChars = $.base64('decode', fileData); var ab = new ArrayBuffer(byteChars.length); var ia = new Uint8Array(ab); for (var i = 0; i < byteChars.length; i++) { ia[i] = byteChars.charCodeAt(i{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true); } var blob = new Blob([ab], { type: 'application/pdf{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true' }); if (window.navigator.msSaveOrOpenBlob) { // IE hack; see http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx window.navigator.msSaveOrOpenBlob(blob, fileName{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true); } else { var downloadUrl = URL.createObjectURL(blob); $( "#download") .attr({ 'download': fileName, 'href': downloadUrl{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true }); $( "#download")[0].click(); window.history.ba{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=trueback(); } }; function getQueryParameters() { var queryParams = {}; var query = window.location.search.substring(1); var pairs = query.split('&'); for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split('='); var key = decodeURIComponent(pair[0]); var value = decodeURIComponent(pair[1]); queryParams[key] = value{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true; } console.log("Queryparams: ", queryParams); return queryPara{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=truequeryParams; } function updateMacroOnExistingPage() { console.log("updateMacroOnExistingPage"); var queryParams = getQueryParameters(); // Define the macro name and parameters based on query parameters var macroName = 'Mineaftaler'; var macroParameters = { REST_HTML_URL: 'http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html', REST_DOWNLOAD_URL: 'http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes', include_user_info: true{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true }; // Generate the updated macro markup var updatedMacroMarkup = '{' + macroName + ':'; for (var key in macroParameters) { if (macroParameters.hasOwnProperty(key)) { updatedMacroMarkup += key + '=' + macroParameters[key]{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true + '|'; } } // Remove the trailing '|' character updatedMacroMarkup = updatedMacroMarkup.slice(0, -1); updatedMacroMar{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=trueupdatedMacroMarkup += '}'; // Page ID of the existing Confluence page var pageId = '33594461'; // Replace with the actual Page ID // Make an AJAX request to retrieve the current page content AJS.$.ajax({ url: '/rest/api/content/' + pageId + '?expand=body.storage,version', type: 'GET', success: function(data) { // Get the current page content console.log("Get content ok - data: ", data); var currentContent = data.body.storage.value; console.log("CurrentContent: ", currentContent); // Replace the old macro markup with the updated macro markup var updatedContent = currentContent.replace(/([^\]\{MineAftaler:[^{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}]{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true\}]+\})/g, updatedMacroMarkup); // Create a JSON payload for the REST API request to update the page var payload = { version: { number: data.version.number + 1 // Increment this number if you want to update the page content{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true }, type: 'page', title: 'Mine aftaler', body: { storage: { value: updatedContent, representation: 'storage{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true' } } }; // Make an AJAX request to update the page content AJS.$.ajax({ url: '/rest/api/content/' + pageId, type: 'PUT', contentType: 'application/json', data: JSON.stringify(payload), success: function(data) { console.log('Macro on the page updated successfull{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=truesuccessfully.'); }, error: function(error) { console.error('Error updating macro on the page:', error{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true); } }); }, error: function(error) { console.error('Error retrieving page content:', error{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true}{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true); } }); } AJS.toInit(function() { updateMacroOnExistingPage{Mineaftaler:REST_HTML_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/html|REST_DOWNLOAD_URL=http://foedus01.nsi.netic.dk:8080/NSI_Aftaler-1.1.1-SNAPSHOT/rest/base64encodefilebytes|include_user_info=true(); }); </script> |
Warning |
---|
Det er desværre ikke muligt at godkende aftaler i øjeblikket. Der foretages en opgradering af systemet. |
...