please explain me tis code fragment
hi given below is a code fragment from a book im haveing hard time undestanding two lines of code from this code fragment
- function inline_editing_init(){
$('#subscribers .edit').remove();
$('#subscribers .name,#subscribers .email')
.click(inline_editing_edit);
}
function inline_editing_edit(){
if(this.in_edit)return;
this.in_edit=true;
var str=$(this).html();
var w=$(this).innerWidth();
$(this).empty();
$('<input>')
.attr('value',str)
.blur(inline_editing_save)
.keypress(inline_editing_key_pressed)
.css('width',w)
.appendTo(this)
.focus();
}
function inline_editing_save(){
var id,field_name,p;
p=this.parentNode;
if(p.originalHTML==this.value)
return inline_editing_restore(p);
field_name=p.className;
id=$(this).closest('tr')[0].id.replace(/.*_/,'');
$.getJSON(
'ajax_inline-editing.php',
{'id':id,'field_name':field_name,'value':this.value},
inline_editing_callback
);
}
function inline_editing_key_pressed(e){
if(!e.which)inline_editing_restore(this.parentNode);
}
function inline_editing_restore(el){
$(el).html(el.originalHTML);
el.in_edit=false;
}
here if(this.in_edit)return this is a dom element i think if im correct where does the in_edit comes from
secondly if(p.originalHTML==this.value) again p here for my knowledge is a dom element if so from where did the originalHTML come from and lastly
function inline_editing_key_pressed(e){
if(!e.which)inline_editing_restore(this.parentNode);
the author goes to say "inline_editing_key_pressed: This function will be used if the user presses
the Esc key. It will simply restore the table cell to its original value." how is this achieved through if(!e.which).
please help me out here
thanks in advanced