Skip to content

Commit

Permalink
add canonical tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ceki committed Feb 4, 2022
1 parent c8d66a2 commit 75257cd
Show file tree
Hide file tree
Showing 5 changed files with 932 additions and 369 deletions.
42 changes: 39 additions & 3 deletions logback-site/src/site/pages/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ p.menu_header {
display: block;
}

span.asGroovy {
span.canonical {
background: #fff;
color: #0079C5;
font-family: "Comic Sans MS", sans-serif;
Expand All @@ -201,10 +201,10 @@ span.asGroovy {
border-bottom: 2px solid #888;
padding: 0px 1em 0px 1em;
margin: -4px 4px 0 4px;
float: right;
float: top;
}

span.asGroovy:hover {
span.canonical:hover {
background: #E0E0EF;
cursor: pointer;
}
Expand Down Expand Up @@ -544,3 +544,39 @@ p.menu {
.deftitle {
font-weight: bold;
}


/* tab BEGIN ================================= */
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}

/* Style the buttons that are used to open the tab content */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
}

.tab button:hover {
background-color: #ddd;
}

.tab button.active {
background-color: #ccc;
}

/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
/* tab END ================================ */
101 changes: 97 additions & 4 deletions logback-site/src/site/pages/js/dsl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,100 @@

var asGroovyURL='http://logback.qos.ch/translator/dsl/asGroovy';
//var xml2CanonURL='https://logback.qos.ch/translator/dsl/xml2Canon/asText';
var xml2CanonURL='/translator/dsl/xml2Canon/asText';

function asGroovy(id) {
//var xml2CanonURL='http://localhost:8080/translator/dsl/xml2Canon/asText';

function canonical(legacyId, canonicalId) {

var form = document.getElementById('aForm');
if(form == null) {
form = document.createElement("form");
document.body.appendChild(form);
}

$(form).empty();
form.id = 'aForm';

var legacyElement = document.getElementById(legacyId);

var inner = legacyElement.innerHTML;
//alert("==="+inner);
inner = inner.replace(/<pre class="prettyprint source">/gi, '');
inner = inner.replace(/<\/pre>/gi, '');
inner = inner.replace(/&lt;/gi, '<');
inner = inner.replace(/&gt;/gi, '>');

inner = inner.replace(/<span class="[^"]*"?>/gi, '');
inner = inner.replace(/<\/span>/gi, '');
inner = inner.replace(/<br>/gi, '');
inner = inner.replace(/&nbsp;/gi, '');
inner = inner.replace(/<b>/gi, '');
inner = inner.replace(/<\/b>/gi, '');

form.setAttribute("method", "post");
form.setAttribute("action", xml2CanonURL);

var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "val");
hiddenField.setAttribute("value", inner);
form.appendChild(hiddenField);

var postData = $("#aForm").serialize();

var canonicalElement = document.getElementById(canonicalId);


$.post(xml2CanonURL, postData, function(payload, status) {
payload = '<pre class="source prettyprint">'+payload+'</pre>'
canonicalElement.innerHTML = payload;
canonicalElement.innerHTML = prettyPrintOne(canonicalElement.innerHTML);
});


}

// $.ajax({
// url: xml2CanonURL,
// type: 'POST',
// crossDomain: true,
// headers: {'Referrer-Policy': 'origin-when-cross-origin',
// 'Access-Control-Allow-Origin': '*',
// 'Access-Control-Allow-Credentials': 'true',
// 'Access-Control-Allow-Methods': 'POST, OPTIONS'},
// //beforeSend: function(xhr){
// // xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
// // xhr.setRequestHeader('Access-Control-Allow-Credentials', 'true');
// // xhr.setRequestHeader('Access-Control-Allow-CredentialsMethods', 'POST');
// //},
// //xhrFields: { withCredentials: true },
// data: inner,
// success: function(res) {
// alert(res);
// }
//
// } );
// alert("zzzzz");
// form.submit( function (event) {
// $.ajax({
// url: xml2CanonURL,
// type: 'POST',
// contents: 'text/plain; charset=UTF-8',
// processData: false,
// dataType: "text",
// data: $(this).serialize(),
// success: function(payload, status) {
// alert(payload);
// }
// });
// return false;
// //event.preventDefault();
// });
// return false;
//}


function xxCcanonical(id) {

var form = document.getElementById('aForm');
if(form == null) {
Expand All @@ -10,7 +103,7 @@ function asGroovy(id) {
}
var p = document.getElementById(id);

var inner = p.innerHTML;
var inner = legacyElementinnerHTML;
//alert("==="+inner);
inner = inner.replace(/&lt;/gi, '<');
inner = inner.replace(/&gt;/gi, '>');
Expand All @@ -23,7 +116,7 @@ function asGroovy(id) {
inner = inner.replace(/<\/b>/gi, '');

form.setAttribute("method", "post");
form.setAttribute("action", asGroovyURL);
form.setAttribute("action", xml2CanonURL);

var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
Expand Down
Loading

0 comments on commit 75257cd

Please sign in to comment.