reverse-name/dart-js/test.dart

214 lines
6.0 KiB
Dart
Raw Normal View History

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('@');
static String atex = b('@!');
static String cln = b(':');
static String exTest = b('!test!');
static String u02 = b('\u0002');
static String u03 = b('\u0003');
// static String u04 = b('\u0004');
// static String u05 = b('\u0005');
// static String u200b = b('\u200B');
static String qq = b('??');
static String assassinate = b('assassinate');
static String exchange = b('exchange');
static String half = b('half');
static String charge = b('charge');
static String fire = b('fire');
static String ice = b('ice');
static String accumulate = b('accumulate');
static String poison = b('poison');
static String berserk = b('berserk');
static String charm = b('charm');
static String curse = b('curse');
static String iron = b('iron');
static String slow = b('slow');
static String haste = b('haste');
static String corpose = b('corpose');
static String shield = b('shield');
static String protect = b('protect');
static String upgrade = b('upgrade');
static String disperse = b('disperse');
static String zombie = b('zombie');
static String shadow = b('shadow');
static String summon = b('summon');
static String minionCount = b('minionCount');
static String bossName = b('bossName_');
static String mario = b('mario');
static String sonic = b('sonic');
static String mosquito = b('mosquito');
static String yuri = b('yuri');
static String slime = b('slime');
static String ikaruga = b('ikaruga');
static String conan = b('conan');
static String aokiji = b('aokiji');
static String lazy = b('lazy');
static String covid = b('covid');
static String saitama = b('saitama');
static String rinick = b('Rinick');
static String hanxu = b('涵虚');
static String lingyun = b('霛雲');
static String yunjian = b('云剑');
static String xinjiyuan = b('新纪元');
static String kuzan = b('库瓒');
static String kuzan1 = b('庫瓒');
static String qilala = b('琪拉拉');
static String chuncai = b('纯菜');
static String xueche = b('学🚗🀄学');
static String phy = b('Ø');
static String seed = b('seed:');
static String dio = b('dio');
static String mask = b('mask');
static String maskz = b('口罩');
static String ladderz = b('天梯');
static String s_win = b('<div class="smile s_win"></div>');
static String s_lose = b('<div class="smile s_lose"></div>');
static String s_elite1 = b('<div class="smile s_elite1"></div>');
static String s_elite2 = b('<div class="smile s_elite2"></div>');
static String s_elite3 = b('<div class="smile s_elite3"></div>');
static String s_boss = b('<div class="smile s_boss"></div>');
static String s_dmg0 = b('<div class="smile s_dmg0"></div>');
static String s_dmg120 = b('<div class="smile s_dmg120"></div>');
static String s_dmg160 = b('<div class="smile s_dmg160"></div>');
static String s_accumulate = b('<div class="s_accumulate s_win"></div>');
static String s_berserk = b('<div class="smile s_berserk"></div>');
static String s_charm = b('<div class="smile s_charm"></div>');
static String s_curse = b('<div class="smile s_curse"></div>');
static String s_exchange = b('<div class="smile s_exchange"></div>');
static String s_haste = b('<div class="smile s_haste"></div>');
static String s_ice = b('<div class="smile s_ice"></div>');
static String s_iron = b('<div class="smile s_iron"></div>');
static String s_poison = b('<div class="smile s_poison"></div>');
static String s_revive = b('<div class="smile s_revive"></div>');
static String s_slow = b('<div class="smile s_slow"></div>');
static String s_counter = b('<div class="smile s_counter"></div>');
static String s_reflect = b('<div class="smile s_reflect"></div>');
static String s_upgrade = b('<div class="smile s_upgrade"></div>');
static String namerena_domain = b('deepmess.com/namerena');
static String namerena_help = b('https://deepmess.com/zh/namerena/');
}
2024-03-04 12:29:26 +08:00
void main() {
2024-03-05 22:34:27 +08:00
print(Dt.s_win);
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-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