Javascript small exercise code
Last Update:2018-12-08
Source: Internet
Author: User
There is no html code and only JS Code. The content of the small exercise is as follows: (learned from Teacher Chen Zhiwen's course)
<Script>
Ext. onReady (function (){
// Ext. Msg. alert ("system prompt (thtwinj2ee)", "The Environment configuration is correct! ");
Var myPosition = Ext. data. Record. create (
[{Name: "position"}]
); // Returns a function
New Ext. Window ({
Title: "Test window (never streaking )",
Width: 550,
Height: 370,
LabelWidth: 70,
Plain: true,
Layout: "form ",
Defaults: {anchor: "95% "},
// ButtonAlign: "center ",
Items:
[
{
Layout: "column ",
BaseCls: "x-plain ",
Style: "padding: 8px ",
Items:
[
{
ColumnWidth:. 5,
Layout: "form ",
BaseCls: "x-plain ",
LabelWidth: 70,
Defaults: {width: 150 },
DefaultType: "textfield ",
Items:
[
{
FieldLabel: "name"
},
{
FieldLabel: "Age ",
Value: 23,
ReadOnly: true
},
{
Xtype: "datefield ",
Format: "Y-m-d ",
Value: "1986-11-16 ",
ReadOnly: true,
FieldLabel: "Date of Birth ",
Listeners:
{
"Blur": function (_ df)
{
Var _ age = _ df. ownerCt. findByType ("textfield") [1];
_ Age. setValue (new Date (). getFullYear ()-_ df. getValue (). getFullYear () + 1 );
}
}
},
{
FieldLabel: "contact number"
},
{
FieldLabel: "mobile phone number"
},
{
FieldLabel: "email"
},
{
Xtype: "combo ",
FieldLabel: "gender ",
ReadOnly: true,
DisplayField: "sex ",
Value: "male ",
TriggerAction: "all ",
Mode: "local ",
Store: new Ext. data. SimpleStore
(
{
Fields: ["sex"],
Data: [["male"], ["female"]
}
)
}
]
},
{
ColumnWidth:. 5,
Layout: "form ",
BaseCls: "x-plain ",
LabelWidth: 55,
Items:
[
{
Xtype: "textfield ",
Width: 185,
Height: 178,
FieldLabel: "profile picture ",
InputType: "image"
}
]
}
]
},
{
Layout: "form ",
BaseCls: "x-plain ",
Style: "padding: 2px, 8px, 8px, 8px ",
DefaultType: "textfield ",
LabelWidth: 71,
Items:
[
{
FieldLabel: "ID card number ",
Width: 415
},
{
FieldLabel: "specific address ",
Width: 415
}
]
},
{
Layout: "column ",
BaseCls: "x-plain ",
Style: "padding: 2px, 8px, 8px, 8px ",
Items:
[
{
ColumnWidth:. 4,
Layout: "form ",
BaseCls: "x-plain ",
LabelWidth: 70,
Items:
[
{
Xtype: "combo ",
ReadOnly: true,
Mode: "local ",
TriggerAction: "all ",
DisplayField: "position ",
Width: 100,
FieldLabel: "title ",
Value: "junior programmer ",
Store: new Ext. data. SimpleStore
(
{
Fields: ["position"],
Data: [["Intermediate programmer"], ["Senior Programmer"], ["Project Manager"]
}
)
}
]
},
{
ColumnWidth:. 2,
Layout: "form ",
BaseCls: "x-plain ",
Items:
[
{
Xtype: "button ",
Text: "add a position ",
Handler: function ()
{
Var _ window = this. ownerCt;
Var _ position = _ window. findByType ("combo") [1];
Ext. Msg. prompt
(
"Add a position ",
"Enter the content of the position to be added ",
Function (_ btn, _ text)
{
If (_ btn = "OK ")
{
Var _ store = this. store;
_ Store. insert (0, new myPosition ({position: _ text }));
This. setValue (_ text );
}
}, _ Position // used to replace this object in the previous function ()
);
}
}
]
},
{
ColumnWidth:. 2,
Layout: "form ",
BaseCls: "x-plain ",
Items:
[
{
Xtype: "button ",
Text: "Modify position ",
Handler: function ()
{
Var _ window = this. ownerCt;
Var _ position = _ window. findByType ("combo") [1];
Ext. Msg. prompt (
"Changing positions (never streaking )",
"Enter the content you want to modify :",
Function (_ btn, _ text)
{
If (_ btn = "OK ")
{
This. setValue (_ text );
}
},
_ Position,
False,
_ Position. getValue ()
);
}
}
]
},
{
ColumnWidth:. 2,
Layout: "form ",
BaseCls: "x-plain ",
Items:
[
{
Xtype: "button ",
Text: "delete a job ",
Handler: function ()
{
Var _ window = this. ownerCt;
Var _ position = _ window. findByType ("combo") [1];
Ext. Msg. confirm
(
"Warning (thtwinj2ee )",
"Are you sure you want to delete this item? ",
Function (_ btn)
{
If (_ btn = "yes ")
{
This. store. remove (this ["selectItem"]);
If (this. store. getCount ()! = 0)
{
This. setValue (this. store. getAt (0). get ("position "));
This ["selectItem"] = this. store. getAt (0). get ("position ");
}
}
},
_ Position
);
}
}
]
}
]
}
],
Listeners:
{
"Show": function (_ window)
{
_ Window. findByType ("textfield") [5]. getEl (). dom. src = "02.jpg ";
}
},
Buttons:
[
{
Text: "OK"
},
{
Text: "cancel"
}
]
}). Show ();
});
</Script>