var note=new Note();$(document).ready(function(){note.getNote("http://clouddisk/getNotelist");$("#allSelect").on("click",function(){var a=$("#note_list .item").length;if($(this).hasClass("snOn")){$(".sn").removeClass("snOn");$("#import2Phone").addClass("disable")}else{if(a>0){$(".sn").addClass("snOn");if(parent.getRomVersion()>=20&&parent.global.bConnected==1){$("#import2Phone").removeClass("disable")}}}});$("#note_list").on("click",".sn",function(){if($(this).hasClass("snOn")){$(this).removeClass("snOn");$("#allSelect").removeClass("snOn")}else{$(this).addClass("snOn");if($("#note_list .sn").length==$("#note_list .snOn").length){$("#allSelect").addClass("snOn")}}if($("#note_list .snOn").length!=0){if(parent.getRomVersion()>=20&&parent.global.bConnected==1){$("#import2Phone").removeClass("disable")}}else{$("#import2Phone").addClass("disable")}});$("#note_list").on("click",".item",function(){var c=new Array();var g=$(this).attr("id");var f=$("#"+g+" .picture_item");for(var a=0;a<f.length;++a){var b={};b.name=$(f[a]).attr("name");b.path=$(f[a]).attr("path");c.push(b)}var d={_dataList:c};var e=template("noteItemTemplate",d);$("#note_detail").html(e)});$("#import2Phone").on("click",function(){if($(this).hasClass("disable")){return}var a=$("#note_list .snOn");var b=new Array();for(var c=0;c<a.length;++c){var d=$(a[c]).parent().attr("id");b.push(note.getDataById(d))}note.import2Phone(JSON.stringify(b))});$("#refresh").on("click",function(){if($(this).hasClass("disable")){return}$("#loadding").show();$("#fail").hide();$("#allSelect").removeClass("snOn");$("#note_detail").html("");$("#import2Phone").addClass("disable");note.getNote("http://clouddisk/getNotelist")})});function Note(){this.getNote=function(a){$("#loadding").show();$.ajax({url:a,type:"GET",success:function(g){$("#loadding").hide();if(g=="error"){$("#fail").show()}else{var e={_dataList:JSON.parse(g)};var f=e._dataList;for(var c=0;c<f.length;c++){f[c]["create_date"]=formatTime(f[c]["create_date"])}var d=template("noteListTemplate",e);$("#note_list").html(d);$("#refresh").removeClass("disable");var b=$("#note_list .item").length;parent.setNoteCount(b)}},error:function(b){$("#loadding").hide();$("#fail").show();$("#refresh").addClass("disable")},complete:function(b){}})};this.import2Phone=function(a){parent.showImportProcess("note","正在导入便签");$.ajax({url:"http://clouddisk/importNotelist",type:"POST",data:a,success:function(){},error:function(){},complete:function(){parent.CloseArtDialog()}})};this.getDataById=function(f){var c={};c.id=parseInt($("#"+f).attr("nid"));c.date=$("#"+f+" .datetime").attr("value");c.content=$("#"+f+" .note_content_value").text();c.color=parseInt($("#"+f).attr("color"));c.alarmtime=parseInt($("#"+f).attr("alarmtime"));c.state=parseInt($("#"+f).attr("state"));c.has_passwd=parseInt($("#"+f).attr("has_passwd"));c.has_photo=parseInt($("#"+f).attr("has_photo"));c.has_contact=parseInt($("#"+f).attr("has_contact"));c.has_alarm=parseInt($("#"+f).attr("has_alarm"));c.curtimemillis=parseInt($("#"+f).attr("curtimemillis"));var a=new Array();var e=$("#"+f+" .picture_item");for(var b=0;b<e.length;++b){var d={};d.name=$(e[b]).attr("name");d.path=$(e[b]).attr("path");a.push(d)}c.pictures=a;return c}}function onConnected(a){if(a==1){if($("#note_list .snOn").length!=0){if(parent.getRomVersion()>=20){$("#import2Phone").removeClass("disable")}}else{$("#import2Phone").addClass("disable")}}else{$("#import2Phone").addClass("disable")}}function formatTime(e){var c=e.substr(0,4);var d=e.substr(4,2);var b=e.substr(6,2);var a=e.substr(8,2);var f=e.substr(10,2);return c+"-"+d+"-"+b+" "+a+":"+f};