Difference between revisions of "カスタムコマンドの例を示します。直接追加するか、参考として使用してください。"
From GXtest Wiki
(Created page with "日付コントロールの値と現在の日付との比較 画像が壊れていないか、また画像が読み込めるかどうかの確認 複数レベルの階層...") |
|||
Line 1: | Line 1: | ||
日付コントロールの値と現在の日付との比較 | 日付コントロールの値と現在の日付との比較 | ||
+ | |||
+ | function CustomCommand (paramJS, currentGXVersion, currentLanguage){ | ||
+ | var day=((new Date().getDate()<10) ? "0" : "")+new Date().getDate(); | ||
+ | var month=(new Date().getMonth()+1<10) ? "0" +(new Date().getMonth()+1): new Date().getMonth()+1; | ||
+ | var year=(((new Date().getFullYear())%100<10) ? "0":"") +(new Date().getFullYear())%100; | ||
+ | var date_var =month.concat("/".concat(day.concat("/".concat(year)))); | ||
+ | if((paramJS==date_var)){ | ||
+ | result = "OK"; | ||
+ | }else{ | ||
+ | result = "Error, is not today"; | ||
+ | } | ||
+ | return result; | ||
+ | } | ||
画像が壊れていないか、また画像が読み込めるかどうかの確認 | 画像が壊れていないか、また画像が読み込めるかどうかの確認 | ||
+ | |||
+ | function CustomCommand (paramJS, currentGXVersion, currentLanguage) | ||
+ | { | ||
+ | |||
+ | result = "OK"; | ||
+ | for (var i = 0; i < window.document.images.length; i++) { | ||
+ | if (!(window.document.images[i].complete)) { | ||
+ | result = "ERROR, image with src:"+window.document.images[i].src+" not found"; | ||
+ | } | ||
+ | |||
+ | if (typeof window.document.images[i].naturalWidth != "undefined" && window.document.images[i].naturalWidth == 0) { | ||
+ | result = "ERROR, image with src:"+window.document.images[i].src+" not found"; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | /* It must be returned in result variable the value "OK" if the command executed successufuly, or an error description in other case */ | ||
+ | return result; | ||
+ | } | ||
複数レベルの階層にあるカスタムメニューのクリック | 複数レベルの階層にあるカスタムメニューのクリック | ||
paramJS の例:Vehicles/Cars/Sedan/1.0L | paramJS の例:Vehicles/Cars/Sedan/1.0L | ||
+ | |||
+ | function CustomCommand (paramJS, currentGXVersion, currentLanguage) | ||
+ | { | ||
+ | |||
+ | result = "OK"; | ||
+ | var menuItems = paramJS.split('/'); | ||
+ | for (var menuOrder = 0; menuOrder < menuItems.length; menuOrder++) { | ||
+ | var menuLevelName = 'menu_level'+(menuOrder+1).toString()+'_text'; | ||
+ | var elems = window.document.getElementsByClassName(menuLevelName); | ||
+ | |||
+ | for (var i = 0; i < elems.length; i++) { | ||
+ | var menuItem = elems[i]; | ||
+ | if (menuItems.length == (menuOrder+1)){ | ||
+ | menuItem = elems[i].childNodes[0]; | ||
+ | } | ||
+ | if (menuItem.innerHTML==menuItems[menuOrder]) { | ||
+ | menuItem.click(); | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | /* It must be returned in result variable the value "OK" if the command executed successufuly, or an error description in other case */ | ||
+ | return result; | ||
+ | } |
Revision as of 20:08, 5 February 2014
日付コントロールの値と現在の日付との比較
function CustomCommand (paramJS, currentGXVersion, currentLanguage){
var day=((new Date().getDate()<10) ? "0" : "")+new Date().getDate(); var month=(new Date().getMonth()+1<10) ? "0" +(new Date().getMonth()+1): new Date().getMonth()+1; var year=(((new Date().getFullYear())%100<10) ? "0":"") +(new Date().getFullYear())%100; var date_var =month.concat("/".concat(day.concat("/".concat(year)))); if((paramJS==date_var)){ result = "OK"; }else{ result = "Error, is not today"; } return result; }
画像が壊れていないか、また画像が読み込めるかどうかの確認
function CustomCommand (paramJS, currentGXVersion, currentLanguage) { result = "OK"; for (var i = 0; i < window.document.images.length; i++) { if (!(window.document.images[i].complete)) { result = "ERROR, image with src:"+window.document.images[i].src+" not found"; } if (typeof window.document.images[i].naturalWidth != "undefined" && window.document.images[i].naturalWidth == 0) { result = "ERROR, image with src:"+window.document.images[i].src+" not found"; } } /* It must be returned in result variable the value "OK" if the command executed successufuly, or an error description in other case */ return result; }
複数レベルの階層にあるカスタムメニューのクリック
paramJS の例:Vehicles/Cars/Sedan/1.0L
function CustomCommand (paramJS, currentGXVersion, currentLanguage)
{ result = "OK"; var menuItems = paramJS.split('/'); for (var menuOrder = 0; menuOrder < menuItems.length; menuOrder++) { var menuLevelName = 'menu_level'+(menuOrder+1).toString()+'_text'; var elems = window.document.getElementsByClassName(menuLevelName); for (var i = 0; i < elems.length; i++) { var menuItem = elems[i]; if (menuItems.length == (menuOrder+1)){ menuItem = elems[i].childNodes[0]; } if (menuItem.innerHTML==menuItems[menuOrder]) { menuItem.click(); break; } } } /* It must be returned in result variable the value "OK" if the command executed successufuly, or an error description in other case */ return result; }