fixed a initial importer

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12064 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2012-11-03 08:41:25 +00:00
parent ccb3f45173
commit 14024da697
2 changed files with 15 additions and 2 deletions

View file

@ -72,7 +72,7 @@ $('.checkxml')
})
.end()
.find('.x_help-inline').hide().end()
.closest('form').find('>.ttxml')/*.hide()*/.end().end()
.closest('form').find('>.ttxml').hide().end().end()
.closest('form').find(':submit').attr('disabled','disabled');
// hide 'sync member' block

View file

@ -1 +1,14 @@
jQuery(function(a){a(".checkxml").find("input:text").change(function(){a(this).closest(".checkxml").find(".x_help-inline").hide();}).end().find("button").click(function(){var g,j,h,b,i,k,f,d;g=a(this).prop("disabled",true);k=g.closest("form");j=g.closest(".checkxml");h=j.find("input").prop("disabled",true).addClass("loading");$message=j.find(".x_help-inline").hide();function c(o){var l,n,m;m=k.find(">.xml");n=k.find(">.ttxml");$message.text(o.result_message);if(o.error||o.exists!="true"){$message.attr("class","x_help-inline").fadeIn(300);n=n.filter(":visible");n.eq(-1).slideUp(100,function(){n=n.slice(0,-1).eq(-1).slideUp(100,arguments.callee);});k.find(":submit").attr("disabled","disabled");return e();}$message.attr("class","x_help-inline").fadeIn(300);k.find(":submit").removeAttr("disabled");f=k.find(".syncmember:hidden");h.prop("disabled",false).removeClass("loading");g.prop("disabled",false);if(o.type=="XML"){m.not(":visible").add(f).slideDown(300);}else{if(o.type=="TTXML"){n.not(":visible").add(f).slideDown(300);k.find("input[name=type]").val("ttxml");}}}function e(){h.prop("disabled",false).removeClass("loading");g.prop("disabled",false);k.find(".syncmember:visible").slideUp(100);return false;}show_waiting_message=false;a.exec_json("importer.procImporterAdminCheckXmlFile",{filename:a.trim(h.val())},c);}).end().find(".x_help-inline").hide().end().closest("form").find(">.ttxml").end().end().closest("form").find(":submit").attr("disabled","disabled");a(".syncmember").hide();});function doSync(a){exec_xml("importer","procImporterAdminSync",[],function(b){alert(b.message);location.href=location.href;});return false;}function doPreProcessing(a,h){var e,f,c,k=false,d=jQuery,i,g,j;e=a.elements.xml_file.value;f=a.elements.type.value;if(!e){return false;}g=d("#process");if(!d("body").children(".x_modal-backdrop").length){d("body").append('<div class="x_modal-backdrop" />');}d('a[href="#process"].modalAnchor').trigger("open.mw");exec_xml("importer","procImporterAdminPreProcessing",{type:f,xml_file:e},b,c=["error","message","type","total","cur","key","status"]);function b(p){var o,t,r,l,m,q,u,s,n;k=true;if(p.status==-1){return alert(p.message);}r=get_by_id("fo_process");l=r.elements;for(m=0,q=c.length;m<q;m++){u=c[m];l[u]?l[u].value=p[u]:0;}n=get_by_id(h);if(n){s=["target_module","guestbook_target_module","user_id","unit_count"];for(m=0,q=s.length;m<q;m++){u=s[m];if(n.elements[u]){r.elements[u].value=n.elements[u].value;}}}jQuery("#preProgressMsg").hide();jQuery("#progressMsg").show();doImport(h);}return false;}function doImport(g){var d=get_by_id("fo_process"),a=d.elements,b,j,f={},e;for(b=0,j=a.length;b<j;b++){f[a[b].name]=a[b].value;}function h(k,p){var m,q,l,o;for(m=0,q=e.length;m<q;m++){l=e[m];a[l]?a[l].value=k[l]:0;}k.total=parseInt(k.total,10)||0;k.cur=parseInt(k.cur,10)||0;percent=parseInt((k.cur/k.total)*100);jQuery("#totalCount").text(k.total);jQuery("#completeCount").text(k.cur);jQuery("#progressBar").width(percent+"%");jQuery("#progressPercent").html(percent+"%");if(k.total>k.cur){doImport(g);}else{function n(){alert(k.message);jQuery('a[href="#process"].modalAnchor').unbind("before-close.mw").trigger("close.mw").find("#progressBar").width(1).end().find("#progressPercent").html("0%").end();try{d.reset();get_by_id(g).reset();}catch(c){}jQuery("span.btn > input[type=submit]").attr("disabled","disabled");}o=get_by_id(g);if(o!=null&&o.isSync.checked){exec_xml("importer","procImporterAdminSync",f,function(c){if(c&&(!c.error||c.error=="0")){n();}},e=["error","message"]);}else{n();}}}show_waiting_message=false;exec_xml("importer","procImporterAdminImport",f,h,e=["error","message","type","total","cur","key"]);show_waiting_message=true;return false;}function displayProgress(d,e){var b,c,a;b=Math.max(d?Math.round(e/d*100):100,1);a=jQuery("#status");if(!a.find("div.progress1").length){a.html('<div class="progressBox"><div class="progress1"></div><div class="progress2"></div></div>');}a.find("div.progress1").html(b+"&nbsp;").css("width",b+"%").end().find("div.progress2").text(e+"/"+d);}
/**
* @file modules/importer/js/importer_admin.js
* @author NHN (developers@xpressengine.com)
* @brief importer에서 사용하는 javascript
**/
jQuery(function($){$('.checkxml').find('input:text').change(function(){$(this).closest('.checkxml').find('.x_help-inline').hide()}).end().find('button').click(function(){var $this,$container,$input,$messages,$loading,$form,$syncmember,count;$this=$(this).prop('disabled',true);$form=$this.closest('form');$container=$this.closest('.checkxml');$input=$container.find('input').prop('disabled',true).addClass('loading');$message=$container.find('.x_help-inline').hide()
function on_complete(data){var $ul,$ttxml,$xml;$xml=$form.find('>.xml');$ttxml=$form.find('>.ttxml');$message.text(data.result_message);if(data.error||data.exists!='true'){$message.attr('class','x_help-inline').fadeIn(300);$ttxml=$ttxml.filter(':visible');$ttxml.eq(-1).slideUp(100,function(){$ttxml=$ttxml.slice(0,-1).eq(-1).slideUp(100,arguments.callee)});$form.find(':submit').attr('disabled','disabled');return restore()};$message.attr('class','x_help-inline').fadeIn(300);$form.find(':submit').removeAttr('disabled');$syncmember=$form.find('.syncmember:hidden');$input.prop('disabled',false).removeClass('loading');$this.prop('disabled',false);if(data.type=='XML'){$xml.not(':visible').add($syncmember).slideDown(300)}else if(data.type=='TTXML'){$ttxml.not(':visible').add($syncmember).slideDown(300);$form.find('input[name=type]').val('ttxml')}}
function restore(){$input.prop('disabled',false).removeClass('loading');$this.prop('disabled',false);$form.find('.syncmember:visible').slideUp(100);return false};show_waiting_message=false;$.exec_json('importer.procImporterAdminCheckXmlFile',{filename:$.trim($input.val())},on_complete)}).end().find('.x_help-inline').hide().end().closest('form').find('>.ttxml').hide().end().end().closest('form').find(':submit').attr('disabled','disabled');$('.syncmember').hide()})
function doSync(fo_obj){exec_xml('importer','procImporterAdminSync',[],function(ret){alert(ret.message);location.href=location.href});return false}
function doPreProcessing(form,formId){var xml_file,type,resp,prepared=false,$=jQuery,$status,$process,$form;xml_file=form.elements['xml_file'].value;type=form.elements['type'].value;if(!xml_file)return false;$process=$('#process');if(!$('body').children('.x_modal-backdrop').length)$('body').append('<div class="x_modal-backdrop" />');$('a[href="#process"].modalAnchor').trigger('open.mw');exec_xml('importer','procImporterAdminPreProcessing',{type:type,xml_file:xml_file},on_complete,resp=['error','message','type','total','cur','key','status'])
function on_complete(ret){var $reload,$cont,fo_proc,elems,i,c,key,to_copy,fo_import;prepared=true;if(ret.status==-1)return alert(ret.message);fo_proc=get_by_id('fo_process');elems=fo_proc.elements;for(i=0,c=resp.length;i<c;i++){key=resp[i];elems[key]?elems[key].value=ret[key]:0};fo_import=get_by_id(formId);if(fo_import){to_copy=['target_module','guestbook_target_module','user_id','unit_count'];for(i=0,c=to_copy.length;i<c;i++){key=to_copy[i];if(fo_import.elements[key])fo_proc.elements[key].value=fo_import.elements[key].value}};jQuery('#preProgressMsg').hide();jQuery('#progressMsg').show();doImport(formId)};return false}
function doImport(formId){var form=get_by_id('fo_process'),elems=form.elements,i,c,params={},resp;for(i=0,c=elems.length;i<c;i++)params[elems[i].name]=elems[i].value
function on_complete(ret,response_tags){var i,c,key,fo_import;for(i=0,c=resp.length;i<c;i++){key=resp[i];elems[key]?elems[key].value=ret[key]:0};ret.total=parseInt(ret.total,10)||0;ret.cur=parseInt(ret.cur,10)||0;percent=parseInt((ret.cur/ret.total)*100);jQuery('#totalCount').text(ret.total);jQuery('#completeCount').text(ret.cur);jQuery('#progressBar').width(percent+'%');jQuery('#progressPercent').html(percent+"%");if(ret.total>ret.cur){doImport(formId)}else{function resultAlertMessage(){alert(ret.message);jQuery('a[href="#process"].modalAnchor').unbind('before-close.mw').trigger('close.mw').find('#progressBar').width(1).end().find('#progressPercent').html('0%').end();try{form.reset();get_by_id(formId).reset()}catch(e){};jQuery('span.btn > input[type=submit]').attr('disabled','disabled')};fo_import=get_by_id(formId);if(fo_import!=null&&fo_import.isSync.checked){exec_xml('importer','procImporterAdminSync',params,function(ret){if(ret&&(!ret.error||ret.error=='0'))resultAlertMessage()},resp=['error','message'])}else resultAlertMessage()}};show_waiting_message=false;exec_xml('importer','procImporterAdminImport',params,on_complete,resp=['error','message','type','total','cur','key']);show_waiting_message=true;return false}
function displayProgress(total,cur){var per,stat,$stat;per=Math.max(total?Math.round(cur/total*100):100,1);$stat=jQuery('#status');if(!$stat.find('div.progress1').length)$stat.html('<div class="progressBox"><div class="progress1"></div><div class="progress2"></div></div>');$stat.find('div.progress1').html(per+'&nbsp;').css('width',per+'%').end().find('div.progress2').text(cur+'/'+total)}