mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 14:40:27 +00:00
Format the history popup content
This commit is contained in:
parent
5ac58d5503
commit
4263bccbba
@ -241,26 +241,30 @@ function reload_domains(url) {
|
||||
|
||||
// pretty JSON
|
||||
json_library = {
|
||||
replacer: function(match, pIndent, pKey, pVal, pEnd) {
|
||||
replacer: function (match, pIndent, pKey, pVal, pEnd) {
|
||||
var key = '<span class=json-key>';
|
||||
var val = '<span class=json-value>';
|
||||
var str = '<span class=json-string>';
|
||||
var r = pIndent || '';
|
||||
if (pKey){
|
||||
r = r + key + pKey.replace(/[": ]/g, '') + '</span>: ';
|
||||
if (pKey) {
|
||||
// r = r + key + pKey.replace(/[": ]/g, '') + '</span>: ';
|
||||
// Keep the quote in the key
|
||||
r = r + key + pKey.replace(/":/, '"') + '</span>: ';
|
||||
}
|
||||
if (pVal){
|
||||
if (pVal) {
|
||||
r = r + (pVal[0] == '"' ? str : val) + pVal + '</span>';
|
||||
}
|
||||
return r + (pEnd || '');
|
||||
},
|
||||
prettyPrint: function(obj) {
|
||||
prettyPrint: function (obj) {
|
||||
obj = obj.replace(/u'/g, "\'").replace(/'/g, "\"").replace(/(False|None)/g, "\"$1\"");
|
||||
var jsonData = JSON.parse(obj);
|
||||
var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg;
|
||||
return JSON.stringify(jsonData, null, 3)
|
||||
// var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg;
|
||||
// The new regex to handle case value is an empty list [] or dict {}
|
||||
var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?/mg;
|
||||
return JSON.stringify(jsonData, null, 3)
|
||||
.replace(/&/g, '&').replace(/\\"/g, '"')
|
||||
.replace(/</g, '<').replace(/>/g, '>')
|
||||
.replace(jsonLine, json_library.replacer);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -107,7 +107,7 @@
|
||||
<td>{{ history.msg }}</td>
|
||||
<td>{{ history.created_on }}</td>
|
||||
<td width="6%">
|
||||
<button type="button" class="btn btn-flat btn-primary history-info-button" value='{{ history.detail|replace("[]","None") }}'>
|
||||
<button type="button" class="btn btn-flat btn-primary history-info-button" value='{{ history.detail }}'>
|
||||
Info <i class="fa fa-info"></i>
|
||||
</button>
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user