Skip to content

Commit

Permalink
Fix: Spelling mistake of $date['id']; refrences to unlock instead of …
Browse files Browse the repository at this point in the history
…mod; varchar length (#59)

- $date['id'] should be $data['id']
- Fixed references to unlocks in several comments and strings.
- varchar length in the database shows that name and longname in
game_mod is 24 and 48 respectively, updated validator to reflect this.
  • Loading branch information
darth3pio committed Jun 21, 2023
1 parent b8d3276 commit 3d31494
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/ASP/frontend/modules/gamedata/Gamedata.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public function postAddMod()
{
case 'add':
$pdo->insert('game_mod', $data);
$date['id'] = $pdo->lastInsertId('id');
$data['id'] = $pdo->lastInsertId('id');
$data['success'] = true;
$data['mode'] = 'add';
$data['status_badge'] = ($data['authorized']) ? 'success' : 'important';
Expand All @@ -632,4 +632,4 @@ public function postAddMod()
die;
}
}
}
}
64 changes: 32 additions & 32 deletions src/ASP/frontend/modules/gamedata/js/game_mods.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
}

/**
* nameRegex : specifies the characters allowed in an unlock name
* nameRegex : specifies the characters allowed in a mod name
*/
$.validator.addMethod("nameRegex", function(value, element) {
return this.optional(element) || /^[a-z0-9_]+$/i.test(value);
}, "Unlock name must contain only letters, numbers, or underscores.");
}, "Mod name must contain only letters, numbers, or underscores.");

// Data Table
var Table = $(".mws-datatable-fn").DataTable({
Expand All @@ -40,12 +40,12 @@
rules: {
shortName: {
required: true,
maxlength: 32,
maxlength: 24,
nameRegex: true
},
longName: {
required: true,
maxlength: 64
maxlength: 48
}
},
invalidHandler: function (form, validator) {
Expand Down Expand Up @@ -113,7 +113,7 @@
// noinspection JSJQueryEfficiency
$("#mws-validate").ajaxForm({
data: { ajax: true },
beforeSubmit: function ()
beforeSubmit: function ()
{
$('#mws-validate-error').hide();
$('#jui-message').attr('class', 'alert loading').html("Submitting form data...").slideDown(200);
Expand All @@ -124,36 +124,36 @@
// Parse the JSON response
var result = jQuery.parseJSON(response);
if (result.success === true) {
var id = result.id;
var rowNode;

if (result.mode === 'add') {
// Add award to table
//noinspection JSUnresolvedFunction
rowNode = Table.row.add([
result.id,
result.name,
result.longname,
'<span id="status-' + id + '" class="badge badge-' + result.status_badge + '}">' + result.status_text + '</span>',
'<span class="btn-group"> \
<a id="edit-' + id + '" href="#" rel="tooltip" title="Edit Details" class="btn btn-small"><i class="icon-pencil"></i></a> \
</span>'
]).draw().node();

$( rowNode ).attr('id', 'tr-unlock-' + id);
}
else if (result.mode === 'edit') {
selectedRowNode.find('td:eq(0)').html(result.id);
selectedRowNode.find('td:eq(1)').html(result.name);
selectedRowNode.find('td:eq(2)').html(result.longname);
$('span#status-' + id).attr('class', 'badge badge-' + result.status_badge).html(result.status_text);
}

var id = result.id;
var rowNode;
if (result.mode === 'add') {
// Add mod to table
//noinspection JSUnresolvedFunction
rowNode = Table.row.add([
result.id,
result.name,
result.longname,
'<span id="status-' + id + '" class="badge badge-' + result.status_badge + '}">' + result.status_text + '</span>',
'<span class="btn-group"> \
<a id="edit-' + id + '" href="#" rel="tooltip" title="Edit Details" class="btn btn-small"><i class="icon-pencil"></i></a> \
</span>'
]).draw().node();

$(rowNode).attr('id', 'tr-mod-' + id);
}
else if (result.mode === 'edit') {
selectedRowNode.find('td:eq(0)').html(result.id);
selectedRowNode.find('td:eq(1)').html(result.name);
selectedRowNode.find('td:eq(2)').html(result.longname);
$('span#status-' + id).attr('class', 'badge badge-' + result.status_badge).html(result.status_text);
}
// Close dialog
$("#editor-form").dialog("close");
}
else {
$('#jui-message').attr('class', 'alert error').html(result.message);
$('#jui-message').attr('class', 'alert error').html(result.message);
}
},
error: function(request, status, error) {
Expand Down Expand Up @@ -232,4 +232,4 @@

});

}) (jQuery, window, document);
}) (jQuery, window, document);

0 comments on commit 3d31494

Please sign in to comment.