How to use empty method in Sure

Best Python code snippet using sure_python

pagesModel.ts

Source:pagesModel.ts Github

copy

Full Screen

1export interface Pages {2 pages: Page[];3 showCompletedPage: boolean;4 showQuestionNumbers: string;5 showProgressBar: string;6 goNextPageAutomatic: boolean;7 pagePrevText: string;8 pageNextText: string;9 requiredText: string;10}11export interface Page {12 name: string;13 elements: PageElement[];14}15export interface PageElement {16 type: ElementType;17 name: string;18 elements?: PurpleElement[];19 visibleIf?: string;20 html?: string;21 title?: string;22}23export interface PurpleElement {24 type: ElementType;25 name: string;26 html?: string;27 visibleIf?: string;28 titleLocation?: TitleLocation;29 choices?: PurpleChoice[];30 elements?: FluffyElement[];31 title?: string;32 isRequired?: boolean;33 description?: Description;34 validators?: Validator[];35 defaultValue?: DefaultValue;36 placeHolder?: DefaultValue;37 inputType?: string;38 columns?: Column[];39 cellType?: CellType;40 rows?: Row[];41}42export enum CellType {43 Boolean = "boolean",44 Text = "text",45}46export interface PurpleChoice {47 value: string;48 text: string;49 visibleIf?: string;50}51export interface Column {52 name: Name;53 title: Title;54 cellType: CellType;55 validators?: Validator[];56 placeHolder?: DefaultValue;57 enableIf?: EnableIf;58 defaultValue?: string;59}60export enum EnableIf {61 BROTHERDEATHAGEEmptyAndRowEndEmpty = "{BROTHER_DEATH_AGE} empty and {row.end} empty",62 DAUGHTERDEATHAGEEmptyAndRowEndEmpty = "{DAUGHTER_DEATH_AGE} empty and {row.end} empty",63 FATHERDEATHAGEEmptyAndRowEndEmpty = "{FATHER_DEATH_AGE} empty and {row.end} empty",64 MATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",65 MATERNALGRANDFATHERDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",66 MATERNALGRANDMOTHERDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",67 MATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",68 MOTHERDEATHAGEEmptyAndRowEndEmpty = "{MOTHER_DEATH_AGE} empty and {row.end} empty",69 PATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",70 PATERNALGRANDFATHERDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",71 PATERNALGRANDMOTHERDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",72 PATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",73 RowEndEmpty = "{row.end} empty",74 RowOngoingFalse = "{row.ongoing} = false",75 SECONDBROTHERDEATHAGEEmptyAndRowEndEmpty = "{SECOND_BROTHER_DEATH_AGE} empty and {row.end} empty",76 SECONDDAUGHTERDEATHAGEEmptyAndRowEndEmpty = "{SECOND_DAUGHTER_DEATH_AGE} empty and {row.end} empty",77 SECONDMATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{SECOND_MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",78 SECONDMATERNALUNCLEAUNTDEATHAGEEmptyAndRowEndEmpty = "{SECOND_MATERNAL_UNCLE_AUNT_DEATH_AGE} empty and {row.end} empty",79 SECONDMATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{SECOND_MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",80 SECONDPATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{SECOND_PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",81 SECONDPATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{SECOND_PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",82 SECONDSISTERDEATHAGEEmptyAndRowEndEmpty = "{SECOND_SISTER_DEATH_AGE} empty and {row.end} empty",83 SECONDSONDEATHAGEEmptyAndRowEndEmpty = "{SECOND_SON_DEATH_AGE} empty and {row.end} empty",84 SISTERDEATHAGEEmptyAndRowEndEmpty = "{SISTER_DEATH_AGE} empty and {row.end} empty",85 SONDEATHAGEEmptyAndRowEndEmpty = "{SON_DEATH_AGE} empty and {row.end} empty",86}87export enum Name {88 End = "end",89 Ongoing = "ongoing",90 Start = "start",91}92export enum DefaultValue {93 Yyyy = "YYYY",94}95export enum Title {96 End = "End",97 Ongoing = "Ongoing",98 Start = "Start",99}100export interface Validator {101 type: ValidatorType;102 text: Text;103 expression: string;104}105export enum Text {106 PleaseEnterAValidAge = "Please enter a valid age",107 PleaseEnterAValidYear = "Please enter a valid year",108 PleaseEnterAValidYearOfEndIllness = "Please enter a valid year of end Illness",109 PleaseEnterAValidYearOfStartIllness = "Please enter a valid year of start Illness",110}111export enum ValidatorType {112 Expression = "expression",113}114export enum Description {115 IfYouDonTKnowGiveYourBestGuess = "If you don't know, give your best guess",116 SelectAllThatApply = "Select all that apply.",117}118export interface FluffyElement {119 type: ElementType;120 name: string;121 visibleIf: string;122 title: string;123 choices: FluffyChoice[];124}125export interface FluffyChoice {126 value: string;127 text: string;128}129export enum ElementType {130 Checkbox = "checkbox",131 HTML = "html",132 Matrixdropdown = "matrixdropdown",133 Panel = "panel",134 Radiogroup = "radiogroup",135 Text = "text",136}137export interface Row {138 value: number | string;139 text: string;140 visibleIf: string;141}142export enum TitleLocation {143 Hidden = "hidden",144}145// Converts JSON strings to/from your types146// and asserts the results of JSON.parse at runtime147export class Convert {148 public static toPages(json: string): Pages {149 return cast(JSON.parse(json), r("Pages"));150 }151 public static pagesToJson(value: Pages): string {152 return JSON.stringify(uncast(value, r("Pages")), null, 2);153 }154}155function invalidValue(typ: any, val: any, key: any = ''): never {156 if (key) {157 throw Error(`Invalid value for key "${key}". Expected type ${JSON.stringify(typ)} but got ${JSON.stringify(val)}`);158 }159 throw Error(`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`, );160}161function jsonToJSProps(typ: any): any {162 if (typ.jsonToJS === undefined) {163 const map: any = {};164 typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });165 typ.jsonToJS = map;166 }167 return typ.jsonToJS;168}169function jsToJSONProps(typ: any): any {170 if (typ.jsToJSON === undefined) {171 const map: any = {};172 typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });173 typ.jsToJSON = map;174 }175 return typ.jsToJSON;176}177function transform(val: any, typ: any, getProps: any, key: any = ''): any {178 function transformPrimitive(typ: string, val: any): any {179 if (typeof typ === typeof val) return val;180 return invalidValue(typ, val, key);181 }182 function transformUnion(typs: any[], val: any): any {183 // val must validate against one typ in typs184 const l = typs.length;185 for (let i = 0; i < l; i++) {186 const typ = typs[i];187 try {188 return transform(val, typ, getProps);189 } catch (_) {}190 }191 return invalidValue(typs, val);192 }193 function transformEnum(cases: string[], val: any): any {194 if (cases.indexOf(val) !== -1) return val;195 return invalidValue(cases, val);196 }197 function transformArray(typ: any, val: any): any {198 // val must be an array with no invalid elements199 if (!Array.isArray(val)) return invalidValue("array", val);200 return val.map(el => transform(el, typ, getProps));201 }202 function transformDate(val: any): any {203 if (val === null) {204 return null;205 }206 const d = new Date(val);207 if (isNaN(d.valueOf())) {208 return invalidValue("Date", val);209 }210 return d;211 }212 function transformObject(props: { [k: string]: any }, additional: any, val: any): any {213 if (val === null || typeof val !== "object" || Array.isArray(val)) {214 return invalidValue("object", val);215 }216 const result: any = {};217 Object.getOwnPropertyNames(props).forEach(key => {218 const prop = props[key];219 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;220 result[prop.key] = transform(v, prop.typ, getProps, prop.key);221 });222 Object.getOwnPropertyNames(val).forEach(key => {223 if (!Object.prototype.hasOwnProperty.call(props, key)) {224 result[key] = transform(val[key], additional, getProps, key);225 }226 });227 return result;228 }229 if (typ === "any") return val;230 if (typ === null) {231 if (val === null) return val;232 return invalidValue(typ, val);233 }234 if (typ === false) return invalidValue(typ, val);235 while (typeof typ === "object" && typ.ref !== undefined) {236 typ = typeMap[typ.ref];237 }238 if (Array.isArray(typ)) return transformEnum(typ, val);239 if (typeof typ === "object") {240 return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)241 : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)242 : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)243 : invalidValue(typ, val);244 }245 // Numbers can be parsed by Date but shouldn't be.246 if (typ === Date && typeof val !== "number") return transformDate(val);247 return transformPrimitive(typ, val);248}249function cast<T>(val: any, typ: any): T {250 return transform(val, typ, jsonToJSProps);251}252function uncast<T>(val: T, typ: any): any {253 return transform(val, typ, jsToJSONProps);254}255function a(typ: any) {256 return { arrayItems: typ };257}258function u(...typs: any[]) {259 return { unionMembers: typs };260}261function o(props: any[], additional: any) {262 return { props, additional };263}264function m(additional: any) {265 return { props: [], additional };266}267function r(name: string) {268 return { ref: name };269}270const typeMap: any = {271 "Pages": o([272 { json: "pages", js: "pages", typ: a(r("Page")) },273 { json: "showCompletedPage", js: "showCompletedPage", typ: true },274 { json: "showQuestionNumbers", js: "showQuestionNumbers", typ: "" },275 { json: "showProgressBar", js: "showProgressBar", typ: "" },276 { json: "goNextPageAutomatic", js: "goNextPageAutomatic", typ: true },277 { json: "pagePrevText", js: "pagePrevText", typ: "" },278 { json: "pageNextText", js: "pageNextText", typ: "" },279 { json: "requiredText", js: "requiredText", typ: "" },280 ], false),281 "Page": o([282 { json: "name", js: "name", typ: "" },283 { json: "elements", js: "elements", typ: a(r("PageElement")) },284 ], false),285 "PageElement": o([286 { json: "type", js: "type", typ: r("ElementType") },287 { json: "name", js: "name", typ: "" },288 { json: "elements", js: "elements", typ: u(undefined, a(r("PurpleElement"))) },289 { json: "visibleIf", js: "visibleIf", typ: u(undefined, "") },290 { json: "html", js: "html", typ: u(undefined, "") },291 { json: "title", js: "title", typ: u(undefined, "") },292 ], false),293 "PurpleElement": o([294 { json: "type", js: "type", typ: r("ElementType") },295 { json: "name", js: "name", typ: "" },296 { json: "html", js: "html", typ: u(undefined, "") },297 { json: "visibleIf", js: "visibleIf", typ: u(undefined, "") },298 { json: "titleLocation", js: "titleLocation", typ: u(undefined, r("TitleLocation")) },299 { json: "choices", js: "choices", typ: u(undefined, a(r("PurpleChoice"))) },300 { json: "elements", js: "elements", typ: u(undefined, a(r("FluffyElement"))) },301 { json: "title", js: "title", typ: u(undefined, "") },302 { json: "isRequired", js: "isRequired", typ: u(undefined, true) },303 { json: "description", js: "description", typ: u(undefined, r("Description")) },304 { json: "validators", js: "validators", typ: u(undefined, a(r("Validator"))) },305 { json: "defaultValue", js: "defaultValue", typ: u(undefined, r("DefaultValue")) },306 { json: "placeHolder", js: "placeHolder", typ: u(undefined, r("DefaultValue")) },307 { json: "inputType", js: "inputType", typ: u(undefined, "") },308 { json: "columns", js: "columns", typ: u(undefined, a(r("Column"))) },309 { json: "cellType", js: "cellType", typ: u(undefined, r("CellType")) },310 { json: "rows", js: "rows", typ: u(undefined, a(r("Row"))) },311 ], false),312 "PurpleChoice": o([313 { json: "value", js: "value", typ: "" },314 { json: "text", js: "text", typ: "" },315 { json: "visibleIf", js: "visibleIf", typ: u(undefined, "") },316 ], false),317 "Column": o([318 { json: "name", js: "name", typ: r("Name") },319 { json: "title", js: "title", typ: r("Title") },320 { json: "cellType", js: "cellType", typ: r("CellType") },321 { json: "validators", js: "validators", typ: u(undefined, a(r("Validator"))) },322 { json: "placeHolder", js: "placeHolder", typ: u(undefined, r("DefaultValue")) },323 { json: "enableIf", js: "enableIf", typ: u(undefined, r("EnableIf")) },324 { json: "defaultValue", js: "defaultValue", typ: u(undefined, "") },325 ], false),326 "Validator": o([327 { json: "type", js: "type", typ: r("ValidatorType") },328 { json: "text", js: "text", typ: r("Text") },329 { json: "expression", js: "expression", typ: "" },330 ], false),331 "FluffyElement": o([332 { json: "type", js: "type", typ: r("ElementType") },333 { json: "name", js: "name", typ: "" },334 { json: "visibleIf", js: "visibleIf", typ: "" },335 { json: "title", js: "title", typ: "" },336 { json: "choices", js: "choices", typ: a(r("FluffyChoice")) },337 ], false),338 "FluffyChoice": o([339 { json: "value", js: "value", typ: "" },340 { json: "text", js: "text", typ: "" },341 ], false),342 "Row": o([343 { json: "value", js: "value", typ: u(0, "") },344 { json: "text", js: "text", typ: "" },345 { json: "visibleIf", js: "visibleIf", typ: "" },346 ], false),347 "CellType": [348 "boolean",349 "text",350 ],351 "EnableIf": [352 "{BROTHER_DEATH_AGE} empty and {row.end} empty",353 "{DAUGHTER_DEATH_AGE} empty and {row.end} empty",354 "{FATHER_DEATH_AGE} empty and {row.end} empty",355 "{MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",356 "{MATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",357 "{MATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",358 "{MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",359 "{MOTHER_DEATH_AGE} empty and {row.end} empty",360 "{PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",361 "{PATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",362 "{PATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",363 "{PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",364 "{row.end} empty",365 "{row.ongoing} = false",366 "{SECOND_BROTHER_DEATH_AGE} empty and {row.end} empty",367 "{SECOND_DAUGHTER_DEATH_AGE} empty and {row.end} empty",368 "{SECOND_MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",369 "{SECOND_MATERNAL_UNCLE_AUNT_DEATH_AGE} empty and {row.end} empty",370 "{SECOND_MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",371 "{SECOND_PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",372 "{SECOND_PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",373 "{SECOND_SISTER_DEATH_AGE} empty and {row.end} empty",374 "{SECOND_SON_DEATH_AGE} empty and {row.end} empty",375 "{SISTER_DEATH_AGE} empty and {row.end} empty",376 "{SON_DEATH_AGE} empty and {row.end} empty",377 ],378 "Name": [379 "end",380 "ongoing",381 "start",382 ],383 "DefaultValue": [384 "YYYY",385 ],386 "Title": [387 "End",388 "Ongoing",389 "Start",390 ],391 "Text": [392 "Please enter a valid age",393 "Please enter a valid year",394 "Please enter a valid year of end Illness",395 "Please enter a valid year of start Illness",396 ],397 "ValidatorType": [398 "expression",399 ],400 "Description": [401 "If you don't know, give your best guess",402 "Select all that apply.",403 ],404 "ElementType": [405 "checkbox",406 "html",407 "matrixdropdown",408 "panel",409 "radiogroup",410 "text",411 ],412 "TitleLocation": [413 "hidden",414 ],...

Full Screen

Full Screen

argument-types.js

Source:argument-types.js Github

copy

Full Screen

1description("Tests the acceptable types for arguments to Geolocation methods.");2function shouldNotThrow(expression)3{4 try {5 eval(expression);6 testPassed(expression + " did not throw exception.");7 } catch(e) {8 testFailed(expression + " should not throw exception. Threw exception " + e);9 }10}11function test(expression, expressionShouldThrow, expectedException) {12 if (expressionShouldThrow) {13 if (expectedException)14 shouldThrow(expression, '(function() { return "' + expectedException + '"; })();');15 else16 shouldThrow(expression, '(function() { return "Error: TYPE_MISMATCH_ERR: DOM Exception 17"; })();');17 } else {18 shouldNotThrow(expression);19 }20}21var emptyFunction = function() {};22function ObjectThrowingException() {};23ObjectThrowingException.prototype.valueOf = function() {24 throw new Error('valueOf threw exception');25}26ObjectThrowingException.prototype.__defineGetter__("enableHighAccuracy", function() {27 throw new Error('enableHighAccuracy getter exception');28});29var objectThrowingException = new ObjectThrowingException();30test('navigator.geolocation.getCurrentPosition()', true);31test('navigator.geolocation.getCurrentPosition(undefined)', true);32test('navigator.geolocation.getCurrentPosition(null)', true);33test('navigator.geolocation.getCurrentPosition({})', true);34test('navigator.geolocation.getCurrentPosition(objectThrowingException)', true);35test('navigator.geolocation.getCurrentPosition(emptyFunction)', false);36//test('navigator.geolocation.getCurrentPosition(Math.abs)', false);37test('navigator.geolocation.getCurrentPosition(true)', true);38test('navigator.geolocation.getCurrentPosition(42)', true);39test('navigator.geolocation.getCurrentPosition(Infinity)', true);40test('navigator.geolocation.getCurrentPosition(-Infinity)', true);41test('navigator.geolocation.getCurrentPosition("string")', true);42test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined)', false);43test('navigator.geolocation.getCurrentPosition(emptyFunction, null)', false);44test('navigator.geolocation.getCurrentPosition(emptyFunction, {})', true);45test('navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException)', true);46test('navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction)', false);47//test('navigator.geolocation.getCurrentPosition(emptyFunction, Math.abs)', false);48test('navigator.geolocation.getCurrentPosition(emptyFunction, true)', true);49test('navigator.geolocation.getCurrentPosition(emptyFunction, 42)', true);50test('navigator.geolocation.getCurrentPosition(emptyFunction, Infinity)', true);51test('navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity)', true);52test('navigator.geolocation.getCurrentPosition(emptyFunction, "string")', true);53test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined)', false);54test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, null)', false);55test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {})', false);56test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, objectThrowingException)', true, 'Error: enableHighAccuracy getter exception');57test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, emptyFunction)', false);58test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true)', false);59test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42)', false);60test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity)', false);61test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity)', false);62test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string")', false);63test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:undefined})', false);64test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:null})', false);65test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:{}})', false);66test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:objectThrowingException})', false);67test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:emptyFunction})', false);68test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true})', false);69test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42})', false);70test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity})', false);71test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity})', false);72test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"})', false);73test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:undefined})', false);74test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:null})', false);75test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:{}})', false);76test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:objectThrowingException})', false);77test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:emptyFunction})', false);78test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true})', false);79test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42})', false);80test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity})', false);81test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity})', false);82test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"})', false);83test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:undefined})', false);84test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:null})', false);85test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:{}})', false);86test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:objectThrowingException})', true, 'Error: valueOf threw exception');87test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:emptyFunction})', false);88test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true})', false);89test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42})', false);90test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity})', false);91test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity})', false);92test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"})', false);93test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:undefined})', false);94test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:null})', false);95test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:{}})', false);96test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:objectThrowingException})', true, 'Error: valueOf threw exception');97test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:emptyFunction})', false);98test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true})', false);99test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42})', false);100test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity})', false);101test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity})', false);102test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"})', false);103window.jsTestIsAsync = false;...

Full Screen

Full Screen

patternfly.dataTables.pfEmpty.js

Source:patternfly.dataTables.pfEmpty.js Github

copy

Full Screen

1/**2 * @summary pfEmpty for DataTables3 * @description A collection of API methods providing functionality to hide and show elements when DataTables is empty.4 * This ensures DataTables meets the Patternfly design pattern with a toolbar and empty state.5 *6 * When DataTable is redrawn and data length is zero, controls under the toolbar-pf-actions and toolbar-pf-results7 * classes are disabled; including the filter drop down, filter input, action buttons, kebab, find, etc. (You may8 * re-enable specific controls via the DataTables "draw.dt" event.) In addition, the DataTables empty table header and9 * row are hidden while the empty state (i.e., blank slate) layout is shown.10 *11 * The toolbar and empty state layouts are expected to contain the classes as shown in the example below.12 *13 * Example:14 *15 * <!-- NOTE: Some configuration may be omitted for clarity -->16 * <div class="row toolbar-pf table-view-pf-toolbar" id="toolbar1">17 * <div class="col-sm-12">18 * <form class="toolbar-pf-actions">19 * ...20 * </form>21 * <div class="row toolbar-pf-results">22 * ...23 * </div>24 * </div>25 * </div>26 * <table class="table table-striped table-bordered table-hover" id="table1">27 * <thead>28 * <tr>29 * <th><input type="checkbox" name="selectAll"></th>30 * <th>Rendering Engine</th>31 * <th>Browser</th>32 * </tr>33 * </thead>34 * </table>35 * <div class="blank-slate-pf table-view-pf-empty hidden" id="emptyState1">36 * <div class="blank-slate-pf-icon">37 * <span class="pficon pficon pficon-add-circle-o"></span>38 * </div>39 * <h1>Empty State Title</h1>40 * ...41 * </div>42 * <script>43 * // NOTE: Some properties may be omitted for clarity44 * $(document).ready(function() {45 * var dt = $("#table1").DataTable({46 * columns: [47 * { data: null, ... },48 * { data: "engine" },49 * { data: "browser" }50 * ],51 * data: null,52 * dom: "t",53 * pfConfig: {54 * emptyStateSelector: "#{{include.emptyStateId}}",55 * ...56 * toolbarSelector: "#{{include.toolbarId}}"57 * }58 * });59 * dt.table().pfEmpty.updateState(); // Optional API to force update60 * });61 * </script>62 *63 * Note: This functionality requires the following Javascript library files to be loaded:64 *65 * https://cdn.datatables.net/select/1.2.0/js/dataTables.select.min.js66 */67(function (factory) {68 "use strict";69 if (typeof define === "function" && define.amd ) {70 // AMD71 define (["jquery", "datatables.net"], function ($) {72 return factory ($, window, document);73 });74 } else if (typeof exports === "object") {75 // CommonJS76 module.exports = function (root, $) {77 if (!root) {78 root = window;79 }80 if (!$ || !$.fn.dataTable) {81 $ = require("datatables.net")(root, $).$;82 }83 return factory($, root, root.document);84 };85 } else {86 // Browser87 factory(jQuery, window, document);88 }89}(function ($, window, document, undefined) {90 "use strict";91 var DataTable = $.fn.dataTable;92 var ACTIONS_SELECTOR = ".toolbar-pf-actions"; // Toolbar actions93 var RESULTS_SELECTOR = ".toolbar-pf-results"; // Toolbar results row94 DataTable.pfEmpty = {};95 /**96 * Initialize97 *98 * @param {DataTable.Api} dt DataTable99 * @private100 */101 DataTable.pfEmpty.init = function (dt) {102 var ctx = dt.settings()[0];103 var opts = (ctx.oInit.pfConfig) ? ctx.oInit.pfConfig : {};104 ctx._pfEmpty = {};105 ctx._pfEmpty.emptyState = $(opts.emptyStateSelector); // Empty state (Blank slate)106 ctx._pfEmpty.isEmptyState = false; // Flag indicating DatTable entered an empty state107 ctx._pfEmpty.tbody = $("tbody", dt.table().container()); // Table body108 ctx._pfEmpty.thead = $("thead", dt.table().container()); // Table head109 ctx._pfEmpty.toolbarActions = $(ACTIONS_SELECTOR, opts.toolbarSelector); // Toolbar actions110 ctx._pfEmpty.toolbarResults = $(RESULTS_SELECTOR, opts.toolbarSelector); // Toolbar results row111 // Update table on DataTables draw event112 dt.on("draw.dt", function () {113 updateState(dt);114 });115 // Initialize116 updateState(dt);117 };118 // Local functions119 /**120 * Disable and hide elements when DataTables has no data121 *122 * @param {DataTable.Api} dt DataTable123 * @private124 */125 function updateEmptyState (dt) {126 var ctx = dt.settings()[0];127 // Show blank slate128 if (ctx._pfEmpty.emptyState !== undefined && ctx._pfEmpty.emptyState.length !== 0) {129 ctx._pfEmpty.emptyState.removeClass("hidden");130 }131 // Hide zero records message132 if (ctx._pfEmpty.tbody !== undefined && ctx._pfEmpty.tbody.length !== 0) {133 ctx._pfEmpty.tbody.addClass("hidden");134 }135 // Hide column headers136 if (ctx._pfEmpty.thead !== undefined && ctx._pfEmpty.thead.length !== 0) {137 ctx._pfEmpty.thead.addClass("hidden");138 }139 // Disable all buttons140 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {141 $("button", ctx._pfEmpty.toolbarActions).prop("disabled", true);142 }143 // Disable all inputs144 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {145 $("input", ctx._pfEmpty.toolbarActions).prop("disabled", true);146 }147 // Hide results container148 if (ctx._pfEmpty.toolbarResults !== undefined && ctx._pfEmpty.toolbarResults.length !== 0) {149 ctx._pfEmpty.toolbarResults.children().addClass("hidden");150 }151 // Enable on empty152 if (ctx._pfEmpty.enableOnEmpty !== undefined) {153 $(ctx._pfEmpty.enableOnEmpty).prop("disabled", false);154 }155 // Enable on empty156 if (ctx._pfEmpty.enableOnEmpty !== undefined) {157 $(ctx._pfEmpty.enableOnEmpty).prop("disabled", false);158 }159 }160 /**161 * Enable and show elements when DataTables has data162 *163 * @param {DataTable.Api} dt DataTable164 * @private165 */166 function updateNonEmptyState (dt) {167 var ctx = dt.settings()[0];168 // Hide blank slate169 if (ctx._pfEmpty.emptyState !== undefined && ctx._pfEmpty.emptyState.length !== 0) {170 ctx._pfEmpty.emptyState.addClass("hidden");171 }172 // Show table body173 if (ctx._pfEmpty.tbody !== undefined && ctx._pfEmpty.tbody.length !== 0) {174 ctx._pfEmpty.tbody.removeClass("hidden");175 }176 // Show column headers177 if (ctx._pfEmpty.thead !== undefined && ctx._pfEmpty.thead.length !== 0) {178 ctx._pfEmpty.thead.removeClass("hidden");179 }180 // Enable all buttons181 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {182 $("button", ctx._pfEmpty.toolbarActions).prop("disabled", false);183 }184 // Enable all inputs185 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {186 $("input", ctx._pfEmpty.toolbarActions).prop("disabled", false);187 }188 // Show results container189 if (ctx._pfEmpty.toolbarResults !== undefined && ctx._pfEmpty.toolbarResults.length !== 0) {190 ctx._pfEmpty.toolbarResults.children().removeClass("hidden");191 }192 }193 /**194 * Update elements upon empty DataTable state195 *196 * @param {DataTable.Api} dt DataTable197 * @private198 */199 function updateState (dt) {200 var ctx = dt.settings()[0];201 // Don't enable or show elements unless DataTable was empty202 if (dt.data().length === 0) {203 ctx._pfEmpty.isEmptyState = true;204 updateEmptyState(dt);205 } else if (ctx._pfEmpty.isEmptyState === true) {206 ctx._pfEmpty.isEmptyState = false;207 updateNonEmptyState(dt);208 }209 }210 // DataTables API211 /**212 * Update state upon empty or non-empty DataTable213 *214 * Example: dt.table().pfEmpty.updateState();215 */216 DataTable.Api.register("pfEmpty.updateState()", function () {217 return this.iterator("table", function (ctx) {218 update(new DataTable.Api(ctx));219 });220 });221 // DataTables creation222 $(document).on("init.dt", function (e, ctx, json) {223 if (e.namespace !== "dt") {224 return;225 }226 DataTable.pfEmpty.init(new DataTable.Api(ctx));227 });228 return DataTable.pfEmpty;...

Full Screen

Full Screen

validate.py

Source:validate.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import re3class validate:4 def __init__(self):5 pass6 def phone(self, value, isEmpty=False):7 "validate phone"8 reg = '^1[3458]\d{9}$'9 p = re.compile(reg)10 return (value == '' and isEmpty) or p.match(value)11 def mobile(self, value, isEmpty=False):12 "validate mobile"13 reg = '^(\d{3}-|\d{4}-)?(\d{8}|\d{7})$'14 p = re.compile(reg)15 return (value == '' and isEmpty) or p.match(value)16 def contact1(self, value, isEmpty=False):17 "validate contact"18 reg = '^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$'19 p = re.compile(reg)20 return (value == '' and isEmpty) or p.match(value)21 def contact(self, value, isEmpty=False):22 "validate contact"23 return self.phone(value, isEmpty) or self.mobile(value, isEmpty)24 def qq(self, value, isEmpty=False):25 "validate qq"26 reg = '^[1-9]\d{4,12}$'27 p = re.compile(reg)28 return (value == '' and isEmpty) or p.match(str(value))29 def url(self, value, isEmpty=False):30 "validate url"31 reg = '^(http|https):\/\/[A-Za-z0-9%\-_@]+\.[A-Za-z0-9%\-_@]{2,}[A-Za-z0-9\.\/=\?%\-&_~`@[\]:+!;]*$'32 p = re.compile(reg)33 return (value == '' and isEmpty) or p.match(value)34 def ip(self, value, isEmpty=False):35 "validate ip"36 reg = '^(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5])$'37 p = re.compile(reg)38 return (value == '' and isEmpty) or p.match(value)39 def int(self, value, isEmpty=False):40 "validate int"41 reg = '^\-?\d+$'42 p = re.compile(reg)43 return (value == '' and isEmpty) or p.match(value)44 def mac(self, value, isEmpty=False):45 "validate mac"46 reg_1 = '[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}'47 reg_2 = '[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}'48 p_1 = re.compile(reg_1)49 p_2 = re.compile(reg_2)50 return (value == '' and isEmpty) or p_1.match(value) or p_2.match(value)51 def plus(self, value, isEmpty=False):52 "validate plus"53 reg = '^[1-9]\d*$'54 p = re.compile(reg)55 return (value == '' and isEmpty) or p.match(value)56 def number(self, value, isEmpty=False):57 "validate number"58 reg = '^[0-9]+$'59 p = re.compile(reg)60 return (value == '' and isEmpty) or p.match(value)61 def notsc(self, value, isEmpty=False):62 "validate notsc"63 reg = ur'^[-a-zA-Z0-9_\u4e00-\u9fa5\s]+$'64 p = re.compile(reg)65 return (value == '' and isEmpty) or p.match(value)66 def letter(self, value, isEmpty=False):67 "validate letter"68 reg = '^[a-zA-Z]+$'69 p = re.compile(reg)70 return (value == '' and isEmpty) or p.match(value)71 def letterOrNum(self, value, isEmpty=False):72 "validate letter or number"73 reg = '^[0-9a-zA-Z]+$'74 p = re.compile(reg)75 return (value == '' and isEmpty) or p.match(value)76 def legalityName(self, value, isEmpty=False):77 "validate legalityName"78 reg = '^[-a-zA-Z0-9_]+$'79 p = re.compile(reg)80 return (value == '' and isEmpty) or p.match(value)81 def email(self, value, isEmpty=False):82 "validate email"83 #reg=r"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$"84 reg = r"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"85 p = re.compile(reg)86 return (value == '' and isEmpty) or p.match(value)87 def email1(self, value, isEmpty=False):88 reg = ur'^[_a-zA-Z\d@.-]+$';89 p = re.compile(reg)90 return (value == '' and isEmpty) or p.match(value)91 def period(self, value, isEmpty=False):92 va = value.split(':')93 if len(va) != 2: return False94 try:95 return not (int(va[0]) > 23 or int(va[1]) > 59 or int(va[1]) < 0)96 except:97 return False98 return True99 def onlyLetterUrl(self, value, isEmpty=False):100 "validate onlyLetterUrl"101 reg = r"^[a-zA-Z0-9.:/?#=]+$"102 p = re.compile(reg)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Sure automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful