Skip to content

Commit

Permalink
Merge pull request #25 from CodeforcesContestHelper/dev
Browse files Browse the repository at this point in the history
[!] Fix problem transfer & copy bug
  • Loading branch information
tiger2005 authored Oct 14, 2021
2 parents 4943b72 + 5533d9e commit f922dbb
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 26 deletions.
4 changes: 2 additions & 2 deletions css/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ body{
}
.singleOpenSmallWindow{
cursor: pointer;
right: 20px;
right: 10px;
}
.singleHeadBackProgress {
width: 0px;
Expand All @@ -362,7 +362,7 @@ body{
top: 0px;
left: 0px;
}
.singleHeadBack > span > i{
.singleHeadBack > span > i, .singleOpenSmallWindow > i{
padding: 3px 5px;
}
.blockManager{
Expand Down
2 changes: 1 addition & 1 deletion css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ body{
background: rgb(146, 117, 37);
}
.successColor{
background: #2ace96;
background: #0ba570;
transition: 0.2s;
color: white;
}
Expand Down
14 changes: 10 additions & 4 deletions css/problem/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,13 @@ ul, ol{
border: 1px solid #777;
border-radius: 5px;
padding: 5px;
padding-bottom: 0px;
width: calc(100% - 12px);
height: 100%;
overflow-x: scroll;
font-family: var(--editor-font-family);
font-size: var(--editor-font-size);
white-space: pre-line;
white-space: pre;
}
@media only screen and (max-width: 520px){
.sampleBlock{
Expand Down Expand Up @@ -508,9 +509,6 @@ ul, ol{
font-size: 16px;
text-align: center;
}
.katex-mathml, .vlist-s{
user-select: none;
}
.copyInfo{
margin-left: 10px;
user-select: none;
Expand All @@ -519,6 +517,14 @@ ul, ol{
padding: 2px;
border-radius: 5px;
}
.katex,
.katex-display {
user-select: all;
-moz-user-select: all;
-webkit-user-select: all;
-ms-user-select: all;
}



::-webkit-scrollbar{
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
</div>
<div class="searchPageTip">
<div style="flex: 1; text-align: left">
<div class="searchPageLoadingType contestListLoadIf"></div>
<div class="searchPageLoadingType contestListLoadIf"><span></span></div>
</div>
<div class="searchPagePagesDisplayer">
<div class="searchPagesButton">
Expand Down
52 changes: 36 additions & 16 deletions js/contest.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,28 +132,35 @@ function displayContestListPage(){
, `<span class="red"><span class="fas fa-running"></span> ${localize('contestListRun')}</span>`
, `<span class="green"><span class="fas fa-check"></span> ${localize('contestListEnd')}</span>`];
if((new Date()).getTime() <= x[3] * 1000)
rep[6] = 0;
rep[6] = 0, rep[5] += ` | <span class='dangerColor' style="padding: 0px 5px">${localize('contestPageBeforeStart')}<span class="contestPageCountdown" time="${x[3] * 1000}" style="padding-left: 10px"></span></span>`;
else if((new Date()).getTime() <= (x[3] + x[4]) * 1000)
rep[6] = 1;
rep[6] = 1, rep[5] += ` | <span class='warningColor' style="padding: 0px 5px">${localize('contestPageRunning')}<span class="contestPageCountdown" time="${(x[3] + x[4]) * 1000}" style="padding-left: 10px"></span></span>`;
else
rep[6] = 2;
rep[6] = rtList[rep[6]];
$(".contestSearch .searchPageBottom").append(contestListFormatString.format(rep));
}
$(".contestPageCountdown").each(function(){
var t = Number($(this).attr("time"));
var q = (new Date()).getTime();
if(q > t)
q = t;
$(this).html(getTimeLength2(t - q));
})
}

function loadContestList(){
$(".contestListLoadIf").css("cursor", "default");
$(".contestListLoadIf").unbind("click");
$(".contestListLoadIf").html(`<span class='fas fa-hourglass-half'></span> ` + localize("loading"));
$(".contestListLoadIf > span").css("cursor", "default");
$(".contestListLoadIf > span").unbind("click");
$(".contestListLoadIf > span").html(`<span class='fas fa-hourglass-half'></span> ` + localize("loading"));
$.ajax({
url: settings.codeforcesApiUrl + '/contest.list',
type: "GET",
timeout : settings.largeTimeLimit,
success: function(data){
var _contestAllList = [];
data = data.result;
$(".contestListLoadIf").html(`<span class='fas fa-hourglass-half'></span> ` + localize("loadingAcCount"));
$(".contestListLoadIf > span").html(`<span class='fas fa-hourglass-half'></span> ` + localize("loadingAcCount"));
loadContestPassedStatus(function(){
for(var i=0; i<data.length; i++)
_contestAllList.push([data[i].name, data[i].id, data[i].type, data[i].startTimeSeconds, data[i].durationSeconds]);
Expand All @@ -165,30 +172,31 @@ function loadContestList(){
var y = $(".contestDirectionOption").children().eq(1).hasClass("chosen");
contestListSort(x, y);
displayContestListPage();
$(".contestListLoadIf").html(`<span class='fas fa-check green'></span> ` + localize("success"));
$(".contestListLoadIf").css("cursor", "pointer");
$(".contestListLoadIf").unbind("click").click(function(){
$(".contestListLoadIf > span").html(`<span class='fas fa-check green'></span> ` + localize("success"));
$(".contestListLoadIf > span").css("cursor", "pointer");
$(".contestListLoadIf > span").unbind("click").click(function(){
loadContestList();
})
}, function(){
$(".contestListLoadIf").html(`<span class='fas fa-times red'></span> ` + localize("failed"));
$(".contestListLoadIf").css("cursor", "pointer");
$(".contestListLoadIf").unbind("click").click(function(){
$(".contestListLoadIf > span").html(`<span class='fas fa-times red'></span> ` + localize("failed"));
$(".contestListLoadIf > span").css("cursor", "pointer");
$(".contestListLoadIf > span").unbind("click").click(function(){
loadContestList();
})
})
},
error: function(){
$(".contestListLoadIf").html(`<span class='fas fa-times red'></span> ` + localize("failed"));
$(".contestListLoadIf").css("cursor", "pointer");
$(".contestListLoadIf").unbind("click").click(function(){
$(".contestListLoadIf > span").html(`<span class='fas fa-times red'></span> ` + localize("failed"));
$(".contestListLoadIf > span").css("cursor", "pointer");
$(".contestListLoadIf > span").unbind("click").click(function(){
loadContestList();
})
}
})
}
var ifInitContestPage = false;
$(".NavBarContent").eq(2).click(function(){
displayContestListPage();
if(!contestInSecondPage){
displayContestListPage();
if(!ifInitContestPage)
Expand Down Expand Up @@ -231,4 +239,16 @@ $(".contestSearch .searchPagesButton").eq(3).click(function(){
var l = 1, r = Math.max(1, Math.ceil(contestListSortResult.length / contestPerPage));
contestListCurrentPage = r;
displayContestListPage();
})
})

function reloadContestPageCountdown(){
setTimeout(reloadContestPageCountdown, 500);
$(".contestPageCountdown").each(function(){
var t = Number($(this).attr("time"));
var q = (new Date()).getTime();
if(q > t)
q = t;
$(this).html(getTimeLength2(t - q));
})
}
reloadContestPageCountdown();
213 changes: 213 additions & 0 deletions js/copy-tex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else {
var a = factory();
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})((typeof self !== 'undefined' ? self : this), function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);

// EXTERNAL MODULE: ./contrib/copy-tex/copy-tex.css
var copy_tex = __webpack_require__(0);

// CONCATENATED MODULE: ./contrib/copy-tex/katex2tex.js
// Set these to how you want inline and display math to be delimited.
var defaultCopyDelimiters = {
inline: ['$', '$'],
// alternative: ['\(', '\)']
display: ['$$', '$$'] // alternative: ['\[', '\]']

}; // Replace .katex elements with their TeX source (<annotation> element).
// Modifies fragment in-place. Useful for writing your own 'copy' handler,
// as in copy-tex.js.

var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) {
if (copyDelimiters === void 0) {
copyDelimiters = defaultCopyDelimiters;
}

// Remove .katex-html blocks that are preceded by .katex-mathml blocks
// (which will get replaced below).
var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html');

for (var i = 0; i < katexHtml.length; i++) {
var element = katexHtml[i];

if (element.remove) {
element.remove(null);
} else {
element.parentNode.removeChild(element);
}
} // Replace .katex-mathml elements with their annotation (TeX source)
// descendant, with inline delimiters.


var katexMathml = fragment.querySelectorAll('.katex-mathml');

for (var _i = 0; _i < katexMathml.length; _i++) {
var _element = katexMathml[_i];

var texSource = _element.querySelector('annotation');

if (texSource) {
if (_element.replaceWith) {
_element.replaceWith(texSource);
} else {
_element.parentNode.replaceChild(texSource, _element);
}

texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1];
}
} // Switch display math to display delimiters.


var displays = fragment.querySelectorAll('.katex-display annotation');

for (var _i2 = 0; _i2 < displays.length; _i2++) {
var _element2 = displays[_i2];
_element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1];
}

return fragment;
};
/* harmony default export */ var katex2tex = (katexReplaceWithTex);
// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js
// Global copy handler to modify behavior on .katex elements.

document.addEventListener('copy', function (event) {
var selection = window.getSelection();

if (selection.isCollapsed) {
return; // default action OK if selection is empty
}

var fragment = selection.getRangeAt(0).cloneContents();

if (!fragment.querySelector('.katex-mathml')) {
return; // default action OK if no .katex-mathml elements
} // Preserve usual HTML copy/paste behavior.


var html = [];

for (var i = 0; i < fragment.childNodes.length; i++) {
html.push(fragment.childNodes[i].outerHTML);
}

event.clipboardData.setData('text/html', html.join('')); // Rewrite plain-text version.

event.clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling.

event.preventDefault();
});
// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.webpack.js
/**
* This is the webpack entry point for KaTeX. As ECMAScript doesn't support
* CSS modules natively, a separate entry point is used.
*/



/***/ })
/******/ ])["default"];
});
Loading

0 comments on commit f922dbb

Please sign in to comment.