build: install & jqValidateForm
This commit is contained in:
1 parent
7bc762d357
commit
f6e1b4611e
6 files changed
+7
-215
No files matched your search
+2
-211
@@ -1,211 +1,2 @@
|
||||
/*
|
||||
function showCityGeneral(cityIdx){
|
||||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
function loadScenarioPreview(scenarioIdx){
|
||||
$(function(){
|
||||
reloadWorldMap({
|
||||
clickableAll:true,
|
||||
selectCallback:showCityGeneral,
|
||||
hrefTemplate:'#',
|
||||
neutralView:true,
|
||||
showMe:false,
|
||||
targetJson:'j_get_scenario_map.php?scenarioIdx={0}'.format(scenarioIdx)
|
||||
});
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function loadScenarios() {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: 'j_load_scenarios.php',
|
||||
dataType: 'json'
|
||||
}).then(function(result) {
|
||||
if (!result.result) {
|
||||
var deferred = $.Deferred();
|
||||
deferred.reject('fail');
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
|
||||
var list = {};
|
||||
|
||||
|
||||
$.each(result.scenario, function(idx, value) {
|
||||
var title = value.title || "-";
|
||||
var pat = /【(.*?)[0-9\-_\.a-zA-Z]*】/;
|
||||
var category = pat.exec(title);
|
||||
category = category ? category[1] : '-';
|
||||
|
||||
value.title = title;
|
||||
value.category = category;
|
||||
value.idx = idx;
|
||||
value.year = value.year || 180;
|
||||
|
||||
if (!(category in list)) {
|
||||
list[category] = {};
|
||||
}
|
||||
|
||||
list[category][idx] = value;
|
||||
});
|
||||
|
||||
var $select = $('#scenario_sel');
|
||||
$.each(list, function(category, items) {
|
||||
var $optgroup = $('<optgroup>').attr('label', category);
|
||||
|
||||
$.each(items, function(idx, scenario) {
|
||||
var $option = $('<option>')
|
||||
.data('scenario', scenario)
|
||||
.val(idx)
|
||||
.html(scenario.title);
|
||||
$optgroup.append($option);
|
||||
});
|
||||
|
||||
$select.append($optgroup);
|
||||
});
|
||||
|
||||
$select.val(0);
|
||||
$select.change();
|
||||
});
|
||||
}
|
||||
|
||||
function scenarioPreview() {
|
||||
var $select = $(this);
|
||||
var $option = $select.find('option:selected');
|
||||
|
||||
var $year = $('#scenario_begin');
|
||||
var $npc = $('#scenario_npc');
|
||||
var $npcEx = $('#scenario_npc_extend');
|
||||
var $nation = $('#scenario_nation');
|
||||
|
||||
var scenario = $option.data('scenario');
|
||||
console.log(scenario.idx, scenario.title);
|
||||
|
||||
$year.html('{0}년'.format(scenario.year));
|
||||
$npc.html('{0}명'.format(scenario.npc_cnt));
|
||||
if (scenario.npcEx_cnt == 0) {
|
||||
$npcEx.html('');
|
||||
} else {
|
||||
$npcEx.html('+{0}명'.format(scenario.npcEx_cnt));
|
||||
}
|
||||
|
||||
$nation.html('');
|
||||
$.each(scenario.nation, function(idx, nation) {
|
||||
$nation.append('<span style="color:{0}">{1}</span> {2}명. {3}<br>'.format(
|
||||
nation.color, nation.name, nation.generals, nation.cities.join(', ')
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
function formSetup() {
|
||||
$.validator.addMethod("autorun_user", function(value, element) {
|
||||
var parent = $(element).parent('.input-group');
|
||||
var checkCnt = parent.find('input:checked').length;
|
||||
if (value <= 0) {
|
||||
if (checkCnt > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (checkCnt == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, "유효 시간과 옵션은 동시에 설정해야합니다.");
|
||||
$('#game_form').validate({
|
||||
rules: {
|
||||
turnterm: "required",
|
||||
sync: "required",
|
||||
scenario: "required",
|
||||
fiction: "required",
|
||||
extend: "required",
|
||||
npcmode: "required",
|
||||
show_img_level: "required",
|
||||
tournament_trig: "required",
|
||||
join_mode: 'required',
|
||||
autorun_user_minutes: { required: true, autorun_user: true, min: 0 }
|
||||
},
|
||||
errorElement: "div",
|
||||
errorPlacement: function(error, element) {
|
||||
// Add the `help-block` class to the error element
|
||||
error.addClass("invalid-feedback");
|
||||
|
||||
if (element.prop("type") === "checkbox") {
|
||||
error.insertAfter(element.parent("label"));
|
||||
} else {
|
||||
error.insertAfter(element);
|
||||
}
|
||||
},
|
||||
highlight: function(element, errorClass, validClass) {
|
||||
$(element).addClass("is-invalid").removeClass("is-valid");
|
||||
},
|
||||
unhighlight: function(element, errorClass, validClass) {
|
||||
$(element).addClass("is-valid").removeClass("is-invalid");
|
||||
}
|
||||
});
|
||||
$('#game_form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
if (!$("#game_form").valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var autorun_user_minutes = parseInt($('#autorun_user_minutes').val());
|
||||
var autorun_user = [];
|
||||
if (autorun_user_minutes > 0) {
|
||||
$('.autorun_user_chk:checked').each(function() {
|
||||
autorun_user.push($(this).data('key'));
|
||||
});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: 'post',
|
||||
url: 'j_install.php',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
turnterm: $('#turnterm input:radio:checked').val(),
|
||||
sync: $('#sync input:radio:checked').val(),
|
||||
scenario: $('#scenario_sel').val(),
|
||||
fiction: $('#fiction input:radio:checked').val(),
|
||||
extend: $('#extend input:radio:checked').val(),
|
||||
block_general_create: $('#block_general_create input:radio:checked').val(),
|
||||
npcmode: $('#npcmode input:radio:checked').val(),
|
||||
show_img_level: $('#show_img_level input:radio:checked').val(),
|
||||
tournament_trig: $('#tournament_trig input:radio:checked').val(),
|
||||
reserve_open: $('#reserve_open').val(),
|
||||
pre_reserve_open: $('#pre_reserve_open').val(),
|
||||
join_mode: $('#join_mode input:radio:checked').val(),
|
||||
autorun_user_minutes: autorun_user_minutes,
|
||||
autorun_user: autorun_user
|
||||
}
|
||||
}).then(function(result) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
if (!result.result) {
|
||||
alert(result.reason);
|
||||
deferred.reject('fail');
|
||||
} else {
|
||||
alert('게임이 리셋되었습니다.');
|
||||
deferred.resolve();
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
}).then(function() {
|
||||
location.href = '..';
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
loadScenarios();
|
||||
$('#scenario_sel').change(scenarioPreview);
|
||||
formSetup();
|
||||
})
|
||||
(()=>{"use strict";var e,r={609:(e,r,t)=>{t(5666),t(9826),t(2222),t(1058),t(603),t(4916),t(9714),t(1539),t(8674),t(9720),t(2526),t(1817),t(2165),t(6992),t(8783),t(3948),t(7042),t(1038),t(7941),t(7327),t(5003),t(4747),t(9337);var n=t(9755),a=t.n(n),o=(t(3734),t(9669)),i=t.n(o),u=t(1469),l=t.n(u),c=(t(1532),t(3123),t(5715)),s=t(7037),f=t.n(s);function p(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function d(e){var r,t={},n=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return p(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?p(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw o}}}}(e);try{for(n.s();!(r=n.n()).done;){var a=r.value,o=a.name,i=a.value;if(!f()(o))throw new TypeError(Line truncated
|
||||
//# sourceMappingURL=install.js.map
|
||||
Reference in new issue
Block a user