Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
[Character] Rewrote character copier completely, dynamically iteratin…
Browse files Browse the repository at this point in the history
…g through database fields to generate the copy routine successfully. Tested and working completely. http://i.imgur.com/lPEIMrV.png
  • Loading branch information
Akkadius committed Mar 2, 2015
1 parent 460a691 commit b20053f
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 526 deletions.
3 changes: 2 additions & 1 deletion ajax.php
Expand Up @@ -4,7 +4,7 @@
$IncludeDir = str_replace('includes', '', $IncludeDir); #echo $IncludeDir; exit;
require_once($IncludeDir . '/includes/config.php');
require_once($IncludeDir . '/includes/functions.php');

if($_GET['M'] == "Items"){ include('modules/ItemEditor/ajax/ajax.php'); }
if($_GET['M'] == "TaskEditor"){ include('modules/TaskEditor/js/ajax.php'); }
if($_GET['M'] == "NPC"){ include('modules/NPC/ajax/ajax.php'); }
Expand All @@ -15,5 +15,6 @@
if($_GET['M'] == "dbstr"){ include('modules/dbstr/js/ajax.php'); }
if($_GET['M'] == "ZT"){ include('modules/Zone_Tools/ajax/ajax.php'); }
if($_GET['M'] == "race_viewer"){ include('modules/RaceViewer/ajax/ajax.php'); }
if($_GET['M'] == "Character"){ include('modules/Character/ajax/ajax.php'); }

?>
2 changes: 2 additions & 0 deletions cust_assets/js/eoc_global.js
@@ -1,5 +1,7 @@
/* Database Functions */

global_loader = "<i class='fa fa-spinner fa-spin' style='font-size:80px'>";

