#此处为方春高自己定义的代码块,主要是为了方便操作
# 消息框 ============================
#提示框
snippet 'dongyi.prompt() 提示框' do |s|
s.trigger = "ca_pro"
s.expansion = "dongyi.prompt(\"$1\") "
s.needApplyReContentAssist = true
end
#警告框=======
snippet 'dongyi.alert() 警告框' do |s|
s.trigger = "ca_alert"
s.expansion = "dongyi.alert({
title: \"$1\",
content:\"$0\",
callback:function(){
alert('点击了');
}
}); "
s.needApplyReContentAssist = true
end
#确认框=======
snippet 'dongyi.confirmt() 确认框' do |s|
s.trigger = "ca_confirm"
s.expansion = "dongyi.confirm({
title:\"$1\",
content:\"$0\",
callback:function(data){
alert(data);
}
}); "
s.needApplyReContentAssist = true
end
#输入框=======
snippet 'dongyi.inputPrompt() 输入框' do |s|
s.trigger = "ca_inputPrompt"
s.expansion = "dongyi.inputPrompt({
title:\"$1\",
content:\"$0\",
callback:function(data){
alert(data);
}
});"
s.needApplyReContentAssist = true
end
#日期选择框=======
snippet 'dongyi.dateSelect() 日期选择框' do |s|
s.trigger = "ca_dateSelect"
s.expansion = "dongyi.dateSelect({
defaultTime:'2015-10-1',
minTime:'2000-1-1',
maxTime:'2020-1-1',
callback:function(date){
alert(date);
}
});"
s.needApplyReContentAssist = true
end
#时间选择框=======
snippet 'dongyi.timeSelect 时间选择框' do |s|
s.trigger = "ca_timeSelect"
s.expansion = "dongyi.timeSelect({
defaultTime:'18:00',
callback:function(date){
alert(date);
}
});"
s.needApplyReContentAssist = true
end
#电话 =======
snippet 'dongyi.callPhone 电话' do |s|
s.trigger = "ca_callPhone"
s.expansion = "dongyi.callPhone('13800138000');"
s.needApplyReContentAssist = true
end
#邮件 =======
snippet 'dongyi.sendEmail 邮件' do |s|
s.trigger = "ca_sendEmail"
s.expansion = "dongyi.sendEmail('dongyixueyuan@qq.com');"
s.needApplyReContentAssist = true
end
#浏览器打开网页 =======
snippet 'dongyi.openUrl 浏览器打开网页 ' do |s|
s.trigger = "ca_openUrl"
s.expansion = "dongyi.openUrl('http://www.dongyixueyuan.com');"
s.needApplyReContentAssist = true
end
#短信 =======
snippet 'dongyi.sendSms 短信 ' do |s|
s.trigger = "ca_sendSms"
s.expansion = "var targetPhone = ['13800138000','138001380001'];
dongyi.sendSms(targetPhone,'短信内容');"
s.needApplyReContentAssist = true
end
#双击退出APP =======
snippet 'dongyi.dblclickExit 双击退出APP(安卓) ' do |s|
s.trigger = "ca_dblclickExit"
s.expansion = "dongyi.dblclickExit();"
s.needApplyReContentAssist = true
end
#隐藏滚动条 =======
snippet 'dongyi.hiddenScroll 隐藏滚动条 ' do |s|
s.trigger = "ca_hiddenScroll"
s.expansion = "dongyi.hiddenScroll();"
s.needApplyReContentAssist = true
end
#蜂鸣提示音 =======
snippet 'dongyi.beep 蜂鸣提示音 ' do |s|
s.trigger = "ca_beep"
s.expansion = "dongyi.beep();"
s.needApplyReContentAssist = true
end
#手机震动 =======
snippet 'dongyi.vibrate 手机震动 ' do |s|
s.trigger = "ca_vibrate"
s.expansion = "dongyi.vibrate();"
s.needApplyReContentAssist = true
end
#遮罩 =======
snippet 'dongyi.showMask 遮罩 ' do |s|
s.trigger = "ca_showMask"
s.expansion = "dongyi.showMask(function(){
alert('callback');
});"
s.needApplyReContentAssist = true
end
#预加载 =======
snippet 'dongyi.preLoad 界面预加载 ' do |s|
s.trigger = "ca_preLoad"
s.expansion = "var arrayData = [{url:'first.html',id:'first'},{url:'second.html',id:'second'}];
dongyi.preLoad(arrayData,function(data){
alert(data);
});"
s.needApplyReContentAssist = true
end
#等待框显示 =======
snippet 'dongyi.showWaiting 等待框显示 ' do |s|
s.trigger = "ca_showWaiting"
s.expansion = "dongyi.showWaiting('等待框...');"
s.needApplyReContentAssist = true
end
#等待框关闭 =======
snippet 'dongyi.closeWaiting 等待框关闭 ' do |s|
s.trigger = "ca_closeWaiting"
s.expansion = "dongyi.closeWaiting();"
s.needApplyReContentAssist = true
end
#打开新界面 =======
snippet 'dongyi.newInterface 打开新界面 ' do |s|
s.trigger = "ca_newInterface"
s.expansion = "dongyi.newInterface({
url:'child.html',
id:'child',
styles:{
top:'0px',
bottom:'',
width:'',
height:''
},
showType:'zoom-fade-out',
showTime:200
});"
s.needApplyReContentAssist = true
end
#关闭当前界面 =======
snippet 'dongyi.closeCurrentInterface 关闭当前界面 ' do |s|
s.trigger = "ca_closeCurrentInterface"
s.expansion = "dongyi.closeCurrentInterface();"
s.needApplyReContentAssist = true
end
#创建子页面 =======
snippet 'dongyi.createChildInterface 创建子页面 ' do |s|
s.trigger = "ca_createChildInterfacee"
s.expansion = "dongyi.createChildInterface({
url:'child.html',
id:'child',
styles:{
top:'44px',
bottom:'',
width:'',
height:'',
}
});"
s.needApplyReContentAssist = true
end
#获得起始页对象 =======
snippet 'dongyi.getStartInterface 获得起始页对象 ' do |s|
s.trigger = "ca_getStartInterface"
s.expansion = "dongyi.getStartInterface(function(startObject){
alert(startObject.getURL());
});"
s.needApplyReContentAssist = true
end
#获得当前界面对象 =======
snippet 'dongyi.getCurrentInterface 获得当前界面对象 ' do |s|
s.trigger = "ca_getCurrentInterface"
s.expansion = "dongyi.getCurrentInterface(function(currentObject){
alert(currentObject.getURL());
});"
s.needApplyReContentAssist = true
end
#获得目标界面对象 =======
snippet 'dongyi.getTargetInterface 获得目标界面对象 ' do |s|
s.trigger = "ca_getTargetInterface"
s.expansion = "dongyi.getTargetInterface('first',function(targetObject){
alert(targetObject.getURL());
});"
s.needApplyReContentAssist = true
end
#actionSheet =======
snippet 'dongyi.actionSheet actionSheet ' do |s|
s.trigger = "ca_actionSheet"
s.expansion = "var arr = [{'title':'打开相册'},{'title':'打开相机'}];
var arr = ['新浪微博','腾讯微博','搜狐微博'];
// 两种写法均可
dongyi.actionSheet(arr,{
succFn:function(data){
alert(data);
},
errFn:function(data){
alert(data);
}
})"
s.needApplyReContentAssist = true
end
#相册 =======
snippet 'dongyi.album 相册 ' do |s|
s.trigger = "ca_album"
s.expansion = "dongyi.album({
succFn:function(path){
alert(path);
},
errFn:function(error){
alert(error);
}
});"
s.needApplyReContentAssist = true
end
#照相机 =======
snippet 'dongyi.camera 照相机 ' do |s|
s.trigger = "ca_camera"
s.expansion = "dongyi.camera({
succFn:function(path,name){
alert(path); // 图片路径
alert(name); // 图片名称
},
errFn:function(error){
alert(error);
}
});"
s.needApplyReContentAssist = true
end
#相册 =======
snippet 'dongyi.album 相册 ' do |s|
s.trigger = "ca_album"
s.expansion = "dongyi.album({
succFn:function(path){
alert(path);
},
errFn:function(error){
alert(error);
}
});"
s.needApplyReContentAssist = true
end
#获得通讯录信息 =======
snippet 'dongyi.getAddressBook 获得通讯录信息 ' do |s|
s.trigger = "ca_getAddressBook"
s.expansion = "dongyi.getAddressBook('phone',function(listData,length){
for(var a=0;a Z
var firstLetter = json.firstLetter;
}
});"
s.needApplyReContentAssist = true
end
# post请求
snippet 'dongyi.get()' do |s| #document.createElement()是显示名称,代码助手提示列表显示时可见
s.trigger = "ca_get" #dc是激活字符,即按下dc后会触发该代码块
s.expansion = "dongyi.get({
url:'http://student.dongyixueyuan.com/link_app/get',
data:{
state:'index'
},
succFn:function(data){
alert(data);
}}
);" #expansion是代码块的输出内容,其中$0、$1是光标的停留和切换位置。$1是第一个停留光标,$0是最后回车时停留的光标。
#如果输出涉及到换行和tab,也需严格在这里使用换行和tab。
#输出双引号在前面加\来转义,输出$使用\$(单引号中)或\\$(双引号中)转义
s.needApplyReContentAssist = true #这句话的意思是输出后同时激活代码助手,即在$1的位置直接拉出标签列表
end
#get请求 =======
snippet 'dongyi.get get请求 ' do |s|
s.trigger = "ca_get"
s.expansion = "dongyi.get({
url:'http://student.dongyixueyuan.com/link_app/get',
data:{
state:'index'
},
succFn:function(data){
alert(data);
}}
);"
s.needApplyReContentAssist = true
end
#设备信息 =======
snippet 'dongyi.getDeviceInfo 设备信息 ' do |s|
s.trigger = "ca_getDeviceInfo"
s.expansion = "dongyi.getDeviceInfo(function(json){
for(var a in json){
alert(a+'='+json[a]);
}
});"
s.needApplyReContentAssist = true
end
#手机信息 =======
snippet 'dongyi.getMachineInfo 手机信息 ' do |s|
s.trigger = "ca_getMachineInfo"
s.expansion = "dongyi.getMachineInfo(function(json){
for(var a in json){
alert(a+'='+json[a]);
}
});"
s.needApplyReContentAssist = true
end
#地理位置 =======
snippet 'dongyi.getCurrentPosition 地理位置 ' do |s|
s.trigger = "ca_getCurrentPosition"
s.expansion = "dongyi.getCurrentPosition({
succFn:function(data){
alert(data);
},
errFn:function(error){
alert(error);
}
});"
s.needApplyReContentAssist = true
end
#手势 =======
snippet 'dongyi.gesture 手势 ' do |s|
s.trigger = "ca_gesture"
s.expansion = "dongyi.gesture(cell['0'],'tap',function(){
alert('我被单击了');
});"
s.needApplyReContentAssist = true
end
#通知 and 接收通知 =======
snippet 'dongyi.sendNotice 通知and 接收通知 ' do |s|
s.trigger = "ca_sendNotice"
s.expansion = "var noticeArr = ['root','first','second']; // 通知id数组
var notice = 'root'; // 通知id单个字符串
dongyi.sendNotice(noticeArr,'channel',{
name:'东翌学院'
});
dongyi.receiveNotice('channel',function(event){
var name = event.detail.name;
alert(name);
});"
s.needApplyReContentAssist = true
end
#本地存储 =======
snippet 'dongyi.localStorage 本地存储 ' do |s|
s.trigger = "ca_localStorage"
s.expansion = "//HTML5自带 - 设置
localStorage.setItem('键','值'); -> localStorage.setItem('name','dongyixueyuan');
//HTML5自带 - 查询
localStorage.getItem('键'); -> var name = localStorage.setItem('name');
//HTML5自带 - 删除
localStorage.removeItem('键'); -> localStorage.removeItem('name');
//HTML5自带 - 清空
localStorage.clear();"
s.needApplyReContentAssist = true
end
网友评论