Page History
HTML |
---|
<script> function download_file(data, downloadFileName) { console.log("Download filename: ", downloadFileName); var fileName = downloadFileName.replace("+", " ") { ; console.log("Filename: ", 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); } var blob = new Blob([ab], { type: 'application/pdf' }); if (window.navigator.msSaveOrOpenBlob) { // IE hack; see http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx window.navigator.msSaveOrOpenBlob(blob, fileName); } else { var downloadUrl = URL.createObjectURL(blob); $( "#download") .attr({ 'download': fileName, 'href': downloadUrl }); $( "#download") [0].click(); window.history.back(); } }; function getQueryParametersAJS.toInit(function() { // Function varto queryParamsparse =URL {};parameters function getParameterByName(name) { var query = console.log(window.location.search.substring(1href); var pairsname = queryname.split('replace(/[\[\]]/g, '\\$&'); for (var iregex = 0; i < pairs.length; i++) { var pair = pairs[i].split('='); var key = decodeURIComponent(pair[0]);new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), varresults value = decodeURIComponent(pair[1]regex.exec(window.location.href); queryParams[key] = value; } console.log("Queryparams: ", queryParams); return queryParams; } function updateMacroOnExistingPage() { console.log("updateMacroOnExistingPage"); var queryParams = getQueryParameters(); // Define the macro name and parameters based on query parameters var macroName = 'Mineaftalerif (!results) return null; if (!results[2]) return ''; 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 }; return decodeURIComponent(results[2].replace(/\+/g, ' ')); } // Generate the updated macro markupExample usage var updatedMacroMarkupparamValue = getParameterByName('{kategori'); + macroName + ':'; for (var key in macroParameters) { if (macroParameters.hasOwnProperty(key)) { updatedMacroMarkup += key + '=' + macroParameters[key] + '|'; } } // Remove the trailing '|' character updatedMacroMarkup = updatedMacroMarkup.slice(0, -1); updatedMacroMarkup += '}'; // 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:[^\}]+\})/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 }, type: 'page', title: 'Mine aftaler', body: { storage: { value: updatedContent, representation: 'storage' } } }; // 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 successfully.'); }, error: function(error) { console.error('Error updating macro on the page:', error); } }); }, error: function(error) { console.error('Error retrieving page content:', error); } }); } AJS.toInit(function() { updateMacroOnExistingPage(); }); </script> |
Warning |
console.log('Kategori:', paramValue);
if (paramValue === 'KOM' || paramValue === 'REG' || paramValue === 'STA' || paramValue === 'LPS' || paramValue === 'APO' || paramValue === 'ITL' || paramValue === 'OVR') {
console.log("switch ", paramValue);
$('.toggle-agreements').hide();
$('#agreement-category-' + paramValue).show();
}
paramValue = getParameterByName('link');
console.log('Header value:', paramValue);
if (paramValue !== null) {
$('html, body').scrollTop($('#' + paramValue).offset().top);
}
});
</script> |
Aftaleoversigt | ||||||
---|---|---|---|---|---|---|
|