Difference between revisions of "Custom Commands de ejemplo"
From GXtest Wiki
(New page: Category: Guías de GXtest Ejemplos de custom commands. Se pueden agregar directamente o obtener una idea de como realizarlos / usarlos == Comparar si un control tiene la fecha de ho...) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Idiomas | ||
+ | | Custom Commands de ejemplo | ||
+ | | Custom Command's examples | ||
+ | | カスタムコマンドの例を示します | ||
+ | }} | ||
[[Category: Guías de GXtest]] | [[Category: Guías de GXtest]] | ||
Line 6: | Line 11: | ||
function CustomCommand (paramJS, currentGXVersion, currentLanguage){ | function CustomCommand (paramJS, currentGXVersion, currentLanguage){ | ||
− | |||
var dia=((new Date().getDate()<10) ? "0" : "")+new Date().getDate(); | var dia=((new Date().getDate()<10) ? "0" : "")+new Date().getDate(); | ||
var mes=(new Date().getMonth()+1<10) ? "0" +(new Date().getMonth()+1): new Date().getMonth()+1; | var mes=(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 year=(((new Date().getFullYear())%100<10) ? "0":"") +(new Date().getFullYear())%100; | ||
var fecha=mes.concat("/".concat(dia.concat("/".concat(year)))); | var fecha=mes.concat("/".concat(dia.concat("/".concat(year)))); | ||
− | |||
if((paramJS==fecha)){ | if((paramJS==fecha)){ | ||
result = "OK"; | result = "OK"; | ||
Line 18: | Line 21: | ||
} | } | ||
return result; | return result; | ||
+ | } | ||
+ | |||
+ | |||
+ | == Verificar que una imagen esta totalmente cargada == | ||
+ | |||
+ | |||
+ | 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; | ||
} | } |
Latest revision as of 00:29, 21 February 2014
Ejemplos de custom commands. Se pueden agregar directamente o obtener una idea de como realizarlos / usarlos
Comparar si un control tiene la fecha de hoy
function CustomCommand (paramJS, currentGXVersion, currentLanguage){ var dia=((new Date().getDate()<10) ? "0" : "")+new Date().getDate(); var mes=(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 fecha=mes.concat("/".concat(dia.concat("/".concat(year)))); if((paramJS==fecha)){ result = "OK"; }else{ result = "Mal, la fecha no es la de hoy"; } return result; }
Verificar que una imagen esta totalmente cargada
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; }