Михаил Капелько il y a 1 an
Parent
révision
7f4e8bd09e
1 fichiers modifiés avec 35 ajouts et 12 suppressions
  1. +35
    -12
      web/memory.html

+ 35
- 12
web/memory.html Voir le fichier

@@ -5,6 +5,30 @@
</head>
<body>
</body>
<script>
function memorySide() {
return 50
}

function memorySpace() {
return 20
}

function memoryGap() {
return memorySide() + memorySpace()
}

function memoryItemPositions(M) {
var pos = [];
for (var i = 0; i < M.itemsCount; i++) {
let row = Math.floor(i / 4)
let x = memoryGap() + (i - row * 4) * memoryGap()
let y = memoryGap() + row * memoryGap()
pos.push([x, y])
}
return pos
}
</script>
<script>
var items = []

@@ -17,18 +41,17 @@
}

// SectionGrid.
let side = Number(50)
let space = Number(20)
let gap = Number(side + space)
for (var id in items) {
var item = items[id]
let row = Math.floor(id / 4)
let x = gap + (id - row * 4) * gap
let y = gap + row * gap
item.style.left = `${x}px`
item.style.top = `${y}px`
item.style.width = `${side}px`
item.style.height = `${side}px`
var M = {
itemsCount: items.length
};
let positions = memoryItemPositions(M);
for (var id in positions) {
var p = positions[id]
var item = items[id];
item.style.left = `${p[0]}px`
item.style.top = `${p[1]}px`
item.style.width = `${memorySide()}px`
item.style.height = `${memorySide()}px`
item.style.position = "absolute"
item.style.background = "blue"
}


Chargement…
Annuler
Enregistrer