#此處為方春高自己定義的代碼塊,主要是為了方便操作
# 消息框? ============================
#提示框
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
#確認(rèn)框=======
snippet 'dongyi.confirmt() 確認(rèn)框' 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
#瀏覽器打開網(wǎng)頁? =======
snippet 'dongyi.openUrl 瀏覽器打開網(wǎng)頁 ' 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,'短信內(nèi)容');"
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
#預(yù)加載? ? =======
snippet 'dongyi.preLoad 界面預(yù)加載 ' 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
#等待框關(guān)閉? ? =======
snippet 'dongyi.closeWaiting 等待框關(guān)閉 ' 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
#關(guān)閉當(dāng)前界面? ? =======
snippet 'dongyi.closeCurrentInterface 關(guān)閉當(dāng)前界面 ' do |s|
s.trigger = "ca_closeCurrentInterface"
s.expansion = "dongyi.closeCurrentInterface();"
s.needApplyReContentAssist = true
end
#創(chuàng)建子頁面? ? ? =======
snippet 'dongyi.createChildInterface 創(chuàng)建子頁面 ' 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
#獲得當(dāng)前界面對象? ? ? =======
snippet 'dongyi.getCurrentInterface 獲得當(dāng)前界面對象? ' do |s|
s.trigger = "ca_getCurrentInterface"
s.expansion = "dongyi.getCurrentInterface(function(currentObject){
alert(currentObject.getURL());
});"
s.needApplyReContentAssist = true
end
#獲得目標(biāo)界面對象? ? =======
snippet 'dongyi.getTargetInterface 獲得目標(biāo)界面對象? ' 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后會觸發(fā)該代碼塊
s.expansion = "dongyi.get({
url:'http://student.dongyixueyuan.com/link_app/get',
data:{
state:'index'
},
succFn:function(data){
alert(data);
}}
);"? #expansion是代碼塊的輸出內(nèi)容巧骚,其中$0蒿赢、$1是光標(biāo)的停留和切換位置。$1是第一個停留光標(biāo)单雾,$0是最后回車時停留的光標(biāo)。
#如果輸出涉及到換行和tab她紫,也需嚴(yán)格在這里使用換行和tab硅堆。
#輸出雙引號在前面加\來轉(zhuǎn)義,輸出$使用\$(單引號中)或\\$(雙引號中)轉(zhuǎn)義
s.needApplyReContentAssist = true? ? ? ? ? ? ? ? ? #這句話的意思是輸出后同時激活代碼助手贿讹,即在$1的位置直接拉出標(biāo)簽列表
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
#設(shè)備信息? ? =======
snippet 'dongyi.getDeviceInfo 設(shè)備信息? ? ' 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數(shù)組
var notice = 'root'; // 通知id單個字符串
dongyi.sendNotice(noticeArr,'channel',{
name:'東翌學(xué)院'
});
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 = "http://HTML5自帶 - 設(shè)置
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