Skip to content

Commit 45f484e

Browse files
committed
Code refactorings (mostly JavaScript fixes)
1 parent d8a3d0c commit 45f484e

File tree

4 files changed

+35
-36
lines changed

4 files changed

+35
-36
lines changed

Open Judge System/Web/OJS.Web/Areas/Contests/Views/Compete/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@
102102
</text>
103103
}
104104
</script>
105-
}
105+
}

Open Judge System/Web/OJS.Web/Scripts/Contests/list-categories-page.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ function CategoryExpander() {
66

77
var self;
88

9-
var init = function (treeView, treeViewSelector) {
9+
var init = function(treeView, treeViewSelector) {
1010
treeview = treeView;
1111
treeviewSelector = treeViewSelector;
1212
self = this;
13-
}
13+
};
1414

1515
function onDataBound() {
1616
var categoryId;
@@ -35,7 +35,7 @@ function CategoryExpander() {
3535
}
3636
}
3737

38-
var categorySelected = function (e) {
38+
var categorySelected = function(e) {
3939
$("#contestsList").html("");
4040
$("#contestsList").addClass("k-loading");
4141

@@ -66,54 +66,54 @@ function CategoryExpander() {
6666
}
6767

6868
var ajaxUrl = "/Contests/List/ByCategory/" + elementId;
69-
$("#contestsList").load(ajaxUrl, function () {
69+
$("#contestsList").load(ajaxUrl, function() {
7070
$("#contestsList").removeClass("k-loading");
7171
});
72-
}
72+
};
7373

74-
var setNestingData = function (categoriesArray) {
74+
var setNestingData = function(categoriesArray) {
7575
if (categoriesArray) {
7676
data = categoriesArray;
7777
}
78-
}
78+
};
7979

80-
var expandSubcategories = function () {
80+
var expandSubcategories = function() {
8181
for (var i = 0; i < data.length; i++) {
8282
var id = data[i];
8383
self.select(id);
8484
}
85-
}
85+
};
8686

87-
var select = function (id) {
87+
var select = function(id) {
8888
currentlySelectedId = id;
89-
89+
9090
var el = treeview.dataSource.get(id);
9191
if (!el && data.indexOf(id) < 0) {
9292
var parentsUrl = "/Contests/List/GetParents/" + id;
9393

9494
$.ajax({
9595
url: parentsUrl,
96-
success: function (data) {
96+
success: function(data) {
9797
self.setNestingData(data);
9898
self.expandSubcategories();
9999
}
100100
});
101101
} else if (el) {
102102
var element = treeviewSelector.find('[data-uid=' + el.uid + ']');
103-
103+
104104
var elementObj = {
105105
elementId: id
106-
}
106+
};
107107

108108
treeview.trigger('select', elementObj);
109109
treeview.expand(element);
110110
treeview.select(element);
111111
}
112-
}
112+
};
113113

114-
var currentId = function () {
114+
var currentId = function() {
115115
return currentlySelectedId;
116-
}
116+
};
117117

118118
return {
119119
expandSubcategories: expandSubcategories,
@@ -134,8 +134,8 @@ function getCategoryIdFromHash() {
134134

135135
var expander = new CategoryExpander();
136136

137-
$(document).ready(function () {
138-
$(window).on("hashchange", function (ev) {
137+
$(document).ready(function() {
138+
$(window).on("hashchange", function() {
139139
var categoryId = getCategoryIdFromHash();
140140
if (expander && categoryId !== expander.currentId()) {
141141
expander.select(categoryId);
@@ -145,4 +145,4 @@ $(document).ready(function () {
145145
var treeviewSelector = $("#contestsCategories");
146146
var treeview = treeviewSelector.data("kendoTreeView");
147147
expander.init(treeview, treeviewSelector);
148-
})
148+
});

Open Judge System/Web/OJS.Web/Scripts/Contests/submission-page.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
function Notifier() {
5353
function showMessage(data) {
54-
container = $("div[id^='notify-container']").filter(':visible');
54+
var container = $("div[id^='notify-container']").filter(':visible');
5555

5656
var notification = $('<div/>', {
5757
text: data.message,
@@ -101,7 +101,7 @@ function Notifier() {
101101
showMessage: showMessage,
102102
notifySuccess: notifySuccess,
103103
notifyFailure: notifyFailure
104-
}
104+
};
105105
}
106106

107107
// update the code mirror textarea to display the submission content - not used
@@ -122,12 +122,12 @@ function getCodeMirrorInstance() {
122122
return codeMirrorInstance;
123123
}
124124

125-
var displayMaximumValues = function (maxMemory, maxTime, memoryString, timeString) {
125+
var displayMaximumValues = function(maxMemory, maxTime, memoryString, timeString) {
126126
var memoryInMb = (maxMemory / 1024 / 1024).toFixed(2);
127127
var maxTimeInSeconds = (maxTime / 1000).toFixed(3);
128128
var result = memoryString + ": " + memoryInMb + " MB <br />" + timeString + ": " + maxTimeInSeconds + " s";
129129
return result;
130-
}
130+
};
131131

132132
// validate the submission content
133133
function validateSubmissionContent() {
@@ -149,7 +149,7 @@ function validateSubmissionContent() {
149149
var messageNotifier = new Notifier();
150150

151151
// validate the submission time
152-
var submissionTimeValidator = function () {
152+
var submissionTimeValidator = function() {
153153
var lastSubmissionTime;
154154
var currentServerTime;
155155

@@ -161,12 +161,11 @@ var submissionTimeValidator = function () {
161161

162162
if (!currentServerTime) {
163163
currentServerTime = serverTime;
164-
setInterval(function () {
164+
setInterval(function() {
165165
currentServerTime = new Date(currentServerTime.getTime() + 1000);
166-
}, 1000)
166+
}, 1000);
167167
}
168168

169-
var limitBetweenSubmissions = limitBetweenSubmissions;
170169
var currentTime = currentServerTime;
171170
var secondsForLastSubmission = (currentTime - lastSubmissionTime) / 1000;
172171

@@ -192,8 +191,8 @@ var submissionTimeValidator = function () {
192191

193192
return {
194193
validate: validate
195-
}
196-
}
194+
};
195+
};
197196

198197
var tabStripManager = new TabStripManager();
199198

@@ -264,15 +263,15 @@ function TabStripManager() {
264263
onContentLoad: onContentLoad,
265264
currentIndex: currentIndex,
266265
init: init
267-
}
266+
};
268267
}
269268

270269
function getSelectedIndexFromHashtag() {
271270
return parseInt(window.location.hash.substr(1));
272271
}
273272

274-
$(document).ready(function () {
275-
$(window).on("hashchange", function (ev) {
273+
$(document).ready(function() {
274+
$(window).on("hashchange", function() {
276275
var hashIndex = getSelectedIndexFromHashtag();
277276
if (hashIndex !== tabStripManager.currentIndex()) {
278277
tabStripManager.selectTabWithIndex(hashIndex);

Open Judge System/Workers/OJS.Workers.Compilers/MsBuildCompiler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public override string BuildCompilerArguments(string inputFile, string outputFil
6464

6565
private static void UnzipFile(string fileToUnzip, string outputDirectory)
6666
{
67-
using (ZipFile zip1 = ZipFile.Read(fileToUnzip))
67+
using (var zipFile = ZipFile.Read(fileToUnzip))
6868
{
69-
foreach (ZipEntry entry in zip1)
69+
foreach (var entry in zipFile)
7070
{
7171
entry.Extract(outputDirectory, ExtractExistingFileAction.OverwriteSilently);
7272
}

0 commit comments

Comments
 (0)