function DoDBSwitch(db){
$.ajax({
url: "ajax.php?M=DBAuth&DoDBSwitch=" + encodeURIComponent(db),
Expand Down
8 changes: 7 additions & 1 deletion includes/functions.php
Expand Up @@ -51,6 +51,12 @@ function SectionHeader($data, $desc = ''){

/* Global Scoped Functions */

function p_var_dump($data){
print '<pre>';
print var_dump($data);
print '</pre>';
}

function DuplicateMySQLRecord ($table, $id_field, $id_copied_from, $copied_to_id = 0) {
/* load the original record into an array */

Expand All @@ -61,7 +67,7 @@ function DuplicateMySQLRecord ($table, $id_field, $id_copied_from, $copied_to_id
/* insert the new record and get the new auto_increment id */
mysql_query("INSERT INTO {$table} (`{$id_field}`) VALUES (NULL)");
$new_id = mysql_insert_id();
# echo mysql_error();
echo mysql_error();
}
else {
$new_id = $copied_to_id;
Expand Down
68 changes: 28 additions & 40 deletions modules/Character/Character.php
@@ -1,49 +1,37 @@
<?php
// Item Editor Dispatcher Page
// Author: Akkadius

echo '<div id="JSOP"></div>';

echo '<script type="text/javascript" src="modules/Character/ajax/ajax.js"></script>';
echo '<link rel="stylesheet" type="text/css" href="css/main.css">';
include('../../includes/constants2.php');
include('functions.php');

echo '<style>
td{ font-size:15px; }
td input{ }
</style>';

PageTitle("Character Tools");

echo StartContent();

echo CBoxStart("Character Tools", "", "text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000;");

echo '
<center><table width="90%" class="mainForm"><tr><td>
<br>
<table>
<tr><td><h2> • Select Tool • </h2></td></tr>
<tr><td></td></tr>
<tr>
<td>
<select onchange="CharacterTool(this.value)">
<option value="0">-</option>
<option value="1">Copy Character</option>
<option value="2">Character Management (BETA)</option>
</td>
</tr>
</table>
<br>
<div id="charactertool"></div>
</td></tr></table></center>';

echo '<br>';
echo CBoxEnd();

echo EndContent();
require_once('includes/constants.php');
require_once('modules/Character/functions.php');

if(isset($_GET['character_copy'])) {
PageTitle("Character Copier");

echo '<h3>Character Copier</h3><hr>';

echo '
<table class="table table-striped table-hover table-condensed flip-content table-bordered" style="width:300px">
<tr>
<td>
<select onchange="CharacterTool(this.value)" class="form-control">
<option value="0">--- Select ---</option>
<option value="1">Copy Character</option>
<!-- <option value="2">Character Management (BETA)</option> -->
</select>
</td>
</tr>
</table>
<div id="character_copy_options"></div>
<div id="character_copy_result"></div>
<div id="character_search_result"></div>
';

}

?>
161 changes: 46 additions & 115 deletions modules/Character/ajax/ajax.js
@@ -1,126 +1,57 @@
function CharacterTool(Data) {
var xmlhttp;
document.getElementById("charactertool").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("charactertool").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.php?Ajax=Character&CharTool=" + Data, true);
xmlhttp.send();
}

function CharSearch(Data) {
var xmlhttp;
document.getElementById("charactersearch").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("charactersearch").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.php?Ajax=Character&CharSearch=" + Data, true);
xmlhttp.send();
function CharacterTool(val) {
u = "character_copy_options";
$("#" + u).html(global_loader);
$.ajax({
url: "ajax.php?M=Character&character_copier",
context: document.body
}).done(function(e) {
$("#" + u).html(e);
});
}

function CharSearchMGMT(Data) {
var xmlhttp;
document.getElementById("charactersearch").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("charactersearch").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.php?Ajax=Character&CharSearchMGMT=" + Data, true);
xmlhttp.send();
function CharacterSearch(val) {
u = "character_search_result";
$("#" + u).html(global_loader);
$.ajax({
url: "ajax.php?M=Character&character_search=" + val,
context: document.body
}).done(function(e) {
$("#" + u).html(e);
});
}

function DoCharMGMT(Data) {
var xmlhttp;
document.getElementById("charactersearch").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("charactersearch").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.php?Ajax=Character&DoCharMGMT=" + Data, true);
xmlhttp.send();
function handle_source_character(val){
$('#origchar').val(val);
}

function DoCharTaskProgShow(Data, TaskID) {
var xmlhttp;
document.getElementById("charactersearch").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("charactersearch").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.php?Ajax=Character&DoCharTaskProgShow=" + Data + "&TaskID=" + TaskID, true);
xmlhttp.send();
function handle_destination_account(val){
$('#dest_account').val(val);
}

function DoGMCommand(Data, Action) {
var xmlhttp;
document.getElementById("GMCommand").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("GMCommand").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.php?Ajax=Character&DoGMCommand=" + Data + "&Action=" + Action, true);
xmlhttp.send();
}
function CopyCharacter(){
u = "character_copy_result";
if($('#new_character_name').val() == "") {
$("#" + u).html("You must specify a new character name");
return;
}
if($('#origchar').val() == "Origin Character"){
$("#" + u).html("There needs to be an Origin Character specified");
return;
}
if($('#dest_account').val() == "Destination Account"){
$("#" + u).html("There needs to be a Destination Account specified");
return;
}

function SendTaskUpdate(Data, TaskID, Activity, Count) {
var xmlhttp;

if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
//document.getElementById("charactersearch").innerHTML=xmlhttp.responseText;
document.getElementById("charactersearch").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
setTimeout(function(){ DoCharTaskProgShow(Data, TaskID); }, 1000);
}
}
if(document.getElementById("activity_" + Activity).value){ Count = document.getElementById("activity_" + Activity).value; }
xmlhttp.open("GET","ajax.php?Ajax=Character&SendTaskUpdate=" + Data + "&TaskID=" + TaskID + "&ActivityID=" + Activity + "&Count=" + Count, true);
xmlhttp.send();

}
var character_copy = $('#origchar').val();
var destination_account = $('#dest_account').val();

$("#" + u).html(global_loader);
$.ajax({
url: "ajax.php?M=Character&do_copy_character&source_character=" + character_copy + "&destination_account=" + destination_account + "&new_character_name=" + encodeURIComponent($('#new_character_name').val()),
context: document.body
}).done(function(e) {
$("#" + u).html(e);
});

function CopyCharacter(){
if(document.getElementById("origchar").value == "Origin Character"){
document.getElementById("copycharresults").innerHTML="There needs to be an Origin Character specified";
return;
}
if(document.getElementById("destaccount").value == "Destination Account"){
document.getElementById("copycharresults").innerHTML="There needs to be a Destination Account specified";
return;
}
var CharCopy = document.getElementById("origchar").value;
var DestAcc = document.getElementById("destaccount").value;

var xmlhttp;
document.getElementById("copycharresults").innerHTML="<center><br><br><img src=\'images/loaders/loader8.gif\'></center><br><br>";
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("copycharresults").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.php?Ajax=Character&CopyChar=1&CharToCopy=" + CharCopy + "&DestAcc=" + DestAcc, true);
xmlhttp.send();
}

0 comments on commit b20053f

Please sign in to comment.