-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project Upload | Front-end and functional arrangements will be made.
- Loading branch information
Showing
3 changed files
with
269 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
body{ | ||
background: rgb(102,208,40); | ||
background: linear-gradient(0deg, rgba(102,208,40,1) 0%, rgba(255,239,0,1) 100%); | ||
} | ||
|
||
g{ | ||
transition: all .2s; | ||
stroke-dasharray: 290; | ||
stroke-dashoffset: -40; | ||
animation: g 3s linear forwards; | ||
} | ||
svg g{ | ||
opacity: 1; | ||
transition: all 3s; | ||
} | ||
.removeElement{ | ||
opacity: 0.3; | ||
transition: all 3s; | ||
} | ||
g line{ | ||
stroke-width: 1px; | ||
fill: #333; | ||
stroke: #555; | ||
transition: all .2s; | ||
stroke-dasharray: 250; | ||
stroke-dashoffset: -30; | ||
animation: dash 3s linear forwards; | ||
} | ||
.line-delete{ | ||
transition: all .2s; | ||
stroke-dasharray: 250; | ||
stroke-dashoffset: 5; | ||
animation: animationDelete 3s linear alternate; | ||
} | ||
.line-delete ellipse{ | ||
stroke: red; | ||
} | ||
.line-won{ | ||
transition: all .2s; | ||
stroke-dasharray: 640; | ||
stroke-dashoffset: 982; | ||
animation: animationWon 3s linear alternate; | ||
} | ||
.g-won{ | ||
stroke: red; | ||
transition: all .2s; | ||
stroke-dasharray: 200; | ||
stroke-dashoffset: 50; | ||
animation: gWon 3s cubic-bezier(0.55, 0.06, 0.68, 0.19) alternate; | ||
} | ||
|
||
g{ | ||
stroke: red; | ||
fill: red; | ||
transition: all .2s; | ||
z-index: 111; | ||
} | ||
|
||
:not(svg) { | ||
transform-origin: 0px 0px; | ||
} | ||
|
||
.d-none{ | ||
display:none; | ||
transition: all .2s; | ||
} | ||
@keyframes dash { | ||
from{ | ||
stroke-dasharray: 5; | ||
stroke-dashoffset: -40; | ||
} | ||
to { | ||
stroke-dasharray: 290; | ||
stroke-dashoffset: -40; | ||
} | ||
} | ||
@keyframes g { | ||
from { | ||
stroke-dasharray: 5; | ||
stroke-dashoffset: 25; | ||
} | ||
to { | ||
stroke-dasharray: 250; | ||
stroke-dashoffset: 0; | ||
} | ||
} | ||
@keyframes animationDelete { | ||
from { | ||
stroke-dasharray: 5; | ||
stroke-dashoffset: 25; | ||
} | ||
to { | ||
stroke-dasharray: 250; | ||
stroke-dashoffset: 0; | ||
stroke: red; | ||
} | ||
} | ||
|
||
@keyframes animationWon{ | ||
from{ | ||
stroke-dasharray: 5; | ||
stroke-dashoffset: 25; | ||
} | ||
to{ | ||
stroke-dasharray: 640; | ||
stroke-dashoffset: 982; | ||
} | ||
} | ||
@keyframes gWon{ | ||
from{ | ||
stroke-dasharray: 5; | ||
stroke-dashoffset: 25; | ||
} | ||
to{ | ||
stroke-dasharray: 200; | ||
stroke-dashoffset: 50; | ||
} | ||
} | ||
|
||
.selectRange{ | ||
position: absolute; | ||
top: 0; | ||
left: 80px; | ||
transform: rotate(90deg)!important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
var inputControl = false; | ||
const sleep = (milliseconds) => { | ||
return new Promise(resolve => setTimeout(resolve, milliseconds)) | ||
} | ||
function josephProblemJs(l, d, controlVal){ | ||
let people = []; | ||
let deathPeople = []; | ||
var homosapiensSpace = 360 / controlVal; | ||
for (let i = 1; i <= l; i++){ | ||
people.push(i); | ||
} | ||
|
||
/*People Add Place - Start*/ | ||
const addPeople = async (callback) => { | ||
var yazdir = 1; | ||
for(let peopleSvg = 0; peopleSvg < 360; peopleSvg +=homosapiensSpace){ | ||
$('.cloneLine').clone().removeClass('cloneLine d-none').appendTo( "#ekle" ).attr('transform', "rotate("+ (peopleSvg+10)+", 500, 500)"); | ||
if(yazdir < 10){ | ||
$('#ekle g:nth-child('+yazdir+') text[text-anchor]').attr('x','35') | ||
}else{ | ||
$('#ekle g:nth-child('+yazdir+') text[text-anchor]').attr('x','30') | ||
} | ||
$('#ekle g:nth-child('+yazdir+') text[text-anchor]').text(yazdir) | ||
yazdir = yazdir+1; | ||
await sleep(20) | ||
} | ||
callback(); | ||
} | ||
/*People Add Place - Finish*/ | ||
|
||
while (people.length !== 1) { | ||
for (let i = 1; i < d; i++) { | ||
people.push(people.shift()); | ||
/* console.log(people) */ | ||
$('#ekle g:nth-child('+i+') text[text-anchor]').text(i) | ||
} | ||
deathPeople.push(people.shift()); | ||
/* console.log(deathPeople) */ | ||
|
||
} | ||
|
||
var time = 3000; | ||
const removePeople = async (callback) => { | ||
for(var i= 0; i < deathPeople.length; i++){ | ||
await sleep(time) | ||
$('#ekle g:nth-child('+deathPeople[i]+')').addClass("line-delete removeElement") | ||
time = 200; | ||
} | ||
callback(); | ||
} | ||
|
||
|
||
addPeople(removePeople); | ||
|
||
const wonPerson = async (callback) => { | ||
await sleep(1000) | ||
$('#ekle g:nth-child('+people[0]+')').addClass('g-won'); | ||
$('#ekle g:nth-child('+people[0]+') ellipse').addClass('g-won').attr('cx','300') | ||
$('#ekle g:nth-child('+people[0]+') line').addClass('line-won') | ||
$('#ekle g:nth-child('+people[0]+') text[text-anchor]').addClass('line-won').attr('x','295').attr('transform', 'rotate(213 300, 500)') | ||
$('#peopleRange').removeAttr('disabled'); | ||
callback(); | ||
} | ||
|
||
removePeople(wonPerson); | ||
|
||
|
||
/* console.log("Death order is " + deathPeople.join(" ")); */ | ||
return people[0]; //survivor | ||
} | ||
$('.josephBtn').click(function(){ | ||
$('#ekle').html('') | ||
var inputControl = $('#inputJoseph').val(); | ||
/* console.log("Hayatta kalan = " + josephProblemJs(inputControl, 2)) */ | ||
josephProblemJs(inputControl, 2, inputControl) | ||
}) | ||
$('#peopleRange').click(function(){ | ||
$('#peopleRange').attr('disabled', 'disabled'); | ||
$('#ekle').html(''); | ||
var rangeVal = $(this).val(); | ||
|
||
josephProblemJs(rangeVal, 2, rangeVal) | ||
console.log(inputControl) | ||
if(inputControl == true){ | ||
$(this).attr('disabled'); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Josephus Problem | Fun solution with Javascript</title> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="assets/main.css"></link> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12 selectRange w-50"> | ||
<label for="peopleRange">Select Range</label> | ||
<input type="range" min="0" max="100" class="custom-range" id="peopleRange"> | ||
</div> | ||
<div class="col-12 "> | ||
<div class="input-group mt-3 mb-2"> | ||
<input type="text" id="inputJoseph" class="form-control" placeholder="How Many People Would You Like To Play With?" aria-describedby="basic-addon2"> | ||
<div class="input-group-append"> | ||
<button class="btn btn-outline-secondary josephBtn" type="button">Start Game</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-12"> | ||
<svg width="1000" height="1000" id="ekle" xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
xmlns:cc="http://creativecommons.org/ns#" | ||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
xmlns:svg="http://www.w3.org/2000/svg" | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | ||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" | ||
inkscape:version="0.48.2 r9819" | ||
sodipodi:docname="chars.svg"> | ||
</svg> | ||
<svg class="d-none"> | ||
<g class="d-none node cloneG" cx="500" cy="500" transform="translate(500,500)"><circle r="50"></circle> | ||
</svg> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<svg> | ||
<g transform="rotate(0 500 500)" class="d-none cloneLine"> | ||
<line id="svg_1" y2="500" x2="500" y1="500" x1="0" stroke-width="1.5" stroke="#000" fill="none"></line> | ||
<ellipse ry="20" rx="20" id="svg_2" cy="500" cx="40" stroke-width="5.5" stroke="#000" fill="#fff"></ellipse> | ||
<text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="18" id="svg_3" y="506" x="30" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000"></text> | ||
</g> | ||
</svg> | ||
</div> | ||
</div> | ||
|
||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> | ||
<script src="assets/main.js"></script> | ||
</body> | ||
</html> |