2024-03-04 19:03:46 +08:00
|
|
|
// js
|
2024-03-04 22:46:12 +08:00
|
|
|
import 'dart:js' as Js;
|
|
|
|
import 'dart:html';
|
2024-03-04 19:03:46 +08:00
|
|
|
|
2024-03-05 22:25:31 +08:00
|
|
|
abstract class IPlr {}
|
|
|
|
|
|
|
|
class NPlr extends IPlr {}
|
2024-03-05 20:48:58 +08:00
|
|
|
|
|
|
|
SpanElement Span(String cls) {
|
|
|
|
return new SpanElement()..classes.add(cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
DivElement Div(String cls) {
|
|
|
|
return new DivElement()..classes.add(cls);
|
|
|
|
}
|
2024-03-05 22:25:31 +08:00
|
|
|
|
|
|
|
TableCellElement TD(TableRowElement tr) {
|
2024-03-05 20:48:58 +08:00
|
|
|
TableCellElement td = new TableCellElement();
|
|
|
|
tr.append(td);
|
|
|
|
return td;
|
|
|
|
}
|
|
|
|
|
|
|
|
ParagraphElement P(String cls) {
|
|
|
|
return new ParagraphElement()..classes.add(cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
String b(String str) {
|
|
|
|
return str;
|
|
|
|
}
|
2024-03-05 22:25:31 +08:00
|
|
|
|
2024-03-05 20:48:58 +08:00
|
|
|
String smile(String str) {
|
|
|
|
return '<div class="smile s_$str"></div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
String l(String str, String key) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2024-03-05 22:25:31 +08:00
|
|
|
num drawText(CanvasRenderingContext2D ctx, String txt, int x, int y, int w,
|
|
|
|
bool center) {
|
|
|
|
TextMetrics tm = ctx.measureText(txt);
|
|
|
|
ctx.fillText(txt, x, y + 15, w);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-03-05 22:34:27 +08:00
|
|
|
class Dt {
|
|
|
|
|
|
|
|
static String ex = b('!');
|
|
|
|
static String add = b('+');
|
|
|
|
static String at = b('@');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-04 12:29:26 +08:00
|
|
|
void main() {
|
2024-03-06 19:09:40 +08:00
|
|
|
|
|
|
|
print(Dt.at);
|
2024-03-05 22:34:27 +08:00
|
|
|
|
2024-03-04 22:52:37 +08:00
|
|
|
// Find an element by id (an-id).
|
|
|
|
Element idElement = querySelector('#an-id')!;
|
|
|
|
|
|
|
|
// Find an element by class (a-class).
|
|
|
|
Element classElement = querySelector('.a-class')!;
|
|
|
|
|
|
|
|
// Find all elements by tag (<div>).
|
|
|
|
List<Element> divElements = querySelectorAll('div');
|
|
|
|
|
2024-03-06 19:09:40 +08:00
|
|
|
Map test_map = {
|
|
|
|
"a": 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
print(test_map);
|
|
|
|
|
2024-03-05 22:25:31 +08:00
|
|
|
TableRowElement tr = new TableRowElement();
|
|
|
|
TD(tr)
|
|
|
|
..text = l('击杀', 'killedCount')
|
|
|
|
..style.width = '44px';
|
|
|
|
TD(tr)
|
|
|
|
..text = l('致命一击', 'killerName')
|
|
|
|
..style.minWidth = '112px';
|
|
|
|
|
|
|
|
var plr = new NPlr();
|
2024-03-05 20:48:58 +08:00
|
|
|
|
|
|
|
DivElement plist = document.querySelector('.plist') as DivElement;
|
|
|
|
DivElement pbody = document.querySelector('.pbody') as DivElement;
|
2024-03-05 12:29:56 +08:00
|
|
|
|
2024-03-05 22:25:31 +08:00
|
|
|
DivElement p = Div('p');
|
|
|
|
|
|
|
|
p.append(tr);
|
|
|
|
pbody.append(p);
|
|
|
|
plist.append(pbody);
|
|
|
|
|
2024-03-05 12:29:56 +08:00
|
|
|
print(idElement);
|
|
|
|
print(classElement);
|
|
|
|
print(divElements);
|
|
|
|
querySelector('#inputs')!.nodes.add(idElement);
|
|
|
|
|
2024-03-04 12:29:26 +08:00
|
|
|
print("Hello, World!");
|
|
|
|
var a = "Hello, World!";
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
a += " " + i.toString();
|
|
|
|
}
|
2024-03-04 22:52:37 +08:00
|
|
|
int b = 124242424;
|
2024-03-04 12:29:26 +08:00
|
|
|
for (var i = 0; i < 10; i++) {
|
2024-03-04 22:52:37 +08:00
|
|
|
b += b * i;
|
2024-03-04 12:29:26 +08:00
|
|
|
}
|
2024-03-04 22:52:37 +08:00
|
|
|
// js sleep
|
|
|
|
Future.delayed(Duration(milliseconds: 1000)).then((value) {
|
|
|
|
print("延时1秒执行 then ");
|
|
|
|
print(value);
|
|
|
|
});
|
2024-03-04 22:46:12 +08:00
|
|
|
|
|
|
|
var closuer = () {
|
|
|
|
print("closuer");
|
|
|
|
};
|
|
|
|
closuer();
|
2024-03-04 12:29:26 +08:00
|
|
|
print(a);
|
2024-03-04 22:52:37 +08:00
|
|
|
}
|
2024-03-05 22:34:27 +08:00
|
|
|
|