Skip to content

Commit c0fd778

Browse files
author
Siarhei
committed
fix bugs, add Thank feature
1 parent befcb94 commit c0fd778

File tree

5 files changed

+74
-28
lines changed

5 files changed

+74
-28
lines changed

LICENSE.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
Copyright © 2016-2021 Team SWViewer
1+
Copyright © 2016-2022 Team SWViewer
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

55
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8+
9+
Components:<br>
10+
bump.wav: [license / author of original file](https://freesound.org/people/kwahmah_02/sounds/268825/)<br>
11+
message.mp3: [license / author of original file](https://freesound.org/people/elmasmalo1/sounds/377017/)<br>
12+
privateMessage.mp3: [license / author of original file](https://freesound.org/people/rhodesmas/sounds/342749/)<br>
13+
Thumbs up font awesome.svg: [license / author of original file](https://en.wikibooks.org/wiki/File:Thumbs_up_font_awesome.svg)

css/index.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ html, body, .full-screen, #loading {
513513
}
514514
/*-------more control------*/
515515
.more-control {
516-
height: calc(5 * 48px);
516+
height: calc(6 * 48px);
517517
overflow: hidden;
518518
transition: height 200ms ease-in-out;
519519
}

index.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,17 @@ function closePO () {
619619
<div class="secondary-hover custom-lang" ng-click="copyViewHistory()" aria-label="[tooltip-copy-link]" i-tooltip="top-left"><img class="touch-ic secondary-icon custom-lang" src="./img/copy-filled.svg" alt="[img-copy]"></div>
620620
<a class="secondary-hover fs-md custom-lang" href='{{selectedEdit.server_url + "" + selectedEdit.script_path}}/index.php?title={{selectedEdit.title}}&action=history' onclick="toggleMoreControl();" rel='noopener noreferrer' target='_blank'>[diff-mo-vh]</a>
621621
</div>
622-
<div >
623-
<div id="editBtn" class="secondary-hover custom-lang" ng-click="openEditSource();" onclick="openPW('editForm'); closeMoreControl();" aria-label="[tooltip-edit-source]" i-tooltip="top-left">
622+
<div ng-click="doThank();">
623+
<div class="secondary-hover custom-lang" aria-label="[tooltip-thank]" i-tooltip="top-left">
624+
<img class="touch-ic secondary-icon custom-lang" src="./img/thumbs-up-filled.svg" alt="[img-thank]">
625+
</div>
626+
<a class="secondary-hover fs-md custom-lang"><span style="color: var(--tc-secondary);">[diff-mo-thank]</span></a>
627+
</div>
628+
<div ng-click="openEditSource();" onclick="openPW('editForm'); closeMoreControl();">
629+
<div id="editBtn" class="secondary-hover custom-lang" aria-label="[tooltip-edit-source]" i-tooltip="top-left">
624630
<img class="touch-ic secondary-icon custom-lang" src="./img/pencil-filled.svg" alt="[img-edit]">
625631
</div>
626-
<a class="secondary-hover fs-md custom-lang" ng-click="openEditSource();" onclick="openPW('editForm'); closeMoreControl();"><span style="color: var(--tc-secondary);">[diff-mo-es]</span></a>
632+
<a class="secondary-hover fs-md custom-lang"><span style="color: var(--tc-secondary);">[diff-mo-es]</span></a>
627633
</div>
628634
</div>
629635
<!-- Control buttons -->
@@ -640,7 +646,7 @@ function closePO () {
640646
<div id="customRevertBtn" class="secondary-hover custom-lang" ng-click="openCustomRevertPanel();" aria-label="[tooltip-custom-rollback]" i-tooltip="top">
641647
<img class="touch-ic secondary-icon custom-lang" src="./img/custom-rollback-filled.svg" alt="[img-custom-rb]">
642648
</div>
643-
<div id="revert" class="secondary-hover custom-lang" ng-click="doRevert({}, true);" aria-label="[tooltip-rollback]" i-tooltip="top">
649+
<div id="revert" class="secondary-hover custom-lang" ng-click="doRevert({}, true, true);" aria-label="[tooltip-rollback]" i-tooltip="top">
644650
<img class="touch-ic secondary-icon custom-lang" src="./img/rollback-filled.svg" alt="[img-rollback]">
645651
</div>
646652
<div id="back" class="secondary-hover custom-lang" ng-click="Back();" aria-label="[tooltip-last-diff]" i-tooltip="top-left">
@@ -1632,7 +1638,7 @@ function searchMyLogs(actionIndex) {
16321638
openPW('logs');
16331639
}
16341640
</script>
1635-
<script src="js/swv.js?v=7"></script>
1641+
<script src="js/swv.js?v=8"></script>
16361642
<script>
16371643

16381644
/*#########################

js/swv.js

+52-19
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
3232
let configArray = getConfig(edit.wiki);
3333
$scope.selectedEdit.config = configArray[0];
3434
$scope.selectedEdit.customRollbackViaUndoOnly = configArray[1];
35-
3635
$scope.selectedEdit.settings = {
3736
checkWarnDelete: (defaultDeleteList.indexOf(edit.wiki) !== -1)? true: false,
3837
checkWarn: (defaultWarnList.indexOf(edit.wiki) !== -1)? true: false
@@ -62,7 +61,6 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
6261
loadingEdits++;
6362
enableLoadingDiffUI();
6463
loadDiff($scope.selectedEdit);
65-
6664
$scope.sessionActions.diffViewed++;
6765
if ($scope.edits.indexOf(edit) !== -1) $scope.edits.splice($scope.edits.indexOf(edit), 1);
6866
};
@@ -77,10 +75,11 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
7775
edits_history.unshift($scope.getSelectedEdit());
7876
i = i + 1;
7977
}
80-
81-
$scope.setSelectedEdit(edits_history[i]);
82-
loadDiff($scope.selectedEdit);
83-
i = i + 1;
78+
if (edits_history.length-1 >= i && Object.keys(edits_history[i]).length !== 0) {
79+
$scope.setSelectedEdit(edits_history[i]);
80+
loadDiff($scope.selectedEdit, true);
81+
i = i + 1;
82+
}
8483
}
8584

8685
$scope.editColor = function (edit) {
@@ -95,7 +94,6 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
9594
return {color: "pink", display: "flex", 'align-items': 'center'}
9695
} else
9796
return {color: "pink"};
98-
9997
}
10098
if (dirLang === "rtl")
10199
return {display: "flex", 'align-items': 'center'}
@@ -136,6 +134,22 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
136134
diffWindow.focus();
137135
}
138136

137+
// ===> Thank send
138+
$scope.doThank = async function () {
139+
await thank($scope.selectedEdit.server_name, $scope.selectedEdit.new)
140+
.then(() => createNotify({
141+
img: '/img/warning-filled.svg',
142+
title: useLang["thank-success-title"],
143+
content: useLang["thank-success-content"].replace("$1", `[[${$scope.selectedEdit.user}||${$scope.selectedEdit.server_url}/wiki/User:${$scope.selectedEdit.user}]]`),
144+
removable: true
145+
})).catch(err => createNotify({
146+
img: '/img/warning-filled.svg',
147+
title: useLang["thank-fail-title"],
148+
content: "Error 3.1: " + err,
149+
removable: true
150+
}));
151+
}
152+
139153
// ===> Open to edit source.
140154
$scope.openEditSource = async function () {
141155
if (typeof $scope.selectedEdit.new === "undefined") return;
@@ -318,13 +332,14 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
318332
$scope.selectRollbackDescription = function (description) {
319333
if (!description.hasOwnProperty('summary')) return;
320334
if (description.summary === null || description.summary === "") return;
335+
let warnDisabled = false;
321336
if (!($scope.selectedEdit.settings.checkWarn === true &&
322337
$scope.selectedEdit.config.warn !== null &&
323338
typeof description.warn !== "undefined" &&
324-
typeof $scope.selectedEdit.config.warn[description.warn] !== "undefined")) description.warn = null;
325-
339+
typeof $scope.selectedEdit.config.warn[description.warn] !== "undefined"))
340+
warnDisabled = true;
326341
description.withoutSection = description.withoutSection || false;
327-
$scope.doRevert(description);
342+
$scope.doRevert(description, warnDisabled);
328343
}
329344

330345

@@ -362,7 +377,7 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
362377
})).catch(err => createNotify({
363378
img: '/img/warning-filled.svg',
364379
title: useLang["gsr-fail-title"],
365-
content: "Error 3.1: " + err,
380+
content: "Error 3.2: " + err,
366381
removable: true
367382
}));
368383
}
@@ -388,7 +403,7 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
388403
}).catch(err => createNotify({
389404
img: '/img/warning-filled.svg',
390405
title: useLang["warn-fail-title"],
391-
content: 'Error: 3.2' + err,
406+
content: 'Error: 3.3' + err,
392407
removable: true
393408
}));
394409
}
@@ -421,7 +436,7 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
421436
}));
422437
}
423438

424-
$scope.doRevert = function (description = {}, quick = false) {
439+
$scope.doRevert = function (description = {}, warnDisabled, quick = false) {
425440
const SEdit = {...$scope.selectedEdit};
426441
if (SEdit.old == null || isNaN(SEdit.old) === true) return;
427442
var rollbackSummary = "";
@@ -434,7 +449,6 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
434449

435450
RSInput.value = "";
436451
closePO();
437-
438452
isLatestRevision(SEdit.server_url, SEdit.script_path, SEdit.title, SEdit.new)
439453
.then(edit => {
440454
if (!edit.isLatest) return bindLatestRevision(SEdit, edit.revision);
@@ -495,7 +509,7 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
495509
}));
496510

497511
$scope.reqSuccessNotify(rollbackData, SEdit, 'rollback', RBMode);
498-
if (description.warn === null || typeof description.warn === 'undefined') return;
512+
if (description.warn === null || typeof description.warn === 'undefined' || warnDisabled === true) return;
499513
$scope.doWarn(rollbackData, SEdit, description, isMax);
500514
}).catch(err => createNotify({
501515
img: '/img/warning-filled.svg',
@@ -973,6 +987,7 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
973987
dataType: 'text',
974988
success: result =>{
975989
config = JSON.parse(result);
990+
// Object.freeze(config);
976991
startEsenServices();
977992
}
978993
});
@@ -1297,7 +1312,7 @@ angular.module("swv").controller("Queue", function ($scope, $compile, $timeout)
12971312
});
12981313

12991314
// => load diff to view
1300-
async function loadDiff(edit, showAll) {
1315+
async function loadDiff(edit, isHistory = false) {
13011316
disableControl(); closeMoreControl();
13021317
closePW();
13031318
loadDiffDesc(edit);
@@ -1313,7 +1328,7 @@ async function loadDiff(edit, showAll) {
13131328
</body>
13141329
</html>`;
13151330
if (document.getElementById('page').srcdoc.trim() !== loadingHtml.trim()) document.getElementById('page').srcdoc = loadingHtml;
1316-
if (edit.old !== null && (checkMode === 2 || showAll === true)) {
1331+
if (edit.old !== null && checkMode === 2) {
13171332

13181333
await getLastUserRevId(edit.server_url, edit.script_path, edit.title, edit.user, edit.new)
13191334
.then(revId => {
@@ -1330,7 +1345,8 @@ async function loadDiff(edit, showAll) {
13301345
document.getElementById('page').srcdoc = diff.html;
13311346
})
13321347
.catch(err => {
1333-
angular.element(document.getElementById('app')).scope().selectTop();
1348+
if (isHistory) angular.element(document.getElementById('angularapp')).scope().Back();
1349+
else angular.element(document.getElementById('app')).scope().selectTop();
13341350
createDialog({
13351351
parentId: 'angularapp', id: 'diffLoadingErrorDialog',
13361352
title: useLang["error-loading-title"], removable: true,
@@ -1701,7 +1717,6 @@ function firstKey(json) {
17011717
return (Object.keys(json).hasOwnProperty(0)) ? Object.keys(json)[0] : undefined;
17021718
}
17031719

1704-
17051720
// => get first editor of the page.
17061721
function getFirstEditor(serverUrl, scriptPath, wiki, title, user) {
17071722
return new Promise((resolve, reject) => {
@@ -1932,6 +1947,24 @@ function structuredData(str, server) {
19321947
return str;
19331948
}
19341949

1950+
// => thank send
1951+
async function thank(domainURL, revisionID) {
1952+
toggleMoreControl();
1953+
return new Promise((resolve, reject) => {
1954+
$.ajax({
1955+
url: 'php/thank.php',
1956+
type: 'POST',
1957+
crossDomain: true,
1958+
dataType: 'text',
1959+
data: {
1960+
project: domainURL,
1961+
rev: revisionID
1962+
}, success: () => resolve(),
1963+
error: err => reject(err)
1964+
})
1965+
});
1966+
}
1967+
19351968
function escapeXSS(str) {
19361969
if (str === undefined) return 'undefined';
19371970
str = str.replace(/&amp;/g, 'ampersanttempprepswv');

templates/about.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<span class='custom-lang'>[about-frame-cookies-desc]</span>
2424

2525
<p class='custom-lang' style='margin-bottom: 10px; font-weight: bold'>[about-frame-licensing]</p>
26-
Copyright &#169; <a href='https://meta.wikimedia.org/wiki/SWViewer/members' rel='noopener noreferrer' target='_blank'>Team</a> SWViewer, 2016-2021; MIT License<br>
26+
Copyright &#169; <a href='https://meta.wikimedia.org/wiki/SWViewer/members' rel='noopener noreferrer' target='_blank'>Team</a> SWViewer, 2016-2022; MIT License<br>
2727
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
2828

2929
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
@@ -33,6 +33,7 @@
3333
bump.wav: <a class='custom-lang' rel='noopener noreferrer' target='_blank' href='https://freesound.org/people/kwahmah_02/sounds/268825/'>[about-frame-attrib]</a><br>
3434
message.mp3: <a class='custom-lang' rel='noopener noreferrer' target='_blank' href='https://freesound.org/people/elmasmalo1/sounds/377017/'>[about-frame-attrib]</a><br>
3535
privateMessage.mp3: <a class='custom-lang' rel='noopener noreferrer' target='_blank' href='https://freesound.org/people/rhodesmas/sounds/342749/'>[about-frame-attrib]</a><br>
36+
Thumbs up font awesome.svg: <a class='custom-lang' rel='noopener noreferrer' target='_blank' href='https://en.wikibooks.org/wiki/File:Thumbs_up_font_awesome.svg'>[about-frame-attrib]</a><br>
3637

3738
<p class='custom-lang' style='margin-bottom: 10px; font-weight: bold'>[about-frame-translating]</p>
3839
<span id="tw2" class='custom-lang'>[about-frame-translators-tw]</span>

0 commit comments

Comments
 (0)