Hey there!
I build a web tool for a photo lab to start print orders to be processed by the printers.
On older Mac's I am experiencing bad performance with my scripts. I was wondering whether there are some low performing parts in my scripts.
Do you guys see such low performing parts?
thx, Max
$(function() {
/* when start button is clicked */
$('.start_btn').click(function() {
/* remove all previous input fields */
$("#dialog_fieldset").children().remove();
/* save id */
id = $(this).attr('name');
/* get data from db */
$.post("inc/get_start_order_infos.inc.php", { id: id },
/* Callback */
function(data){
/* make data globally available */
daten = data;
/* build the var 'infos_html' */
var infos_html = '<label for="kunden_nr">Kunden-Nr.</label><input type="text" name="kunden_nr" id="kunden_nr" ';
infos_html += 'value="' + data.kunden_nr + '" class="text ui-widget-content ui-corner-all" />';
infos_html += '<label for="sort">Sort</label><input type="text" name="sort" id="sort" value="';
infos_html += data.sort_nr + '" class="text ui-widget-content ui-corner-all" />';
/* append infos_html to the fieldset */
$('#dialog_fieldset').append(infos_html);
/* Code Index */
anzahlCodes = 1;
/* For each element within the sub array codes */
for(e in data.codes){
/* build the var 'code_html' */
var code_html = '<label for="code' + anzahlCodes + '">Code ' + anzahlCodes;
code_html += '</label><input type="text" name="code' + anzahlCodes + '" id="code' + anzahlCodes;
code_html += '" value="' + data.codes[e] + '" class="text ui-widget-content ui-corner-all" />';
/* append code_html to the fieldset */
$('#dialog_fieldset').append(code_html);
anzahlCodes++;
}
$('#dialog').dialog('open');
$('#kunden_nr').select();
}, "json");
return false;
});
$("#dialog").dialog({
bgiframe: false,
autoOpen: false,
height: 350,
modal: true,
buttons: {
'Auftrag starten': function() {
/* close dialog */
$(this).dialog('close');
/* create the info array to be submitted */
var arr_infos = new Array();
arr_infos[0] = id;
arr_infos[1] = $('#kunden_nr').attr('value');
arr_infos[2] = $('#sort').attr('value');
/* write inputs into the str_codes */
var str_codes = "";
for (var i=1; i < anzahlCodes; i++){
var cde = '#code' + i;
if(i == 1){
str_codes += $(cde).attr('value');
}
else{
str_codes += "<--->" + $(cde).attr('value');
}
}
/* execute start */
$.post("inc/start_orders.inc.php", { 'corrected_infos[]':arr_infos, 'corrected_codes': str_codes },
/* Callback */
function(data){
$('#notice').remove();
/* if start was successful */
if (data.mstype == 'success'){
/* the pressed button */
btn = ".start_btn[name=" + id + "]";
/* the tr where the button is inside */
tr = $(btn).parent().parent();
/* remove red */
$(tr).removeClass('rot');
/* set text of Kunden-Nr. td */
$(tr).children().eq(3).text(arr_infos[1]);
/* set text of Sort td */
$(tr).children().eq(4).text(arr_infos[2]);
/* set text of Code td */
$(tr).children().eq(5).text(str_codes);
/* set text of start td */
$(tr).children().eq(8).text('ja');
/* prepend notice */
$("#outline").prepend("<div id='notice'>" + data.ms + "</div>");
}
/* if not successful */
else {
$("#outline").prepend("<div id='notice' class='notice_err'>" + data.ms + "</div>");
}
}, "json");
},
'Abbrechen': function() {
$(this).dialog('close');
}
}
});