Skip to content

Commit

Permalink
1.1.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
JetSimon committed May 13, 2023
1 parent 97554ef commit 147ba37
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
10 changes: 8 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Changelog

## 1.1.0

- Added warning on import if duplicate PKs are found (Thanks Astro!)
- Changed the state issue score issue pk to be a dropdown menu

## 1.0.9

- Fix horrible bug where question/answer fields would be reset upon adding!
- Fixed horrible bug where question/answer fields would be reset upon adding!

## 1.0.8

- Change questions to use Map instead to preserve question ordering
- Changed questions to use Map instead to preserve question ordering

## 1.0.7

- Added CYOA supprt
- CYOA support does not import CYOA data from existing mods, only those made with Jet's TCT Mod Tool

## 1.0.6

- Added ability to add/delete questions!
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
</div>

<div class="bg-blue-400 w-full drop-shadow-md mx-auto text-center text-white font-italic py-10">Made by <a class="hover:text-gray-200" href="https://jetsimon.com/">Jet Simon</a> | Version 1.0.9 | <a class="hover:text-gray-200" href="./changelog.md">Changelog</a> | <a class="hover:text-gray-200" href="https://github.com/JetSimon/Jets-The-Campaign-Trail-Mod-Tool-Website">Github Repo</a></div>
<div class="bg-blue-400 w-full drop-shadow-md mx-auto text-center text-white font-italic py-10">Made by <a class="hover:text-gray-200" href="https://jetsimon.com/">Jet Simon</a> | Version 1.1.0 | <a class="hover:text-gray-200" href="./changelog.md">Changelog</a> | <a class="hover:text-gray-200" href="https://github.com/JetSimon/Jets-The-Campaign-Trail-Mod-Tool-Website">Github Repo</a></div>
<script src="js/base.js"></script>
<script src="js/components.js"></script>
</body>
Expand Down
61 changes: 61 additions & 0 deletions js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,34 @@ function loadDataFromFile(raw_json) {

states_json = extractJSON(raw_json, "campaignTrail_temp.states_json = JSON.parse(", ");", "campaignTrail_temp.states_json = [", "]")
states_json.forEach(state => {

if(state["pk"] in states) {
alert(`WARNING: Found duplicate pk ${state["pk"]} in states already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, state["pk"])
states[state["pk"]] = state
});

questions_json = extractJSON(raw_json, "campaignTrail_temp.questions_json = JSON.parse(", ");", "campaignTrail_temp.questions_json = [", "]");
questions_json.forEach(question => {

if(question["pk"] in questions) {
alert(`WARNING: Found duplicate pk ${question["pk"]} in questions already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, question["pk"]);
question['fields']['description'] = question['fields']['description'].replaceAll("’", "'").replaceAll("—", "—");
questions.set(question.pk, question);
});

answers_json = extractJSON(raw_json, "campaignTrail_temp.answers_json = JSON.parse(", ");", "campaignTrail_temp.answers_json = [", "]");
answers_json.forEach(answer => {

if(answer["pk"] in answers) {
alert(`WARNING: Found duplicate pk ${answer["pk"]} in answers already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, answer["pk"]);
answer['fields']['description'] = answer['fields']['description'].replaceAll("’", "'").replaceAll("—", "—");
key = answer["pk"];
Expand All @@ -295,6 +310,11 @@ function loadDataFromFile(raw_json) {

answer_feedbacks_json = extractJSON(raw_json, "campaignTrail_temp.answer_feedback_json = JSON.parse(", ");", "campaignTrail_temp.answer_feedback_json = [", "]");
answer_feedbacks_json.forEach(feedback => {

if(feedback["pk"] in feedbacks) {
alert(`WARNING: Found duplicate pk ${feedback["pk"]} in feedbacks already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, feedback["pk"]);
feedback['fields']['answer_feedback'] = feedback['fields']['answer_feedback'].replaceAll("’", "'").replaceAll("—", "—");
key = feedback['pk'];
Expand All @@ -303,55 +323,96 @@ function loadDataFromFile(raw_json) {

answer_score_globals_json = extractJSON(raw_json, "campaignTrail_temp.answer_score_global_json = JSON.parse(", ");", "campaignTrail_temp.answer_score_global_json = [", "]");
answer_score_globals_json.forEach(x => {

if(x["pk"] in answer_score_globals) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in answer_score_globals already, make sure there are no duplicate PKs in your file before importing`)
}


highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
answer_score_globals[key] = x;
});

answer_score_issues_json = extractJSON(raw_json, "campaignTrail_temp.answer_score_issue_json = JSON.parse(", ");", "campaignTrail_temp.answer_score_issue_json = [", "]");
answer_score_issues_json.forEach(x => {

if(x["pk"] in answer_score_issues) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in answer_score_issues already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
answer_score_issues[key] = x;
});

answer_score_states_json = extractJSON(raw_json, "campaignTrail_temp.answer_score_state_json = JSON.parse(", ");", "campaignTrail_temp.answer_score_state_json = [", "]");
answer_score_states_json.forEach(x => {

if(x["pk"] in answer_score_states) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in answer_score_states already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
answer_score_states[key] = x;
});

candidate_issue_scores_json = extractJSON(raw_json, "campaignTrail_temp.candidate_issue_score_json = JSON.parse(", ");", "campaignTrail_temp.candidate_issue_score_json = [", "]");
candidate_issue_scores_json.forEach(x => {

if(x["pk"] in candidate_issue_scores) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in candidate_issue_scores already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
candidate_issue_scores[key] = x;
});

candidate_state_multipliers_json = extractJSON(raw_json, "campaignTrail_temp.candidate_state_multiplier_json = JSON.parse(", ");", "campaignTrail_temp.candidate_state_multiplier_json = [", "]");
candidate_state_multipliers_json.forEach(x => {

if(x["pk"] in candidate_state_multipliers) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in candidate_state_multipliers already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
candidate_state_multipliers[key] = x;
});

running_mate_issue_scores_json = extractJSON(raw_json, "campaignTrail_temp.running_mate_issue_score_json = JSON.parse(", ");", "campaignTrail_temp.running_mate_issue_score_json = [", "]");
running_mate_issue_scores_json.forEach(x => {

if(x["pk"] in running_mate_issue_scores) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in running_mate_issue_scores already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
running_mate_issue_scores[key] = x;
});

state_issue_scores_json = extractJSON(raw_json, "campaignTrail_temp.state_issue_score_json = JSON.parse(", ");", "campaignTrail_temp.state_issue_score_json = [", "]");
state_issue_scores_json.forEach(x => {

if(x["pk"] in state_issue_scores) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in state_issue_scores already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
state_issue_scores[key] = x;
});

issues_json = extractJSON(raw_json, "campaignTrail_temp.issues_json = JSON.parse(", ");", "campaignTrail_temp.issues_json = [", "]");
issues_json.forEach(x => {

if(x["pk"] in issues) {
alert(`WARNING: Found duplicate pk ${x["pk"]} in issues already, make sure there are no duplicate PKs in your file before importing`)
}

highest_pk = Math.max(highest_pk, x["pk"]);
key = x['pk'];
issues[key] = x;
Expand Down
14 changes: 11 additions & 3 deletions js/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,9 @@ Vue.component('state-issue-score', {
<h1 class="font-bold">STATE ISSUE SCORE PK {{this.pk}}</h1><br>
<label for="issue">Issue PK</label><br>
<input @input="onInput($event)" :value="issue" name="issue" type="text"><br>
<select @change="onInput($event)" name="issue">
<option v-for="issue in issues" :selected="issue.pk == currentIssue" :value="issue.pk" :key="issue.pk">{{issue.pk}} - {{issue.fields.name}}</option>
</select><br>
<label for="state_issue_score">State Issue Score</label><br>
<input @input="onInput($event)" :value="stateIssueScore" name="state_issue_score" type="text"><br>
Expand All @@ -924,11 +926,17 @@ Vue.component('state-issue-score', {
methods: {
onInput: function(evt) {
Vue.prototype.$TCT.state_issue_scores[this.pk].fields[evt.target.name] = evt.target.value;
}
},
},

computed: {
issue: function () {

issues: function () {
let a = [Vue.prototype.$globalData.filename];
return Object.values(Vue.prototype.$TCT.issues);
},

currentIssue: function () {
return Vue.prototype.$TCT.state_issue_scores[this.pk].fields.issue;
},

Expand Down

0 comments on commit 147ba37

Please sign in to comment.