Added typing for recaptcha.js

This commit is contained in:
brentj73
2014-07-23 12:19:26 +01:00
parent 5a8f9e312f
commit c0e29234f7
2 changed files with 91 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
/// <reference path="recaptcha.d.ts"/>
var recaptchaOptions: RecaptchaOptions = {
theme : 'custom',
custom_theme_widget: 'recaptcha_widget'
};
var recaptchaOptions: RecaptchaOptions = {
custom_translations: { instructions_visual: "This is my text:" }
};
var recaptchaOptions: RecaptchaOptions = {
custom_translations: {
instructions_visual: "Scrivi le due parole:",
instructions_audio: "Trascrivi ci\u00f2 che senti:",
play_again: "Riascolta la traccia audio",
cant_hear_this: "Scarica la traccia in formato MP3",
visual_challenge: "Modalit\u00e0 visiva",
audio_challenge: "Modalit\u00e0 auditiva",
refresh_btn: "Chiedi due nuove parole",
help_btn: "Aiuto",
incorrect_try_again: "Scorretto. Riprova.",
},
lang: 'it',
theme: 'red'
};
var recaptchaOptions: RecaptchaOptions = {
theme : 'white',
tabindex : 2
};
Recaptcha.create("public_key_a",
"element_id_a",
{
theme: "red",
callback: Recaptcha.focus_response_field
}
);
Recaptcha.create("public_key_b",
"element_id_b",
recaptchaOptions
);
Recaptcha.switch_type("audio");
Recaptcha.get_challenge();
Recaptcha.get_response();
Recaptcha.reload();
Recaptcha.showhelp();
Recaptcha.focus_response_field();
Recaptcha.destroy();
+39
View File
@@ -0,0 +1,39 @@
// Type definitions for Google Recaptcha
// Project: https://www.google.com/recaptcha
// Definitions by: Brent Jenkins <https://github.com/brentj73>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare class Recaptcha {
constructor();
static reload(): void;
static switch_type(newtype: any);
static showhelp(): void;
static get_challenge(): string;
static get_response(): string;
static focus_response_field(): void;
static create(public_key: string, element: string, options: RecaptchaOptions): void;
static destroy(): void;
}
interface RecaptchaOptions {
tabindex?: number;
theme?: string;
callback?: Function;
lang?: string;
custom_theme_widget?: string;
custom_translations?: CustomTranslations;
}
interface CustomTranslations {
visual_challenge?: string;
audio_challenge?: string;
refresh_btn?: string;
instructions_visual?: string;
instructions_audio?: string;
help_btn?: string;
play_again?: string;
cant_hear_this?: string;
incorrect_try_again?: string;
image_alt_text?: string;
privacy_and_terms?: string;
}