Toggle navigation
P3X GitList Snapshot
GitHub
Repo
Changelog
To do
Releases
Themes
Change log
Loading change log ...
To do ...
Loading todo ...
browsing:
5f0744c48f5b6bacef2eab4339f439e9107a4bb1
Branches
master
Tags
v2024.4.105
v2023.10.119
v2023.10.102
v2022.4.106
v2021.10.211
v2021.10.198
v2021.10.197
v2021.10.195
v2021.10.194
v2021.10.191
v2021.10.189
v2021.10.183
v2021.10.161
v2021.10.152
v2021.10.146
v2021.10.143
v2021.4.102
v2020.10.189
v2020.10.187
v2020.10.185
v2020.10.182
v2020.10.170
v2020.10.138
v2020.10.136
v2020.10.104
v2020.10.102
v2020.4.218
v2020.4.210
v2020.4.188
v2020.4.185
v2020.4.146
v2020.4.144
v2020.4.126
v2020.4.125
v2020.4.123
v2020.4.117
v2020.4.116
v2020.4.114
v2020.4.111
v2020.4.107
v2020.4.105
v2020.4.103
v2019.10.154
v2019.10.146
v2019.10.114
v2019.10.111
v2019.10.109
v2019.4.128
v2019.4.124
v2019.4.121
v2019.4.119
v2019.4.116
v2019.4.113
v2019.4.108
v2019.4.107
v2019.4.106
v2019.4.104
v2019.4.102
v2019.4.22
v2019.4.21
v2019.4.19
v2019.4.16
v2019.2.9-0
v2019.1.23-7
v2019.1.23-0
v2019.1.19-3
v2019.1.1-16
v2019.1.1-15
v2019.1.1-13
v2019.1.1-11
v2019.1.1-6
v2014.4.16
v2014.4.14
v1.1.18-573
p3x-gitlist-2.8.25-822
2019.4.8
2019.1.15-0
2019.1.12-3
2019.1.12-1
2019.1.10-5
2019.1.1-2
2018.12.31-3
2018.12.30-1
2018.12.22-6
2018.12.21-8
2018.12.21-7
2018.12.21-2
2018.12.14-3
2018.12.14-1
2018.12.14-0
2018.12.13-4
2018.12.13-3
2018.12.13-1
2018.12.13-0
2018.11.24-2
2018.11.19-0
2018.11.15-3
2018.11.15-1
2018.10.8-1
2018.9.20-0
2.12.10-1046
2.12.6-1040
2.12.4-1038
2.11.14-1031
2.10.83-1014
2.9.13-892
2.9.8-888
2.9.6-887
2.9.4-886
2.9.2-883
2.9.1-882
2.8.56-862
2.8.52-855
2.8.48-849
2.8.27-829
2.8.23-822
2.8.7-806
2.8.2-803
2.8.0
2.7.78-794
2.7.19-757
2.7.17-754
2.7.12-750
2.7.8-749
2.7.5-743
2.7.4-742
2.6.2-721
2.5.22-696
2.5.19-684
2.5.7-668
2.1.7-643
2.0.38-619
2.0.37-616
2.0.35-613
2.0.33-609
2.0.31-604
2.0.27-600
2.0.26-598
2.0.25-598
2.0.17-593
2.0.15-589
2.0.12-585
2.0.4-579
1.1.14
1.1.13
1.1.12
1.1.11
1.1.10
1.1.9
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4-rc.3
1.0.4-rc.2
1.0.4-rc.1
1.0.3
1.0.2
1.0.1
1.0.0
0.5.6
0.5.5
0.5.4
0.5.0
0.4.0
0.3
0.2
0.1
Files
Commits
Log
Graph
Stats
gitlist.git
src
browser
js
file.js
RSS
Git
Fetch origin
Download
ZIP
TAR
Clone
Raw
View
History
Clone
SSH
HTTPS
Blames found: 129
Mode: javascript
Binary: false
Hang on, we reloading big blames...
acb728d8
$(function() {
45980021
180837f0
const Cookies = require('js-cookie') const errorHandler = window.gitlist.ajaxErrorHandler;
d965056a
const gitHelperAjax = window.gitlist.gitHelperAjax;
180837f0
const $modalDelete = $('#p3x-gitlist-modal-delete')
1c39cec1
if ($modalDelete.length === 0 ) { return; }
180837f0
const $buttonDelete = $('#p3x-gitlist-file-delete') const $buttonDeleteSure = $('#p3x-gitlist-modal-delete-confirm') const $formDeleteForm = $('#p3x-gitlist-modal-delete-form') const $deleteInputName = $('#p3x-gitlist-modal-delete-name'); const $deleteInputEmail = $('#p3x-gitlist-modal-delete-email'); const $deleteInputComment = $('#p3x-gitlist-modal-delete-comment'); const inputs = { name: $deleteInputName, email: $deleteInputEmail, comment: $deleteInputComment, }
30923e92
180837f0
$buttonDelete.click(() => {
30923e92
if (!window.gitlist.changeableCommit()) {
180837f0
return } $modalDelete.modal('show') })
1c39cec1
$formDeleteForm[0].addEventListener('submit', async(ev) => { ev.preventDefault();
180837f0
if($formDeleteForm[0].checkValidity() === false) {
30923e92
window.gitlist.invalidSnackbarCommit()
180837f0
return; } try {
d965056a
180837f0
const json = await gitHelperAjax({ modal: $modalDelete, action: 'delete', inputs: inputs,
d965056a
180837f0
})
d965056a
if (window.gitlist.gitNewPush(json)) { return }
180837f0
} catch(e) { errorHandler(e) } })
d480ad94
const sourceCode = $('#p3x-gitlist-file-editor');
45980021
if (sourceCode.length) {
dd5784c6
let originalCode = '';
4af1308b
let disableFull = false;
cf5d41c4
const cookieName = 'p3x-gitlist-codemirror-size' const currentSizing = Cookies.get(cookieName)
1c39cec1
const $codeCodeMirroNormal = $('#p3x-gitlist-file-codemirror'); const $codeCodeMirrorBig = $('#p3x-gitlist-file-codemirror-exceeded')
acb728d8
let value = sourceCode.text();
4af1308b
const maxSize = window.gitlist.codemirror_full_limit;
745faa04
const size = Math.ceil(value.length / 1024);
180837f0
let cm;
312f2829
const createCodeMirror = () => {
4af1308b
if (size > maxSize) { disableFull = true;
1c39cec1
$codeCodeMirroNormal.hide(); $codeCodeMirrorBig.show();
4af1308b
} else {
1c39cec1
$codeCodeMirroNormal.show();
4af1308b
}
312f2829
const mode = sourceCode.attr('language'); const pre = sourceCode.get(0);
c3ed23e3
1c39cec1
const $codeMirror = $('.CodeMirror'); const $buttonScroll = $('#p3x-gitlist-file-button-scroll'); const $buttonFull = $('#p3x-gitlist-file-button-full'); const $buttonEdit = $('#p3x-gitlist-file-button-edit'); const $buttonEditCancel = $('#p3x-gitlist-file-button-edit-cancel'); const $buttonEditSave = $('#p3x-gitlist-file-button-edit-save') const $buttonDelete = $('#p3x-gitlist-file-delete')
e2fdc503
const codeMirrorHeight = window.gitlist.editorMaxHeight;
c3ed23e3
1c39cec1
$buttonEditCancel.hide(); $buttonEditSave.hide();
dd5784c6
1c39cec1
$buttonEdit.click(() => {
acb728d8
30923e92
if (!window.gitlist.changeableCommit()) {
180837f0
return
acb728d8
}
dd5784c6
// buttonEditRow.show();
1c39cec1
$buttonEdit.hide(); $buttonDelete.hide() $buttonEditCancel.show(); $buttonEditSave.show();
dd5784c6
gitlist.viewer.setOption('readOnly', false) originalCode = gitlist.viewer.getValue() gitlist.viewer.focus(); $.snackbar({
acb728d8
content: `Editing`,
dd5784c6
}) })
e8d5bddc
const validateCodeIsSame = (snack = true) => { value = gitlist.viewer.getValue(); if (originalCode === value) { if (snack) { $.snackbar({ content: 'The code has not changed. No saving.', }) } return true; } return false; } const close = () => {
1c39cec1
$buttonDelete.show() $buttonEdit.show(); $buttonEditSave.hide(); $buttonEditCancel.hide();
dd5784c6
gitlist.viewer.setOption('readOnly', true)
e8d5bddc
}
1c39cec1
$buttonEditCancel.click(() => {
e8d5bddc
if (!validateCodeIsSame(false)) { gitlist.viewer.setValue(originalCode) $.snackbar({ htmlAllowed: true, content: 'The changes are reverted.', }) } close();
dd5784c6
})
acb728d8
1c39cec1
const $commitModal = $('#p3x-gitlist-modal-commit'); $buttonEditSave.click(async () => {
acb728d8
if (validateCodeIsSame()) { return; }
1c39cec1
$commitModal.modal('show')
acb728d8
})
1c39cec1
const $commitInputName = $('#p3x-gitlist-modal-commit-name'); const $commitInputEmail = $('#p3x-gitlist-modal-commit-email'); const $commitInputComment = $('#p3x-gitlist-modal-commit-comment'); const $commitForm = $('#p3x-gitlist-modal-commit-form');
acb728d8
const inputs = {
1c39cec1
name: $commitInputName, email: $commitInputEmail, comment: $commitInputComment,
acb728d8
}
1c39cec1
//const $commitCommitPushButton = $('#p3x-gitlist-modal-commit-push')
acb728d8
1c39cec1
$commitForm[0].addEventListener('submit', async(ev) => { ev.preventDefault();
acb728d8
if (validateCodeIsSame()) { return; }
1c39cec1
if($commitForm[0].checkValidity() === false) {
30923e92
window.gitlist.invalidSnackbarCommit()
acb728d8
return; }
497e0e06
/*
acb728d8
$.snackbar({ htmlAllowed: true, content: ' <i class="fas fa-cog fa-spin"></i> Saving ...' })
497e0e06
*/
acb728d8
try {
180837f0
await gitHelperAjax({
1c39cec1
modal: $commitModal,
180837f0
action: 'save', inputs: inputs,
d965056a
data: { value: value },
acb728d8
})
180837f0
originalCode = value; close(); $.snackbar({ htmlAllowed: true, content: '<i class="fas fa-check"></i> The file is saved.', })
acb728d8
} catch(e) { errorHandler(e); }
dd5784c6
})
312f2829
const setScroll = () => {
1c39cec1
$buttonFull.removeClass('active') $buttonScroll.addClass('active') $codeMirror.css('height', codeMirrorHeight)
312f2829
gitlist.viewer.setSize(null, codeMirrorHeight);
4af1308b
if (!disableFull) { Cookies.set(cookieName, 'scroll', window.gitlist.cookieSettings) }
312f2829
}
1c39cec1
$buttonScroll.click(setScroll)
df0c8f11
312f2829
const setFull = () => {
1c39cec1
$buttonScroll.removeClass('active') $buttonFull.addClass('active') $codeMirror.css('height', 'auto')
4af1308b
gitlist.viewer.setSize(null, '100%'); Cookies.set(cookieName, 'full', window.gitlist.cookieSettings)
312f2829
}
c3ed23e3
1c39cec1
$buttonFull.click(setFull)
180837f0
cm = CodeMirror(function(elt) {
312f2829
pre.parentNode.replaceChild(elt, pre); }, {
acb728d8
styleActiveLine: true, styleSelectedText: true,
312f2829
value: value, lineNumbers: true, matchBrackets: true, lineWrapping: true, readOnly: true, mode: mode, theme: window.gitlist.getActualThemeCodemirror(), });
acb728d8
gitlist.viewer = cm; const isReallyFull = currentSizing === 'full' && !disableFull; if (isReallyFull) {
312f2829
setFull() } else { setScroll() }
dd5784c6
acb728d8
const scrollToEditor = () => {
27d987a8
let line = location.hash.startsWith('#L') ? location.hash.substring(2) : undefined
acb728d8
if (line !== undefined) { setTimeout(() => {
27d987a8
line = parseInt(line) cm.setSelection({ line: line - 1 , char: 0, }, { line: line - 1, char: Number.MAX_SAFE_INTEGER })
acb728d8
cm.scrollIntoView({line: line, char:0}, isReallyFull ? window.innerHeight / 2 : 100)
1008d646
/* const codes = $('.CodeMirror-linenumber') for(let codeLinenumber of codes) { const $codeLinenumber = $(codeLinenumber) const findLine = $codeLinenumber.text(); if(findLine === line ) { break; } } */
acb728d8
}, 250) } }
1c3c1f07
if (location.search.includes('edit=1')) { setTimeout(() => {
1c39cec1
$buttonEdit.click();
acb728d8
scrollToEditor();
1c3c1f07
}, 500)
acb728d8
} else { scrollToEditor();
1c3c1f07
}
df0c8f11
}
4af1308b
createCodeMirror();
df0c8f11
180837f0
const $showSvgButton = $('#p3x-gitlist-file-svg-show') if ($showSvgButton.length > 0) { const $svgElements = $('.p3x-gitlist-file-svg-toggle') const $cmWrapper = $(cm.getWrapperElement()) const $svgContentWrapper = $('#p3x-gitlist-file-svg-content') $showSvgButton.click(() => { if ($showSvgButton.hasClass('active')) { $svgContentWrapper.empty() } else { const image = `<img class="p3x-gitlist-max-width" src="data:image/svg+xml;base64,${btoa(cm.getValue())}"/>` // console.log(image) $svgContentWrapper.append(image) } $showSvgButton.toggleClass('active') $svgElements.toggle() $cmWrapper.toggle() }) }
45980021
}
1c3c1f07
45980021
})