mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-14 01:20: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
|
// pretty JSON
|
||||||
json_library = {
|
json_library = {
|
||||||
replacer: function(match, pIndent, pKey, pVal, pEnd) {
|
replacer: function (match, pIndent, pKey, pVal, pEnd) {
|
||||||
var key = '<span class=json-key>';
|
var key = '<span class=json-key>';
|
||||||
var val = '<span class=json-value>';
|
var val = '<span class=json-value>';
|
||||||
var str = '<span class=json-string>';
|
var str = '<span class=json-string>';
|
||||||
var r = pIndent || '';
|
var r = pIndent || '';
|
||||||
if (pKey){
|
if (pKey) {
|
||||||
r = r + key + pKey.replace(/[": ]/g, '') + '</span>: ';
|
// 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>';
|
r = r + (pVal[0] == '"' ? str : val) + pVal + '</span>';
|
||||||
}
|
}
|
||||||
return r + (pEnd || '');
|
return r + (pEnd || '');
|
||||||
},
|
},
|
||||||
prettyPrint: function(obj) {
|
prettyPrint: function (obj) {
|
||||||
obj = obj.replace(/u'/g, "\'").replace(/'/g, "\"").replace(/(False|None)/g, "\"$1\"");
|
obj = obj.replace(/u'/g, "\'").replace(/'/g, "\"").replace(/(False|None)/g, "\"$1\"");
|
||||||
var jsonData = JSON.parse(obj);
|
var jsonData = JSON.parse(obj);
|
||||||
var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg;
|
// 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)
|
return JSON.stringify(jsonData, null, 3)
|
||||||
.replace(/&/g, '&').replace(/\\"/g, '"')
|
.replace(/&/g, '&').replace(/\\"/g, '"')
|
||||||
.replace(/</g, '<').replace(/>/g, '>')
|
.replace(/</g, '<').replace(/>/g, '>')
|
||||||
.replace(jsonLine, json_library.replacer);
|
.replace(jsonLine, json_library.replacer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
<td>{{ history.msg }}</td>
|
<td>{{ history.msg }}</td>
|
||||||
<td>{{ history.created_on }}</td>
|
<td>{{ history.created_on }}</td>
|
||||||
<td width="6%">
|
<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>
|
Info <i class="fa fa-info"></i>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user