Added Google Foobar and DOJC Songs
This commit is contained in:
commit
784563309e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
__pycache__/
|
||||
10
DOJC Songs/.htaccess
Normal file
10
DOJC Songs/.htaccess
Normal file
@ -0,0 +1,10 @@
|
||||
Options +Indexes
|
||||
IndexOptions IgnoreCase FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* SuppressHTMLPreamble
|
||||
RewriteEngine On
|
||||
|
||||
Header set Access-Control-Allow-Origin "*"
|
||||
|
||||
# SPECIFY HEADER FILE
|
||||
HeaderName /header.html
|
||||
# IGNORE THESE FILES
|
||||
IndexIgnore /header.html /api.php
|
||||
80
DOJC Songs/api.floofy.php
Normal file
80
DOJC Songs/api.floofy.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if(isset($_POST['getdir']) && !empty($_POST['getdir'])) {
|
||||
$dir = $_POST['getdir'];
|
||||
echo json_encode((listDir($dir[0],$dir[1])));
|
||||
}
|
||||
|
||||
if(isset($_POST['rootdir']) && !empty($_POST['rootdir'])) {
|
||||
echo json_encode('/Database'.'/');
|
||||
}
|
||||
|
||||
function listDir($relroot,$section) {
|
||||
$folder = getcwd().$relroot;
|
||||
$paths = scandir($folder);
|
||||
$ext = array("ext");
|
||||
$mod = array("mod");
|
||||
$size = array("size");
|
||||
|
||||
$paths = array_slice($paths,$section*100,100);
|
||||
|
||||
foreach ($paths as $dir) {
|
||||
$realdir = $folder.'/'.$dir;
|
||||
if(is_dir($realdir)) {
|
||||
$ext[] = 'true';
|
||||
$size[] = "- - - -";
|
||||
} else {
|
||||
$ext[] = 'false';
|
||||
$size[] = human_filesize(filesize($realdir));
|
||||
}
|
||||
$mod[] = date ("F d, Y", filemtime($realdir));
|
||||
}
|
||||
|
||||
$results[] = $paths;
|
||||
$results[] = $ext;
|
||||
$results[] = $mod;
|
||||
$results[] = $size;
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function human_filesize($bytes, $decimals = 2) {
|
||||
$sz = 'BKMGTP';
|
||||
$factor = floor((strlen($bytes) - 1) / 3);
|
||||
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor].'B';
|
||||
}
|
||||
|
||||
/*function scan_dir($path){
|
||||
$ite=new RecursiveDirectoryIterator($path);
|
||||
|
||||
$bytestotal=0;
|
||||
$nbfiles=0;
|
||||
foreach (new RecursiveIteratorIterator($ite) as $filename=>$cur) {
|
||||
$filesize=$cur->getSize();
|
||||
$bytestotal+=$filesize;
|
||||
$nbfiles++;
|
||||
$files[] = $filename;
|
||||
}
|
||||
|
||||
$bytestotal=number_format($bytestotal);
|
||||
|
||||
return array('total'=>$nbfiles,'size'=>$bytestotal,'files'=>$files);
|
||||
}
|
||||
|
||||
$files = scan_dir('/home/discordo/public_html/subdomain/music_dir/');
|
||||
$subtract = 0;
|
||||
for($mp3 = 0; $mp3 <= 100; $mp3++) {
|
||||
if (strpos($files['files'][$mp3], '.mp3') == false) {
|
||||
if (isset($files['files'][$mp3])) {
|
||||
unset($files['files'][$mp3]);
|
||||
$subtract++;
|
||||
};
|
||||
};
|
||||
};
|
||||
$files['total'] = $files['total'] - $subtract;
|
||||
|
||||
$json = json_encode($files);
|
||||
printf($json);*/
|
||||
80
DOJC Songs/api.php
Normal file
80
DOJC Songs/api.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if(isset($_POST['getdir']) && !empty($_POST['getdir'])) {
|
||||
$dir = $_POST['getdir'];
|
||||
echo json_encode((listDir($dir[0],$dir[1])));
|
||||
}
|
||||
|
||||
if(isset($_POST['rootdir']) && !empty($_POST['rootdir'])) {
|
||||
echo json_encode('/Database'.'/');
|
||||
}
|
||||
|
||||
function listDir($relroot,$section) {
|
||||
$folder = getcwd().$relroot;
|
||||
$paths = scandir($folder);
|
||||
$ext = array("ext");
|
||||
$mod = array("mod");
|
||||
$size = array("size");
|
||||
|
||||
$paths = array_slice($paths,$section*100,100);
|
||||
|
||||
foreach ($paths as $dir) {
|
||||
$realdir = $folder.'/'.$dir;
|
||||
if(is_dir($realdir)) {
|
||||
$ext[] = 'true';
|
||||
$size[] = "- - - -";
|
||||
} else {
|
||||
$ext[] = 'false';
|
||||
$size[] = human_filesize(filesize($realdir));
|
||||
}
|
||||
$mod[] = date ("F d, Y", filemtime($realdir));
|
||||
}
|
||||
|
||||
$results[] = $paths;
|
||||
$results[] = $ext;
|
||||
$results[] = $mod;
|
||||
$results[] = $size;
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function human_filesize($bytes, $decimals = 2) {
|
||||
$sz = 'BKMGTP';
|
||||
$factor = floor((strlen($bytes) - 1) / 3);
|
||||
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor].'B';
|
||||
}
|
||||
|
||||
function scan_dir($path){
|
||||
$ite=new RecursiveDirectoryIterator($path);
|
||||
|
||||
$bytestotal=0;
|
||||
$nbfiles=0;
|
||||
foreach (new RecursiveIteratorIterator($ite) as $filename=>$cur) {
|
||||
$filesize=$cur->getSize();
|
||||
$bytestotal+=$filesize;
|
||||
$nbfiles++;
|
||||
$files[] = $filename;
|
||||
}
|
||||
|
||||
$bytestotal=number_format($bytestotal);
|
||||
|
||||
return array('total'=>$nbfiles,'size'=>$bytestotal,'files'=>$files);
|
||||
}
|
||||
|
||||
$files = scan_dir('/home/discordo/public_html/subdomain/music_dir/Database');
|
||||
$subtract = 0;
|
||||
for($mp3 = 0; $mp3 <= 100; $mp3++) {
|
||||
if (strpos($files['files'][$mp3], '.mp3') == false) {
|
||||
if (isset($files['files'][$mp3])) {
|
||||
unset($files['files'][$mp3]);
|
||||
$subtract++;
|
||||
};
|
||||
};
|
||||
};
|
||||
$files['total'] = $files['total'] - $subtract;
|
||||
|
||||
$json = json_encode($files);
|
||||
printf($json);
|
||||
455
DOJC Songs/desktop/desktop.css
Normal file
455
DOJC Songs/desktop/desktop.css
Normal file
@ -0,0 +1,455 @@
|
||||
html {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
body {
|
||||
display: grid;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
color: white;
|
||||
font-family: 'Open Sans Condensed', sans-serif;
|
||||
grid-template-columns: 15% auto;
|
||||
grid-template-rows: 8% auto;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #2EA8FF;
|
||||
}
|
||||
|
||||
.transition {
|
||||
-webkit-transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
-moz-transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
-ms-transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
}
|
||||
|
||||
#header1 {
|
||||
display: grid;
|
||||
background-color: #292828;
|
||||
text-align: center;
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#header1 img {
|
||||
margin: auto;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
#header2 {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
background-color: #151313;
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
#header2 div {
|
||||
margin: auto;
|
||||
font-size: 150%;
|
||||
}
|
||||
|
||||
#header2 p {
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
padding: 5%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#header2 p:hover {
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
#header2 i {
|
||||
margin-left: 2%;
|
||||
}
|
||||
|
||||
#spectrum {
|
||||
grid-column: 5;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
position: relative;
|
||||
background-color: #151313;
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
#sidebar span {
|
||||
font-size: 110%;
|
||||
padding: 5%;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#sidebar span p {
|
||||
cursor: pointer;
|
||||
color: #63d4ff;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.navi {
|
||||
display: grid;
|
||||
height: 6vh;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
grid-template-columns: 1fr 3fr 7fr;
|
||||
}
|
||||
|
||||
.naviInner {
|
||||
background-color: rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.naviInner div {
|
||||
display: grid;
|
||||
height: 4vh;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
grid-template-columns: 3fr 7fr;
|
||||
}
|
||||
|
||||
.navi:hover, .naviInner div:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1) !important
|
||||
}
|
||||
|
||||
.navi i {
|
||||
margin: auto 0 auto 0;
|
||||
font-size: 2.1vh;
|
||||
text-align: center;
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
.navi p {
|
||||
margin: auto 0 auto 0;
|
||||
font-size: 2vh;
|
||||
grid-column: 3;
|
||||
}
|
||||
|
||||
.naviInner p {
|
||||
margin: auto 0 auto 0;
|
||||
font-size: 2vh;
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
#mainContainer {
|
||||
overflow: hidden;
|
||||
background-color: #070606;
|
||||
font-family: 'Saira Condensed', sans-serif;
|
||||
grid-column: 2;
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
.card {
|
||||
display: grid;
|
||||
border-radius: 2px;
|
||||
background-color: #FEFEFE;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
color: black;
|
||||
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
grid-template-columns: 35% auto 25% 15%;
|
||||
grid-template-rows: 6vh auto;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
|
||||
}
|
||||
|
||||
#songList {
|
||||
height: 100%;
|
||||
color: white;
|
||||
display: grid;
|
||||
grid-template-columns: 100%;
|
||||
grid-template-rows: 90% 10%;
|
||||
}
|
||||
|
||||
#directory {
|
||||
display: grid;
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
grid-template-columns: 100%;
|
||||
grid-template-rows: 1fr 2fr 20fr 5fr;
|
||||
}
|
||||
|
||||
#directory p {
|
||||
font-size: 150%;
|
||||
padding: 1.5vh 2vh 1.5vh 2vh;
|
||||
}
|
||||
|
||||
canvas {
|
||||
display: none;
|
||||
grid-column: 1;
|
||||
grid-row: 4;
|
||||
}
|
||||
|
||||
#playback {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
#directoryHeader {
|
||||
display: grid;
|
||||
grid-template-columns: 6fr 2fr 1fr;
|
||||
grid-template-rows: 100%;
|
||||
color: black;
|
||||
background-color: white;
|
||||
box-shadow: #6f6f6f 0 0 20px 0px;
|
||||
}
|
||||
|
||||
#directoryHeader p {
|
||||
display: grid;
|
||||
cursor: pointer;
|
||||
grid-template-columns: 19fr 1fr;
|
||||
grid-template-rows: 100%;
|
||||
padding: 2.3vh;
|
||||
}
|
||||
|
||||
#directoryHeader p:hover {
|
||||
background-color: rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
#directoryHeader i {
|
||||
margin: auto;
|
||||
display: none;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#directoryCont {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: grid;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid white;
|
||||
background-color: rgba(255,255,255,0.03);
|
||||
grid-template-columns: 6fr 2fr 1fr;
|
||||
grid-template-rows: 100%;
|
||||
}
|
||||
|
||||
.item:hover {
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
.item p {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#directoryLocation {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#directoryLocation p {
|
||||
padding: 0.5vh;
|
||||
margin: 1vh 1.5vh 1vh 1.5vh;
|
||||
border-radius: 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#directoryLocation i {
|
||||
font-size: 150%;
|
||||
}
|
||||
|
||||
.subdir:hover {
|
||||
background-color: rgba(255,255,255, 0.1);
|
||||
}
|
||||
|
||||
#playback {
|
||||
display: grid;
|
||||
grid-template-columns: 30% 40% 15% 15%;
|
||||
grid-template-rows: 100%;
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
audio {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#playback div {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
#playback h2 {
|
||||
font-size: 2.3vh;
|
||||
margin: auto 5% auto;
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
#playback i {
|
||||
font-size: 2.3vh;
|
||||
}
|
||||
|
||||
#info {
|
||||
grid-template-columns: 9fr 1fr;
|
||||
grid-template-rows: 100%;
|
||||
}
|
||||
|
||||
#info div {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
#info a {
|
||||
cursor: pointer;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#info i {
|
||||
color: rgba(255,255,255,1);
|
||||
}
|
||||
|
||||
#info i:hover {
|
||||
color: rgba(255,255,255,0.7);
|
||||
}
|
||||
|
||||
#tracker {
|
||||
grid-template-columns: 100%;
|
||||
grid-template-rows: 1fr 1fr;
|
||||
}
|
||||
|
||||
#tracker div:first-child {
|
||||
margin: auto;
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#tracker i {
|
||||
margin: auto;
|
||||
cursor: pointer;
|
||||
padding: 0 3% 0 3%;
|
||||
|
||||
}
|
||||
|
||||
#tracker i:hover {
|
||||
color: rgba(255,255,255,0.7);
|
||||
}
|
||||
|
||||
#bar {
|
||||
display: grid;
|
||||
grid-template-columns: 10% 80% 10%;
|
||||
grid-template-rows: 100%;
|
||||
}
|
||||
|
||||
#bar p {
|
||||
padding: 0 0 0 10%;
|
||||
margin: auto 0 auto 0;
|
||||
}
|
||||
|
||||
#bar p:first-child {
|
||||
padding: 0 10% 0 0;
|
||||
margin: auto 0 auto 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#speed, #volume {
|
||||
grid-template-columns: 20% 80%;
|
||||
grid-template-rows: 100%;
|
||||
padding: 10%;
|
||||
}
|
||||
|
||||
#speed i, #volume i {
|
||||
margin: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#speed i:hover, #volume i:hover {
|
||||
color: rgba(255,255,255,0.6);
|
||||
}
|
||||
|
||||
input[type=range] {
|
||||
-webkit-appearance: none;
|
||||
width: 100%;
|
||||
margin: 3px 0;
|
||||
background: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
input[type=range]:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
input[type=range]::-webkit-slider-runnable-track {
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
cursor: pointer;
|
||||
background: #63d4ff;
|
||||
}
|
||||
|
||||
input[type=range]::-webkit-slider-thumb {
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
border-radius: 50px;
|
||||
background-color: white;
|
||||
cursor: pointer;
|
||||
-webkit-appearance: none;
|
||||
margin-top: -3px;
|
||||
}
|
||||
|
||||
input[type=range]::-moz-range-track {
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
cursor: pointer;
|
||||
background: #63d4ff;
|
||||
}
|
||||
|
||||
input[type=range]::-moz-range-thumb {
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
border-radius: 50px;
|
||||
background: #ffffff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type=range]::-ms-track {
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
input[type=range]::-ms-fill-lower {
|
||||
background: #395373;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
input[type=range]::-ms-fill-upper {
|
||||
background: #486992;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
input[type=range]::-ms-thumb {
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
border-radius: 50px;
|
||||
background: #ffffff;
|
||||
cursor: pointer;
|
||||
height: 7px;
|
||||
}
|
||||
|
||||
input[type=range]:focus::-ms-fill-lower {
|
||||
background: #486992;
|
||||
}
|
||||
|
||||
input[type=range]:focus::-ms-fill-upper {
|
||||
background: #5a7fae;
|
||||
}
|
||||
73
DOJC Songs/desktop/desktop.html
Normal file
73
DOJC Songs/desktop/desktop.html
Normal file
@ -0,0 +1,73 @@
|
||||
<body>
|
||||
<div id="header1" class="transition">
|
||||
<img src="./logo.png">
|
||||
</div>
|
||||
<div id="header2">
|
||||
<div id="spectrum">
|
||||
<p class="transition">Spectrum <i class="fa fa-times-circle" aria-hidden="true"></i></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="sidebar">
|
||||
<span>Developed by <p onclick="window.open('http://discordonlinejammingcentral.com/user-3.html','_blank')">ksjdragon</p></span>
|
||||
</div>
|
||||
<div id="mainContainer">
|
||||
<div id="songList">
|
||||
<div id="directory">
|
||||
<div id="directoryLocation" class="transition">
|
||||
<p>DOJC Mixtapes</p>
|
||||
</div>
|
||||
<div id="directoryHeader">
|
||||
<p class="name transition">Name
|
||||
<i class="fa fa-chevron-down transition"></i>
|
||||
<i class="fa fa-chevron-up transition"></i>
|
||||
</p>
|
||||
<p class="date transition">Date Modified
|
||||
<i class="fa fa-chevron-down transition"></i>
|
||||
<i class="fa fa-chevron-up transition"></i>
|
||||
</p>
|
||||
<p class="size transition">Size
|
||||
<i class="fa fa-chevron-down transition"></i>
|
||||
<i class="fa fa-chevron-up transition"></i>
|
||||
</p>
|
||||
</div>
|
||||
<div id="directoryCont">
|
||||
|
||||
</div>
|
||||
<canvas id="visualize" width="1200" height="250"></canvas>
|
||||
</div>
|
||||
<div id="playback">
|
||||
<div id="info">
|
||||
<div>
|
||||
<h2></h2>
|
||||
</div>
|
||||
<div>
|
||||
<a download><i class="fa fa-download transition"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tracker">
|
||||
<div>
|
||||
<i id="prev" class="fa fa-step-backward" aria-hidden="true"></i>
|
||||
<i id="pause" class="fa fa-pause-circle transition"></i>
|
||||
<i id="next" class="fa fa-step-forward" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div id="bar">
|
||||
<p>-:--</p>
|
||||
<input type="range" min="0", max="100000" value="0">
|
||||
<p>-:--</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="speed">
|
||||
<i class="fa fa-fast-forward transition"></i>
|
||||
<input type="range" min="0", max="100" value="25">
|
||||
</div>
|
||||
<div id="volume">
|
||||
<i class="fa fa-volume-up transition"></i>
|
||||
<input type="range" min="0", max="100" value="100">
|
||||
</div>
|
||||
<audio controls>
|
||||
<source src="">
|
||||
</audio>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
556
DOJC Songs/desktop/desktop.js
Normal file
556
DOJC Songs/desktop/desktop.js
Normal file
@ -0,0 +1,556 @@
|
||||
var data, // Stores data from PHP.
|
||||
vis,
|
||||
section = 0,
|
||||
clickable = true,
|
||||
selectName, // Stores name of folder in selected div
|
||||
selectDiv, // Stores actual selected div.
|
||||
currDir = "",
|
||||
spectrum = false; // Stores enable spectrum option.
|
||||
|
||||
var sort = {
|
||||
"name": 1,
|
||||
"date": 1,
|
||||
"size": 1,
|
||||
};
|
||||
var audioSettings = {
|
||||
speed: 1,
|
||||
volume: 1,
|
||||
mute: false
|
||||
};
|
||||
|
||||
var themeColors = { // For reference and for quick changing if need-be.
|
||||
"main": "#070606",
|
||||
"sidebar": "#151313",
|
||||
"highlight": "#63d4ff"
|
||||
};
|
||||
|
||||
var navSelect = "songList"; // In the future, this can be dynamically updated, but for demonstration purposes, this is set.
|
||||
var subNavSelect = "";
|
||||
|
||||
var navi = [ // Necessary arguments: id, alias, fa | Optional arguments: subnav.
|
||||
{
|
||||
"id": "home",
|
||||
"alias": "Home",
|
||||
"fa": "home"
|
||||
},
|
||||
{
|
||||
"id": "forums",
|
||||
"alias": "Forums",
|
||||
"fa": "file"
|
||||
},
|
||||
{
|
||||
"id": "memberList",
|
||||
"alias": "Member List",
|
||||
"fa": "users"
|
||||
},
|
||||
{
|
||||
"id": "calendar",
|
||||
"alias": "Calendar",
|
||||
"fa": "calendar"
|
||||
},
|
||||
{
|
||||
"id": "help",
|
||||
"alias": "Help",
|
||||
"fa": "info-circle"
|
||||
},
|
||||
{
|
||||
"id": "songList",
|
||||
"alias": "Song List",
|
||||
"fa": "music"
|
||||
}
|
||||
];
|
||||
|
||||
function getData() {
|
||||
$.when($.ajax({
|
||||
type : 'POST',
|
||||
url: 'api.floofy.php',
|
||||
data: {rootdir: 'rootdir'}
|
||||
})).done(function(d) {
|
||||
rootDir = d;
|
||||
checkHash();
|
||||
});
|
||||
}
|
||||
|
||||
function listDir(dir, sec) { // Directory is the sub-directory, sec is the section of data, if files need to be split up into sections.
|
||||
var real = rootDir+dir;
|
||||
$.when($.ajax({
|
||||
type : 'POST',
|
||||
url: 'api.floofy.php',
|
||||
data: {getdir : [real, sec]},
|
||||
})).done(function(d) {
|
||||
data = d;
|
||||
if(data[0] === null) {
|
||||
currDir = "";
|
||||
listDir(currDir, 0);
|
||||
return;
|
||||
}
|
||||
if(sec == 0) {
|
||||
data[0].splice(0,2);
|
||||
data[1].splice(0,3);
|
||||
data[2].splice(0,3);
|
||||
data[3].splice(0,3);
|
||||
} else {
|
||||
data[1].splice(0,1);
|
||||
data[2].splice(0,1);
|
||||
data[3].splice(0,1);
|
||||
}
|
||||
var toObj = [];
|
||||
for(var i = 0; i < data[0].length; i++) {
|
||||
toObj.push({
|
||||
name: data[0][i],
|
||||
folder: data[1][i],
|
||||
date: data[2][i],
|
||||
size: data[3][i]
|
||||
});
|
||||
}
|
||||
data = toObj;
|
||||
sortFiles("name", -1);
|
||||
clickable = true;
|
||||
});
|
||||
}
|
||||
|
||||
function stringToDate(str) {
|
||||
var dt;
|
||||
dt = str.replace(",","").split(" ");
|
||||
dt = Date.parse(dt[1] + " " + dt[0] + " " + dt[2]);
|
||||
return dt;
|
||||
}
|
||||
|
||||
function sortFiles(type, direction) {
|
||||
switch(type) {
|
||||
case "name":
|
||||
data.sort(function(a, b){ return (a.name < b.name) ? direction*1 : direction*-1;});
|
||||
break;
|
||||
case "date":
|
||||
data.sort(function(a, b){
|
||||
a = stringToDate(a.date);
|
||||
b = stringToDate(b.date);
|
||||
|
||||
return (a < b) ? direction*1 : direction*-1;
|
||||
});
|
||||
break;
|
||||
case "size":
|
||||
data.sort(function(a, b){ return (a.size.replace("B","").substring(0, a.size.length-1) < b.size.replace("B","").substring(0, b.size.length-1)) ? direction*1 : direction*-1;});
|
||||
}
|
||||
var ico = document.querySelectorAll("#directoryHeader i");
|
||||
for(var i = 0; i < ico.length; i++) {
|
||||
ico[i].style.opacity = "0";
|
||||
}
|
||||
setTimeout(function() {
|
||||
for(var i = 0; i < ico.length; i++) {
|
||||
ico[i].style.display = "none";
|
||||
}
|
||||
var arrow = document.querySelectorAll("#directoryHeader ."+type+" i.fa-chevron-" + ((direction < 0) ? "up" : "down"))[0];
|
||||
arrow.style.display = "block"
|
||||
setTimeout(function() {
|
||||
arrow.style.opacity = "1";
|
||||
}, 1);
|
||||
}, 300);
|
||||
try {
|
||||
clearTbl();
|
||||
setTimeout(function() {
|
||||
document.getElementById("directory").removeChild(document.getElementById("directoryCont"));
|
||||
dispDir();
|
||||
}, 300);
|
||||
} catch(err) {
|
||||
dispDir();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function dispDir() {
|
||||
updateLocation();
|
||||
try {
|
||||
document.getElementById("directory").removeChild(document.getElementById("directoryCont"));
|
||||
} catch(err) {}
|
||||
var cont = document.createElement("div");
|
||||
cont.id = "directoryCont";
|
||||
cont.style.opacity = "0";
|
||||
cont.className = "transition";
|
||||
|
||||
selectName = "";
|
||||
var item;
|
||||
if(data.length === 0) {
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode("Nothing here!"));
|
||||
p.style.fontWeight = "100";
|
||||
cont.appendChild(p);
|
||||
}
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
item = createRow();
|
||||
|
||||
var curr = data[i];
|
||||
var name = document.createTextNode(curr.name);
|
||||
var modified = document.createTextNode(curr.date);
|
||||
var size = document.createTextNode(curr.size);
|
||||
|
||||
item.childNodes[0].appendChild(name);
|
||||
if((new Date() - stringToDate(curr.date)) < 604800000) item.childNodes[0].style.color = "#63d4ff";
|
||||
item.childNodes[1].appendChild(modified);
|
||||
item.childNodes[2].appendChild(size);
|
||||
|
||||
var ext = document.createAttribute("ext");
|
||||
|
||||
if(curr.folder == "true") {
|
||||
ext.value = "fol";
|
||||
} else {
|
||||
ext.value = curr.name.substring(curr.name.lastIndexOf(".")+1,curr.name.length).toLowerCase();
|
||||
}
|
||||
item.setAttributeNode(ext);
|
||||
|
||||
item.onclick = function() {
|
||||
if(clickable == true) {
|
||||
var name = this.childNodes[0].innerText;
|
||||
url = getURI(name);
|
||||
if(selectName == name) {
|
||||
clickable = false;
|
||||
attr = this.getAttribute("ext");
|
||||
if(attr == "fol") {
|
||||
clearTbl();
|
||||
setTimeout(function() {
|
||||
currDir += name+"/";
|
||||
listDir(currDir,0);
|
||||
}, 300)
|
||||
return;
|
||||
} else {
|
||||
playFile(url, name);
|
||||
clickable = true;
|
||||
}
|
||||
}
|
||||
selectName = name;
|
||||
selectDiv = this;
|
||||
for(var i =0; i < document.getElementsByClassName("item").length;i++){
|
||||
document.getElementsByClassName("item")[i].style.backgroundColor = "";
|
||||
}
|
||||
this.style.backgroundColor = "rgba(255,255,255,0.2)";
|
||||
}
|
||||
}
|
||||
cont.appendChild(item);
|
||||
item = null;
|
||||
}
|
||||
document.getElementById("directory").appendChild(cont);
|
||||
setTimeout(function() {
|
||||
document.getElementById("directoryCont").style.opacity = "1";
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function clearTbl() {
|
||||
selected = undefined;
|
||||
selectDiv = undefined;
|
||||
document.getElementById("directoryCont").style.opacity = "0";
|
||||
document.getElementById("directoryLocation").style.opacity = "0";
|
||||
}
|
||||
|
||||
function createRow() {
|
||||
var item = document.createElement("div");
|
||||
item.className = "item transition";
|
||||
var name = document.createElement("p");
|
||||
name.className = "name";
|
||||
item.appendChild(name);
|
||||
var modified = document.createElement("p");
|
||||
modified.className = "modified";
|
||||
item.appendChild(modified);
|
||||
var size = document.createElement("p");
|
||||
size.className = "size";
|
||||
item.appendChild(size);
|
||||
return item;
|
||||
}
|
||||
|
||||
function updateLocation() {
|
||||
window.location.hash = currDir.replace(/[\/]+/g,"*").replace(/ /g, "_");
|
||||
var loc = document.getElementById("directoryLocation");
|
||||
while(loc.firstChild) loc.removeChild(loc.firstChild);
|
||||
loc.style.opacity = "1";
|
||||
var subdir = currDir.split("/");
|
||||
subdir = subdir.slice(0, subdir.length-1);
|
||||
for(var i = 0; i < subdir.length+1; i++) {
|
||||
var p = document.createElement("p");
|
||||
var ic = document.createElement("i");
|
||||
ic.className = "fa fa-angle-right";
|
||||
if(i !== 0) loc.appendChild(ic);
|
||||
if(i === 0) {
|
||||
p.appendChild(document.createTextNode("DOJC Mixtapes"));
|
||||
} else {
|
||||
p.appendChild(document.createTextNode(subdir[i-1]));
|
||||
}
|
||||
if(i !== subdir.length) {
|
||||
p.style.cursor = "pointer";
|
||||
p.className = "subdir transition";
|
||||
p.onclick = function() {
|
||||
clickable = false;
|
||||
clearTbl();
|
||||
subdirNum = subdir.indexOf(this.innerText);
|
||||
if(subdirNum === -1) {
|
||||
currDir = "";
|
||||
} else {
|
||||
currDir = subdir.slice(0, subdirNum+1).reduce(function(a,b) { return a+"/"+b; })+"/";
|
||||
}
|
||||
listDir(currDir, 0);
|
||||
}
|
||||
}
|
||||
loc.appendChild(p);
|
||||
}
|
||||
}
|
||||
|
||||
function getURI(name) {
|
||||
var dirs = (rootDir+currDir+name).split("/");
|
||||
var uri = window.location.origin;
|
||||
for(var i = 1; i < dirs.length; i++) uri+="/"+encodeURIComponent(dirs[i]);
|
||||
return uri;
|
||||
}
|
||||
|
||||
function createNav() {
|
||||
for (var i = 0; i < navi.length; i++) { // Create navigation tabs.
|
||||
var side = document.getElementById("sidebar");
|
||||
var div = document.createElement("div");
|
||||
div.className = "navi transition";
|
||||
div.setAttribute("option", navi[i].id);
|
||||
div.onclick = function() {
|
||||
var op = this.getAttribute("option");
|
||||
if (navSelect === op) return;
|
||||
updateMain(op);
|
||||
};
|
||||
var ic = document.createElement("i");
|
||||
ic.className = "fa fa-" + navi[i].fa;
|
||||
ic["aria-hidden"] = true;
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode(navi[i].alias));
|
||||
div.appendChild(ic);
|
||||
div.appendChild(p);
|
||||
side.appendChild(div);
|
||||
var subNav = navi[i].subNav;
|
||||
if(!subNav) continue;
|
||||
|
||||
var subNavCont = document.createElement("div");
|
||||
subNavCont.className = "naviInner";
|
||||
subNavCont.setAttribute("option", navi[i].id);
|
||||
for(var j = 0; j < subNav.length; j++) {
|
||||
var eachSubNav = document.createElement("div");
|
||||
eachSubNav.className = "transition";
|
||||
eachSubNav.setAttribute("option", navi[i].id+"&"+subNav[j].id);
|
||||
eachSubNav.onclick = function() {
|
||||
var op = this.getAttribute("option");
|
||||
if(subNavSelect === op) return;
|
||||
updateMain(op);
|
||||
}
|
||||
var p2 = document.createElement("p");
|
||||
p2.appendChild(document.createTextNode(subNav[j].alias));
|
||||
eachSubNav.appendChild(p2);
|
||||
subNavCont.appendChild(eachSubNav);
|
||||
}
|
||||
side.appendChild(subNavCont);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNav(op) { // Updates the sidebar navigation (if naviagation tabs are ever dynamically implemented).
|
||||
var oldNav = document.querySelectorAll("[option=" + navSelect + "]")[0];
|
||||
var newNav = document.querySelectorAll("[option=" + op + "]")[0];
|
||||
oldNav.style.backgroundColor = "rgba(0,0,0,0)";
|
||||
oldNav.style.color = "white";
|
||||
newNav.style.backgroundColor = themeColors.main;
|
||||
newNav.style.color = themeColors.highlight;
|
||||
}
|
||||
|
||||
function updateMain(op) { // Updates the actual page.
|
||||
updateNav(op);
|
||||
switch(op) {
|
||||
case "home":
|
||||
window.location = "http://discordonlinejammingcentral.com/";
|
||||
break;
|
||||
case "forums":
|
||||
window.location = "http://discordonlinejammingcentral.com/";
|
||||
break;
|
||||
case "memberList":
|
||||
window.location = "http://discordonlinejammingcentral.com/memberlist.php";
|
||||
break;
|
||||
case "calendar":
|
||||
window.location = "http://discordonlinejammingcentral.com/calendar.php";
|
||||
break;
|
||||
case "help":
|
||||
window.location = "http://discordonlinejammingcentral.com/misc.php?action=help";
|
||||
break;
|
||||
case "songList":
|
||||
// Implement if dynamic
|
||||
break;
|
||||
}
|
||||
navSelect = op;
|
||||
}
|
||||
|
||||
function sortButtons() {
|
||||
document.querySelectorAll("#directoryHeader .name")[0].onclick = function() {
|
||||
sort.name = sort.name * -1;
|
||||
sortFiles("name", sort.name);
|
||||
};
|
||||
document.querySelectorAll("#directoryHeader .date")[0].onclick = function() {
|
||||
sort.date = sort.date * -1;
|
||||
sortFiles("date", sort.date);
|
||||
};
|
||||
document.querySelectorAll("#directoryHeader .size")[0].onclick = function() {
|
||||
sort.size = sort.size * -1;
|
||||
sortFiles("size", sort.size);
|
||||
};
|
||||
}
|
||||
|
||||
function visualize(url) {
|
||||
if(!spectrum) return;
|
||||
vis = new Visualizer();
|
||||
vis.ini();
|
||||
vis._visualize(url, document.getElementById("visualize"), document.getElementsByTagName("audio")[0]);
|
||||
}
|
||||
|
||||
function playFile(url, name) {
|
||||
var audio = document.getElementsByTagName("audio")[0];
|
||||
document.querySelectorAll("#playback h2")[0].innerText = name;
|
||||
document.querySelectorAll("#info a")[0].href = url;
|
||||
audio.src = url;
|
||||
document.querySelectorAll("#speed i")[0].click();
|
||||
audio.play();
|
||||
if(vis) {
|
||||
(spectrum) ? vis._restart() : vis._stop();
|
||||
} else {
|
||||
visualize(url);
|
||||
}
|
||||
}
|
||||
|
||||
function checkHash() {
|
||||
if(window.location.hash) {
|
||||
currDir = window.location.hash.replace(/[_]+/g, " ").replace(/[\*]+/g,"/").replace("#","");
|
||||
}
|
||||
listDir(currDir,0);
|
||||
window.location.hash = "";
|
||||
}
|
||||
|
||||
function audioControls() {
|
||||
var audio = document.getElementsByTagName("audio")[0];
|
||||
document.querySelectorAll("#speed input")[0].oninput = function() {
|
||||
audioSettings.speed = (this.value/50) + 0.5;
|
||||
audio.playbackRate = audioSettings.speed;
|
||||
};
|
||||
document.querySelectorAll("#speed i")[0].onclick = function() {
|
||||
audio.playbackRate = 1;
|
||||
document.querySelectorAll("#speed input")[0].value = "25";
|
||||
};
|
||||
document.querySelectorAll("#volume input")[0].oninput = function() {
|
||||
audioSettings.volume = this.value/100;
|
||||
if(audioSettings.volume >= 2/3) document.querySelectorAll("#volume i")[0].className = "fa fa-volume-up transition";
|
||||
if(audioSettings.volume < 2/3 && audioSettings.volume >= 1/3) document.querySelectorAll("#volume i")[0].className = "fa fa-volume-down transition";
|
||||
if(audioSettings.volume < 1/3) document.querySelectorAll("#volume i")[0].className = "fa fa-volume-off transition";
|
||||
audio.volume = audioSettings.volume;
|
||||
};
|
||||
document.querySelectorAll("#volume i")[0].onclick = function() {
|
||||
audioSettings.mute = !audioSettings.mute;
|
||||
audio.volume = (audioSettings.mute) ? 0 : audioSettings.volume;
|
||||
(audioSettings.mute) ? this.style.color = "#ff1a1a" : this.style.color = "white";
|
||||
};
|
||||
document.querySelectorAll("#pause")[0].onclick = function() {
|
||||
if(audio.src === "") return;
|
||||
if(audio.paused) {
|
||||
audio.play();
|
||||
this.className = "fa fa-pause-circle transition";
|
||||
} else {
|
||||
audio.pause();
|
||||
this.className ="fa fa-play-circle transition";
|
||||
}
|
||||
};
|
||||
audio.ontimeupdate = function() {
|
||||
if(isNaN(audio.duration)) return;
|
||||
var end = Math.floor(audio.duration%60).toString();
|
||||
if(end.length === 1) end = "0"+end;
|
||||
var played = Math.floor(audio.currentTime%60).toString();
|
||||
if(played.length === 1) played = "0"+played;
|
||||
document.querySelectorAll("#tracker p")[0].innerText = Math.floor(audio.currentTime/60)+":"+played;
|
||||
document.querySelectorAll("#tracker p")[1].innerText = Math.floor(audio.duration/60)+":"+end;
|
||||
document.querySelectorAll("#tracker input")[0].value = Math.floor(100000*audio.currentTime/audio.duration);
|
||||
};
|
||||
document.querySelectorAll("#tracker input")[0].oninput = function() {
|
||||
if(audio.src === "") {
|
||||
this.value = "0";
|
||||
return;
|
||||
}
|
||||
var curr = audio.duration*this.value/100000;
|
||||
var currRead = Math.floor(curr%60);
|
||||
if(currRead.length === 1) currRead = "0"+currRead;
|
||||
document.querySelectorAll("#tracker p")[0].innerText = Math.floor(curr/60)+":"+currRead;
|
||||
audio.currentTime = curr;
|
||||
};
|
||||
document.querySelectorAll("#spectrum p")[0].onclick = function() {
|
||||
spectrum = !spectrum;
|
||||
if(spectrum) {
|
||||
document.querySelectorAll("#spectrum i")[0].className = "fa fa-check-circle";
|
||||
document.getElementsByTagName("canvas")[0].style.display = "block";
|
||||
} else {
|
||||
document.querySelectorAll("#spectrum i")[0].className = "fa fa-times-circle";
|
||||
document.getElementsByTagName("canvas")[0].style.display = "none";
|
||||
}
|
||||
if(vis) {
|
||||
(spectrum) ? vis._restart() : vis._stop();
|
||||
} else {
|
||||
visualize(url);
|
||||
}
|
||||
};
|
||||
document.getElementById("prev").onclick = function() {
|
||||
try {
|
||||
if(selectDiv == undefined) {
|
||||
return;
|
||||
} else {
|
||||
newDiv = selectDiv.previousElementSibling;
|
||||
while(newDiv.getAttribute("ext") === "fol") newDiv = newDiv.previousElementSibling;
|
||||
newDiv.click();
|
||||
newDiv.click();
|
||||
}
|
||||
} catch(err) {}
|
||||
};
|
||||
document.getElementById("next").onclick = function() {
|
||||
try {
|
||||
if(selectDiv == undefined) {
|
||||
newDiv = document.getElementById("directoryCont").childNodes[0];
|
||||
} else {
|
||||
newDiv = selectDiv.nextElementSibling;
|
||||
}
|
||||
while(newDiv.getAttribute("ext") === "fol") newDiv = newDiv.nextElementSibling;
|
||||
newDiv.click();
|
||||
newDiv.click();
|
||||
} catch(err) {}
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", function(event) {
|
||||
try {
|
||||
switch((event || window.event).keyCode) {
|
||||
case 13:
|
||||
selectDiv.click();
|
||||
break;
|
||||
case 38:
|
||||
selectDiv.previousElementSibling.click();
|
||||
break;
|
||||
case 40:
|
||||
if(selectDiv == undefined) {
|
||||
document.getElementById("directoryCont").childNodes[0].click();
|
||||
} else {
|
||||
selectDiv.nextElementSibling.click();
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
var subdirs = document.getElementsByClassName("subdir");
|
||||
subdirs[subdirs.length-1].click();
|
||||
break;
|
||||
case 32:
|
||||
var audio = document.getElementsByTagName("audio")[0];
|
||||
if(audio.paused) {
|
||||
audio.play();
|
||||
document.querySelectorAll("#pause")[0].className = "fa fa-pause-circle transition";
|
||||
} else {
|
||||
audio.pause();
|
||||
document.querySelectorAll("#pause")[0].className ="fa fa-play-circle transition";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch(err) {}
|
||||
});
|
||||
|
||||
|
||||
getData();
|
||||
createNav();
|
||||
updateMain(navSelect);
|
||||
sortButtons();
|
||||
audioControls();
|
||||
123
DOJC Songs/desktop/visualizer.js
Normal file
123
DOJC Songs/desktop/visualizer.js
Normal file
@ -0,0 +1,123 @@
|
||||
|
||||
var Visualizer = function() {
|
||||
this.file = null, //the current file
|
||||
this.fileName = null, //the current file name
|
||||
this.audioContext = null,
|
||||
this.source = null, //the audio source
|
||||
this.info = document.getElementById('info').innerHTML, //this used to upgrade the UI information
|
||||
this.infoUpdateId = null, //to sotore the setTimeout ID and clear the interval
|
||||
this.animationId = null,
|
||||
this.status = 0, //flag for sound is playing 1 or stopped 0
|
||||
this.forceStop = false,
|
||||
this.allCapsReachBottom = false
|
||||
};
|
||||
|
||||
|
||||
Visualizer.prototype = {
|
||||
ini: function() {
|
||||
this._prepareAPI();
|
||||
},
|
||||
_prepareAPI: function() {
|
||||
//fix browser vender for AudioContext and requestAnimationFrame
|
||||
window.AudioContext = window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.msAudioContext;
|
||||
window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame;
|
||||
window.cancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.msCancelAnimationFrame;
|
||||
try {
|
||||
this.audioContext = new AudioContext();
|
||||
} catch (e) {
|
||||
alert('!Your browser does not support AudioContext', false);
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
_visualize: function(url, canvas, audio) {
|
||||
var audioContext = this.audioContext,
|
||||
audioBufferSouceNode = audioContext.createMediaElementSource(audio),
|
||||
analyser = audioContext.createAnalyser(),
|
||||
that = this;
|
||||
this.analyser = analyser;
|
||||
this.canvas = canvas;
|
||||
//connect the source to the analyser
|
||||
audioBufferSouceNode.connect(analyser);
|
||||
//connect the analyser to the destination(the speaker), or we won't hear the sound
|
||||
analyser.connect(audioContext.destination);
|
||||
//then assign the buffer to the buffer source node
|
||||
//play the source
|
||||
if (!audioBufferSouceNode.start) {
|
||||
audioBufferSouceNode.start = audioBufferSouceNode.noteOn //in old browsers use noteOn method
|
||||
audioBufferSouceNode.stop = audioBufferSouceNode.noteOff //in old browsers use noteOn method
|
||||
};
|
||||
//stop the previous sound if any
|
||||
if (this.animationId !== null) {
|
||||
cancelAnimationFrame(this.animationId);
|
||||
}
|
||||
if (this.source !== null) {
|
||||
this.source.stop(0);
|
||||
}
|
||||
//audioBufferSouceNode.start(0);
|
||||
this.status = 1;
|
||||
this.source = audioBufferSouceNode;
|
||||
this._drawSpectrum(analyser, canvas);
|
||||
},
|
||||
_restart: function() {
|
||||
this._drawSpectrum(this.analyser, this.canvas);
|
||||
},
|
||||
_stop: function() {
|
||||
cancelAnimationFrame(this.animationId);
|
||||
},
|
||||
_drawSpectrum: function(analyser, canvas) {
|
||||
var that = this,
|
||||
monoL = canvas,
|
||||
//monoR = document.getElementById('mono-R'),
|
||||
cwidth = monoL.width,
|
||||
cheight = monoL.height - 3,
|
||||
meterWidth = 1, //width of the meters in the spectrum
|
||||
gap = 0.01, //gap between meters
|
||||
capHeight = 2,
|
||||
capStyle = '#fff',
|
||||
meterNum = 20 * (2 + 2), //count of the meters
|
||||
capYPositionArray = []; ////store the vertical position of hte caps for the preivous frame
|
||||
ctx = monoL.getContext('2d'),
|
||||
gradient = ctx.createLinearGradient(0, 0, 0, 300);
|
||||
gradient.addColorStop(1, themeColors.highlight);
|
||||
gradient.addColorStop(0, '#fff');
|
||||
|
||||
var drawMeter = function() {
|
||||
var array = new Uint8Array(analyser.frequencyBinCount);
|
||||
analyser.getByteFrequencyData(array);
|
||||
if (that.status === 0) {
|
||||
//fix when some sounds end the value still not back to zero
|
||||
for (var i = array.length - 1; i >= 0; i--) {
|
||||
array[i] = 0;
|
||||
};
|
||||
allCapsReachBottom = true;
|
||||
for (var i = capYPositionArray.length - 1; i >= 0; i--) {
|
||||
allCapsReachBottom = allCapsReachBottom && (capYPositionArray[i] === 0);
|
||||
};
|
||||
if (allCapsReachBottom) {
|
||||
cancelAnimationFrame(that.animationId); //since the sound is top and animation finished, stop the requestAnimation to prevent potential memory leak,THIS IS VERY IMPORTANT!
|
||||
return;
|
||||
};
|
||||
};
|
||||
var step = Math.round(array.length / meterNum); //sample limited data from the total array
|
||||
ctx.clearRect(0, 0, cwidth, cheight);
|
||||
for (var i = 0; i < meterNum; i++) {
|
||||
var value = array[i * step];
|
||||
if (capYPositionArray.length < Math.round(meterNum)) {
|
||||
capYPositionArray.push(value);
|
||||
};
|
||||
ctx.fillStyle = capStyle;
|
||||
//draw the cap, with transition effect
|
||||
if (value < capYPositionArray[i]) {
|
||||
ctx.fillRect(i * 12, cheight - (--capYPositionArray[i]), meterWidth, capHeight);
|
||||
} else {
|
||||
ctx.fillRect(i * 12, cheight - value, meterWidth, capHeight);
|
||||
capYPositionArray[i] = value;
|
||||
};
|
||||
ctx.fillStyle = gradient; //set the filllStyle to gradient for a better look
|
||||
ctx.fillRect(i * 12 /*meterWidth+gap*/ , cheight - value + capHeight, meterWidth, cheight); //the meter
|
||||
}
|
||||
that.animationId = requestAnimationFrame(drawMeter);
|
||||
}
|
||||
this.animationId = requestAnimationFrame(drawMeter);
|
||||
}
|
||||
}
|
||||
43
DOJC Songs/header.html
Normal file
43
DOJC Songs/header.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<title>DOJC Mixtapes</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Saira+Condensed:300,400" rel="stylesheet">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<script type="text/javascript" src="http://discordonlinejammingcentral.com/jscripts/jquery.js?ver=1804"></script>
|
||||
<script src="https://use.fontawesome.com/c8d5486cd8.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script>
|
||||
var prefix = (screen.width <= 699) ? "mobile" : "desktop";
|
||||
var scripts = {
|
||||
"desktop": ["visualizer", "desktop"],
|
||||
"mobile": ["mobile"]
|
||||
};
|
||||
var l = document.createElement("link");
|
||||
l.rel = "stylesheet";
|
||||
l.href = "./"+prefix+"/"+prefix+".css";
|
||||
document.getElementsByTagName("head")[0].appendChild(l);
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:window.location.origin + "/"+prefix+"/"+prefix+".html",
|
||||
success: function(d){
|
||||
document.getElementsByTagName("body")[0].outerHTML = d;
|
||||
for(var i = 0; i < scripts[prefix].length; i++) {
|
||||
var s = document.createElement("script");
|
||||
s.src = "./"+prefix+"/"+scripts[prefix][i]+".js";
|
||||
document.getElementsByTagName("html")[0].appendChild(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
pre {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
BIN
DOJC Songs/logo.png
Normal file
BIN
DOJC Songs/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
263
DOJC Songs/mobile/mobile.css
Normal file
263
DOJC Songs/mobile/mobile.css
Normal file
@ -0,0 +1,263 @@
|
||||
html {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
body {
|
||||
display: grid;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
color: white;
|
||||
font-family: 'Open Sans Condensed', sans-serif;
|
||||
grid-template-columns: 100%;
|
||||
grid-template-rows: 8% 6% auto;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.transition {
|
||||
-webkit-transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
-moz-transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
-ms-transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
}
|
||||
|
||||
#header {
|
||||
display: grid;
|
||||
grid-row: 1;
|
||||
grid-template-columns: 7vh auto 7vh;
|
||||
background-color: #151313;
|
||||
}
|
||||
|
||||
#header div {
|
||||
margin: auto;
|
||||
font-size: 3vh;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
#header div .fa {
|
||||
padding: 1.5vh;
|
||||
}
|
||||
|
||||
#header img {
|
||||
height: 60%;
|
||||
margin: auto 0 auto 0;
|
||||
}
|
||||
|
||||
#mainContainer {
|
||||
grid-row: 3;
|
||||
background-color: #070606;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
position: absolute;
|
||||
left: -80%;
|
||||
height: 100%;
|
||||
width: 60%;
|
||||
background-color: #151313;
|
||||
box-shadow: 1px 0px 12px 1px black;
|
||||
}
|
||||
|
||||
#sidebar div:nth-child(2) {
|
||||
margin-top: 20%;
|
||||
}
|
||||
|
||||
#sidebar span {
|
||||
font-size: 110%;
|
||||
padding: 5%;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#sidebar span p {
|
||||
cursor: pointer;
|
||||
color: #63d4ff;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.navi {
|
||||
display: grid;
|
||||
height: 6vh;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
grid-template-columns: 1fr 3fr 7fr;
|
||||
}
|
||||
|
||||
.naviInner {
|
||||
background-color: rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.naviInner div {
|
||||
display: grid;
|
||||
height: 4vh;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
grid-template-columns: 3fr 7fr;
|
||||
}
|
||||
|
||||
.navi:hover, .naviInner div:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1) !important
|
||||
}
|
||||
|
||||
.navi i {
|
||||
margin: auto 0 auto 0;
|
||||
font-size: 2.1vh;
|
||||
text-align: center;
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
.navi p {
|
||||
margin: auto 0 auto 0;
|
||||
font-size: 2vh;
|
||||
grid-column: 3;
|
||||
}
|
||||
|
||||
.naviInner p {
|
||||
margin: auto 0 auto 0;
|
||||
font-size: 2vh;
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
#directoryHeader {
|
||||
grid-row: 2;
|
||||
background: rgba(0,0,0,0.7);
|
||||
display: grid;
|
||||
grid-template-columns: 50% auto 10% 7%;
|
||||
}
|
||||
|
||||
#directoryHeader p:nth-child(2) {
|
||||
grid-column: 3;
|
||||
opacity: 0;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#location {
|
||||
margin: auto 0 auto 5%;
|
||||
grid-column: 1;
|
||||
}
|
||||
|
||||
#directoryHeader i {
|
||||
grid-column: 4;
|
||||
opacity: 0;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: grid;
|
||||
padding: 2%;
|
||||
grid-template-columns: 14% auto 10%;
|
||||
grid-template-rows: 60% 40%;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
.item .name {
|
||||
grid-row: 1;
|
||||
grid-column: 2;
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
.item .modified {
|
||||
grid-row: 2;
|
||||
grid-column: 2;
|
||||
font-size: 80%;
|
||||
color: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
.item div {
|
||||
grid-row: 1 / 3;
|
||||
grid-column: 3;
|
||||
margin: auto;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
.fileIcon {
|
||||
grid-column: 1 !important;
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
margin: auto auto auto 0 !important;
|
||||
}
|
||||
|
||||
.item div .fa {
|
||||
padding: 1.5vh;
|
||||
}
|
||||
|
||||
#copy {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
top: -50%;
|
||||
}
|
||||
|
||||
#dotMenu {
|
||||
display: none;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
top: 2vh;
|
||||
right: 2vh;
|
||||
font-size: 2.5vh;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
#dotMenu p, #dotMenu a {
|
||||
display: block;
|
||||
padding: 10% 40% 10% 13%;
|
||||
}
|
||||
|
||||
#dotMenu a {
|
||||
color: rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.card {
|
||||
border-radius: 2px;
|
||||
background-color: #FEFEFE;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
color: black;
|
||||
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
}
|
||||
|
||||
#menuOverlay {
|
||||
background-color: rgba(0,0,0,0.2);
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#optionContainer {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
bottom: -60%;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#optionContainer p {
|
||||
color: black;
|
||||
font-size: 2.5vh;
|
||||
padding: 3%;
|
||||
}
|
||||
|
||||
#optionContainer p:first-child {
|
||||
color: rgba(0,0,0,0.7);
|
||||
}
|
||||
|
||||
.overlay .fa-times {
|
||||
font-size: 4vh;
|
||||
position: absolute;
|
||||
right: 4vh;
|
||||
top: 4vh;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
38
DOJC Songs/mobile/mobile.html
Normal file
38
DOJC Songs/mobile/mobile.html
Normal file
@ -0,0 +1,38 @@
|
||||
<body>
|
||||
<div id="header">
|
||||
<div class="transition">
|
||||
<i class="fa fa-bars transition"></i>
|
||||
</div>
|
||||
<img src="./logo.png">
|
||||
<div class="transition">
|
||||
<i class="fa fa-ellipsis-v"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div id="directoryHeader">
|
||||
<p id="location" class="transition">BinBin</p>
|
||||
<p class="transition">Name</p>
|
||||
<i class="fa fa-arrow-up transition"></i>
|
||||
</div>
|
||||
<div id="sidebar" class="transition">
|
||||
<span>Developed by <p onclick="window.open('http://discordonlinejammingcentral.com/user-3.html','_blank')">ksjdragon</p></span>
|
||||
</div>
|
||||
<div id="mainContainer">
|
||||
<div id="songList">
|
||||
<div id="directory">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dotMenu" class="card">
|
||||
<p id="openSort" class="transition">Sort by...</p>
|
||||
<a id="download" class="transition" download>Download</a>
|
||||
</div>
|
||||
<div id="menuOverlay" class="transition">
|
||||
<div id="optionContainer" class="transition">
|
||||
<p>Sort by</p>
|
||||
<p>Name</p>
|
||||
<p>Date</p>
|
||||
<p>Size</p>
|
||||
</div>
|
||||
</div>
|
||||
<input id="copy" readonly>
|
||||
</body>
|
||||
559
DOJC Songs/mobile/mobile.js
Normal file
559
DOJC Songs/mobile/mobile.js
Normal file
@ -0,0 +1,559 @@
|
||||
var data, // Stores data from PHP.
|
||||
section = 0,
|
||||
clickable = true,
|
||||
selectName, // Stores name of folder in selected div
|
||||
selectDiv, // Stores actual selected div.
|
||||
currDir = "";
|
||||
|
||||
var sort = {
|
||||
"name": -1,
|
||||
"date": 1,
|
||||
"size": 1,
|
||||
};
|
||||
|
||||
var faIcons = {
|
||||
"fol": "folder",
|
||||
"mp3": "music",
|
||||
"ogg": "music",
|
||||
"other": "file",
|
||||
"wav": "music"
|
||||
};
|
||||
|
||||
var navi = [ // Necessary arguments: id, alias, fa | Optional arguments: subnav.
|
||||
{
|
||||
"id": "home",
|
||||
"alias": "Home",
|
||||
"fa": "home"
|
||||
},
|
||||
{
|
||||
"id": "forums",
|
||||
"alias": "Forums",
|
||||
"fa": "file"
|
||||
},
|
||||
{
|
||||
"id": "memberList",
|
||||
"alias": "Member List",
|
||||
"fa": "users"
|
||||
},
|
||||
{
|
||||
"id": "calendar",
|
||||
"alias": "Calendar",
|
||||
"fa": "calendar"
|
||||
},
|
||||
{
|
||||
"id": "help",
|
||||
"alias": "Help",
|
||||
"fa": "info-circle"
|
||||
},
|
||||
{
|
||||
"id": "songList",
|
||||
"alias": "Song List",
|
||||
"fa": "music"
|
||||
}
|
||||
];
|
||||
|
||||
var navSelect = "songList";
|
||||
|
||||
var themeColors = { // For reference and for quick changing if need-be.
|
||||
"main": "#070606",
|
||||
"sidebar": "#151313",
|
||||
"highlight": "#63d4ff"
|
||||
};
|
||||
|
||||
function getData() {
|
||||
$.when($.ajax({
|
||||
type : 'POST',
|
||||
url: 'api.floofy.php',
|
||||
data: {rootdir: 'rootdir'}
|
||||
})).done(function(d) {
|
||||
rootDir = d;
|
||||
checkHash();
|
||||
});
|
||||
}
|
||||
|
||||
function listDir(dir, sec) { // Directory is the sub-directory, sec is the section of data, if files need to be split up into sections.
|
||||
var real = rootDir+dir;
|
||||
$.when($.ajax({
|
||||
type : 'POST',
|
||||
url: 'api.floofy.php',
|
||||
data: {getdir : [real, sec]},
|
||||
})).done(function(d) {
|
||||
data = d;
|
||||
if(data[0] === null) {
|
||||
currDir = "";
|
||||
listDir(currDir, 0);
|
||||
return;
|
||||
}
|
||||
if(sec == 0) {
|
||||
data[0].splice(0,2);
|
||||
data[1].splice(0,3);
|
||||
data[2].splice(0,3);
|
||||
data[3].splice(0,3);
|
||||
} else {
|
||||
data[1].splice(0,1);
|
||||
data[2].splice(0,1);
|
||||
data[3].splice(0,1);
|
||||
}
|
||||
var toObj = [];
|
||||
for(var i = 0; i < data[0].length; i++) {
|
||||
toObj.push({
|
||||
name: data[0][i],
|
||||
folder: data[1][i],
|
||||
date: data[2][i],
|
||||
size: data[3][i]
|
||||
});
|
||||
}
|
||||
data = toObj;
|
||||
sortFiles("name", -1);
|
||||
clickable = true;
|
||||
});
|
||||
}
|
||||
|
||||
function sortFiles(type, direction) {
|
||||
switch(type) {
|
||||
case "name":
|
||||
data.sort(function(a, b){ return (a.name < b.name) ? direction*1 : direction*-1;});
|
||||
break;
|
||||
case "date":
|
||||
data.sort(function(a, b){
|
||||
a = a.date.replace(",","").split(" ");
|
||||
b = b.date.replace(",","").split(" ");
|
||||
a = Date.parse(a[1] + " " + a[0] + " " + a[2]);
|
||||
b = Date.parse(b[1] + " " + b[0] + " " + b[2]);
|
||||
|
||||
return (a < b) ? direction*1 : direction*-1;
|
||||
});
|
||||
break;
|
||||
case "size":
|
||||
data.sort(function(a, b){ return (a.size.replace("B","").substring(0, a.size.length-1) < b.size.replace("B","").substring(0, b.size.length-1)) ? direction*1 : direction*-1;});
|
||||
}
|
||||
var p = document.querySelectorAll("#directoryHeader p:nth-child(2)")[0];
|
||||
var i = document.querySelectorAll("#directoryHeader i")[0];
|
||||
p.style.opacity = "0";
|
||||
i.style.opacity = "0";
|
||||
setTimeout(function() {
|
||||
p.innerText = type[0].toUpperCase() + type.substring(1,type.length);
|
||||
i.className = "fa fa-arrow-" + ((direction < 0) ? "up" : "down") + " transition";
|
||||
p.style.opacity = "1";
|
||||
i.style.opacity = "1";
|
||||
}, 300);
|
||||
|
||||
try {
|
||||
clearTbl();
|
||||
setTimeout(function() {
|
||||
document.getElementById("directory").removeChild(document.getElementById("directoryCont"));
|
||||
dispDir();
|
||||
}, 300);
|
||||
} catch(err) {
|
||||
dispDir();
|
||||
}
|
||||
}
|
||||
|
||||
function dispDir() {
|
||||
updateLocation();
|
||||
try {
|
||||
document.getElementById("directory").removeChild(document.getElementById("directoryCont"));
|
||||
} catch(err) {}
|
||||
var cont = document.createElement("div");
|
||||
cont.id = "directoryCont";
|
||||
cont.style.opacity = "0";
|
||||
cont.className = "transition";
|
||||
|
||||
selectName = "";
|
||||
var item;
|
||||
if(data.length === 0) {
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode("Nothing here!"));
|
||||
p.style.fontWeight = "100";
|
||||
cont.appendChild(p);
|
||||
}
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
item = createRow();
|
||||
|
||||
var curr = data[i];
|
||||
var name = document.createTextNode(curr.name);
|
||||
var otherInfo = document.createTextNode(curr.date.split(" | ")[0] + " | " + curr.size);
|
||||
|
||||
item.childNodes[0].appendChild(name);
|
||||
item.childNodes[1].appendChild(otherInfo);
|
||||
|
||||
var ext = document.createAttribute("ext");
|
||||
|
||||
if(curr.folder == "true") {
|
||||
ext.value = "fol";
|
||||
} else {
|
||||
ext.value = curr.name.substring(curr.name.lastIndexOf(".")+1,curr.name.length).toLowerCase();
|
||||
}
|
||||
item.setAttributeNode(ext);
|
||||
|
||||
var ico = document.createElement("div");
|
||||
ico.className = "fileIcon";
|
||||
var faico = document.createElement("i");
|
||||
faico.className = "fa fa-" + (faIcons[item.getAttribute("ext")] || faIcons["other"]);
|
||||
ico.appendChild(faico);
|
||||
item.appendChild(ico);
|
||||
|
||||
item.onclick = function() {
|
||||
if(clickable == true) {
|
||||
var name = this.childNodes[0].innerText;
|
||||
url = getURI(name);
|
||||
attr = this.getAttribute("ext");
|
||||
var download = document.querySelectorAll("#dotMenu a")[0]
|
||||
if(attr == "fol") {
|
||||
download.href = ""
|
||||
download.style.color = "rgba(0,0,0,0.5)";
|
||||
} else {
|
||||
download.href = url;
|
||||
download.style.color = "rgba(0,0,0,1)";
|
||||
}
|
||||
if(selectName == name) {
|
||||
clickable = false;
|
||||
attr = this.getAttribute("ext");
|
||||
if(attr == "fol") {
|
||||
clearTbl();
|
||||
setTimeout(function() {
|
||||
currDir += name+"/";
|
||||
listDir(currDir,0);
|
||||
}, 300)
|
||||
return;
|
||||
} else {
|
||||
audioOverlay(url);
|
||||
clickable = true;
|
||||
}
|
||||
}
|
||||
selectName = name;
|
||||
selectDiv = this;
|
||||
for(var i =0; i < document.getElementsByClassName("item").length;i++){
|
||||
document.getElementsByClassName("item")[i].style.backgroundColor = "";
|
||||
}
|
||||
this.style.backgroundColor = "rgba(255,255,255,0.2)";
|
||||
}
|
||||
}
|
||||
cont.appendChild(item);
|
||||
item = null;
|
||||
}
|
||||
document.getElementById("directory").appendChild(cont);
|
||||
setTimeout(function() {
|
||||
document.getElementById("directoryCont").style.opacity = "1";
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function getClose() {
|
||||
var close = document.createElement("i");
|
||||
close.className = "fa fa-times transition";
|
||||
var attr = document.createAttribute("aria-hidden");
|
||||
attr.value = "true";
|
||||
close.setAttributeNode(attr);
|
||||
|
||||
close.onclick = function() {
|
||||
this.style.color = "#f13838";
|
||||
that = this;
|
||||
document.getElementsByClassName("overlay")[0].opacity = "0";
|
||||
setTimeout(function() {
|
||||
that.style.color = "white";
|
||||
document.getElementsByTagName("body")[0].removeChild(document.getElementsByClassName("overlay")[0]);
|
||||
clickable = true;
|
||||
}, 300);
|
||||
};
|
||||
|
||||
return close;
|
||||
}
|
||||
|
||||
function createRow() {
|
||||
var item = document.createElement("div");
|
||||
item.className = "item transition";
|
||||
var name = document.createElement("p");
|
||||
name.className = "name";
|
||||
item.appendChild(name);
|
||||
var modified = document.createElement("p");
|
||||
modified.className = "modified";
|
||||
item.appendChild(modified);
|
||||
return item;
|
||||
}
|
||||
|
||||
function audioOverlay(url) {
|
||||
var overlay = getDefaultOverlay();
|
||||
var audio = document.createElement("audio");
|
||||
audio.onclick = function() {event.stopPropagation();}
|
||||
audio.src = url;
|
||||
audio.controls = true;
|
||||
audio.autoplay = true;
|
||||
|
||||
audio.style.margin = "auto";
|
||||
audio.style.width = (window.innerWidth * 0.9).toString() + "px";
|
||||
|
||||
var div = document.createElement("div");
|
||||
div.style.margin = "auto";
|
||||
div.style.gridRow = "1";
|
||||
div.style.gridColumn = "1";
|
||||
div.appendChild(audio);
|
||||
overlay.appendChild(div);
|
||||
|
||||
var close = getClose();
|
||||
overlay.appendChild(close);
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(overlay);
|
||||
setTimeout(function() {
|
||||
overlay.style.opacity = "1";
|
||||
}, 10);
|
||||
}
|
||||
|
||||
function getDefaultOverlay() {
|
||||
var overlay = document.createElement("div");
|
||||
overlay.className = "overlay transition";
|
||||
overlay.style.position = "absolute";
|
||||
overlay.style.top = "0";
|
||||
overlay.style.left = "0";
|
||||
overlay.style.minHeight = "100%";
|
||||
overlay.style.minWidth = "100%";
|
||||
overlay.style.background = 'rgba(0,0,0,0.8)';
|
||||
overlay.style.zIndex = "50";
|
||||
overlay.style.display = "grid";
|
||||
overlay.style.gridTemplateColumns = "1fr";
|
||||
overlay.style.gridTemplateRows = "1fr";
|
||||
overlay.style.opacity = "0";
|
||||
|
||||
return overlay;
|
||||
}
|
||||
|
||||
function clearTbl() {
|
||||
selected = undefined;
|
||||
selectDiv = undefined;
|
||||
document.getElementById("directoryCont").style.opacity = "0";
|
||||
}
|
||||
|
||||
function getURI(name) {
|
||||
var dirs = (rootDir+currDir+name).split("/");
|
||||
var uri = window.location.origin;
|
||||
for(var i = 1; i < dirs.length; i++) uri+="/"+encodeURIComponent(dirs[i]);
|
||||
return uri;
|
||||
}
|
||||
|
||||
function createNav() {
|
||||
for (var i = 0; i < navi.length; i++) { // Create navigation tabs.
|
||||
var side = document.getElementById("sidebar");
|
||||
var div = document.createElement("div");
|
||||
div.className = "navi transition";
|
||||
div.setAttribute("option", navi[i].id);
|
||||
var ic = document.createElement("i");
|
||||
ic.className = "fa fa-" + navi[i].fa;
|
||||
ic["aria-hidden"] = true;
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode(navi[i].alias));
|
||||
div.appendChild(ic);
|
||||
div.appendChild(p);
|
||||
side.appendChild(div);
|
||||
var subNav = navi[i].subNav;
|
||||
if(!subNav) continue;
|
||||
|
||||
var subNavCont = document.createElement("div");
|
||||
subNavCont.className = "naviInner";
|
||||
subNavCont.setAttribute("option", navi[i].id);
|
||||
for(var j = 0; j < subNav.length; j++) {
|
||||
var eachSubNav = document.createElement("div");
|
||||
eachSubNav.className = "transition";
|
||||
eachSubNav.setAttribute("option", navi[i].id+"&"+subNav[j].id);
|
||||
eachSubNav.onclick = function() {
|
||||
var op = this.getAttribute("option");
|
||||
if(subNavSelect === op) return;
|
||||
//updateMain(op);
|
||||
}
|
||||
var p2 = document.createElement("p");
|
||||
p2.appendChild(document.createTextNode(subNav[j].alias));
|
||||
eachSubNav.appendChild(p2);
|
||||
subNavCont.appendChild(eachSubNav);
|
||||
}
|
||||
side.appendChild(subNavCont);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNav(op) { // Updates the sidebar navigation (if naviagation tabs are ever dynamically implemented).
|
||||
var oldNav = document.querySelectorAll("[option=" + navSelect + "]")[0];
|
||||
var newNav = document.querySelectorAll("[option=" + op + "]")[0];
|
||||
oldNav.style.backgroundColor = "rgba(0,0,0,0)";
|
||||
oldNav.style.color = "white";
|
||||
newNav.style.backgroundColor = themeColors.main;
|
||||
newNav.style.color = themeColors.highlight;
|
||||
}
|
||||
|
||||
function updateMain(op) { // Updates the actual page.
|
||||
updateNav(op);
|
||||
switch(op) {
|
||||
case "home":
|
||||
window.location = "http://discordonlinejammingcentral.com/";
|
||||
break;
|
||||
case "forums":
|
||||
window.location = "http://discordonlinejammingcentral.com/";
|
||||
break;
|
||||
case "memberList":
|
||||
window.location = "http://discordonlinejammingcentral.com/memberlist.php";
|
||||
break;
|
||||
case "calendar":
|
||||
window.location = "http://discordonlinejammingcentral.com/calendar.php";
|
||||
break;
|
||||
case "help":
|
||||
window.location = "http://discordonlinejammingcentral.com/misc.php?action=help";
|
||||
break;
|
||||
case "songList":
|
||||
// Implement if dynamic
|
||||
break;
|
||||
}
|
||||
navSelect = op;
|
||||
}
|
||||
|
||||
function updateLocation() {
|
||||
window.location.hash = currDir.replace(/[\/]+/g,"*").replace(/ /g, "_");
|
||||
var i = document.querySelectorAll("#header div:first-child i")[0];
|
||||
document.getElementById("location").innerText = (currDir === "") ? "BinBin" : currDir.split("/").slice(-2)[0];
|
||||
if(currDir === "" && !i.className.includes("fa-bars")) {
|
||||
i.style.opacity = "0";
|
||||
setTimeout(function() {
|
||||
i.className = "fa fa-bars transition";
|
||||
i.style.opacity = "1"
|
||||
}, 300);
|
||||
} else if(currDir !== "" && !i.className.includes("fa-arrow-left")) {
|
||||
i.style.opacity = "0";
|
||||
setTimeout(function() {
|
||||
i.className = "fa fa-arrow-left transition";
|
||||
i.style.opacity = "1";
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
function checkHash() {
|
||||
console.log(window.location.hash);
|
||||
if(window.location.hash) {
|
||||
currDir = window.location.hash.replace(/[_]+/g, " ").replace(/[\*]+/g,"/").replace("#","");
|
||||
}
|
||||
listDir(currDir,0);
|
||||
window.location.hash = "";
|
||||
}
|
||||
|
||||
function closeMenuOverlay() {
|
||||
var overlay = document.getElementById("menuOverlay");
|
||||
overlay.style.opacity = "0";
|
||||
setTimeout(function() {
|
||||
overlay.style.display = "none";
|
||||
}, 300);
|
||||
document.getElementById("optionContainer").style.bottom = "-60%";
|
||||
}
|
||||
|
||||
function sortButtons() {
|
||||
document.querySelectorAll("#optionContainer p:first-child")[0].onclick = function() {event.stopPropagation();}
|
||||
document.querySelectorAll("#optionContainer p:nth-child(2)")[0].onclick = function() {
|
||||
event.stopPropagation();
|
||||
closeMenuOverlay();
|
||||
sort.name = sort.name * -1;
|
||||
sortFiles("name", sort.name);
|
||||
}
|
||||
document.querySelectorAll("#optionContainer p:nth-child(3)")[0].onclick = function() {
|
||||
event.stopPropagation();
|
||||
closeMenuOverlay();
|
||||
sort.date = sort.date * -1;
|
||||
sortFiles("date", sort.date);
|
||||
}
|
||||
document.querySelectorAll("#optionContainer p:nth-child(4)")[0].onclick = function() {
|
||||
event.stopPropagation();
|
||||
closeMenuOverlay();
|
||||
sort.size = sort.size * -1;
|
||||
sortFiles("size", sort.size);
|
||||
}
|
||||
document.querySelectorAll("#directoryHeader p:nth-child(2)")[0].onclick = function() {
|
||||
var type = this.innerText.toLowerCase();
|
||||
sort[type] = sort[type] * -1;
|
||||
sortFiles(type, sort[type]);
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll("#header div:first-child i")[0].onclick = function() {
|
||||
this.parentNode.style.backgroundColor = "rgba(0,0,0,0.4)";
|
||||
that = this;
|
||||
setTimeout(function() {
|
||||
that.parentNode.style.backgroundColor = "rgba(0,0,0,0)";
|
||||
}, 300);
|
||||
if(currDir === "") {
|
||||
console.log("asdf");
|
||||
setTimeout(function() {
|
||||
document.getElementById("sidebar").style.left = "0";
|
||||
}, 10);
|
||||
|
||||
} else {
|
||||
var arr = currDir.split("/");
|
||||
if(arr.length === 2) {
|
||||
currDir = "";
|
||||
} else {
|
||||
currDir = arr.slice(0,arr.length-2).reduce((a,b) => a+"/"+b)+"/";
|
||||
}
|
||||
listDir(currDir, 0);
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll("#header div:last-child i")[0].onclick = function(event) {
|
||||
event.stopPropagation();
|
||||
this.parentNode.style.backgroundColor = "rgba(0,0,0,0.4)";
|
||||
that = this;
|
||||
setTimeout(function() {
|
||||
that.parentNode.style.backgroundColor = "rgba(0,0,0,0)";
|
||||
}, 300);
|
||||
var menu = document.getElementById("dotMenu");
|
||||
menu.style.display = "block";
|
||||
setTimeout(function() {
|
||||
menu.style.opacity = "1";
|
||||
}, 10);
|
||||
}
|
||||
|
||||
document.getElementById("sidebar").onclick = function() {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
document.getElementById("openSort").onclick = function() {
|
||||
event.stopPropagation();
|
||||
this.style.backgroundColor = "rgba(0,0,0,0.2)";
|
||||
that = this;
|
||||
setTimeout(function() {
|
||||
that.style.backgroundColor = "rgba(0,0,0,0)";
|
||||
}, 300);
|
||||
// Close Menu
|
||||
var menu = document.getElementById("dotMenu");
|
||||
menu.style.opacity = "0";
|
||||
setTimeout(function() {
|
||||
menu.style.display = "none";
|
||||
}, 300);
|
||||
// Open overlay
|
||||
var overlay = document.getElementById("menuOverlay");
|
||||
overlay.style.display = "block";
|
||||
setTimeout(function() {
|
||||
overlay.style.opacity = "1";
|
||||
}, 10);
|
||||
|
||||
setTimeout(function() {
|
||||
var option = document.getElementById("optionContainer");
|
||||
option.style.bottom = "0";
|
||||
}, 150);
|
||||
}
|
||||
|
||||
document.getElementById("download").onclick = function() {
|
||||
event.stopPropagation();
|
||||
this.style.backgroundColor = "rgba(0,0,0,0.2)";
|
||||
that = this;
|
||||
setTimeout(function() {
|
||||
that.style.backgroundColor = "rgba(0,0,0,0)";
|
||||
}, 300);
|
||||
}
|
||||
|
||||
document.onclick = function(event) {
|
||||
var menu = document.getElementById("dotMenu");
|
||||
menu.style.opacity = "0";
|
||||
setTimeout(function() {
|
||||
menu.style.display = "none";
|
||||
}, 300);
|
||||
|
||||
closeMenuOverlay();
|
||||
|
||||
document.getElementById("sidebar").style.left = "-80%";
|
||||
}
|
||||
|
||||
getData();
|
||||
sortButtons();
|
||||
createNav();
|
||||
updateNav(navSelect);
|
||||
24
Google FooBar/boomBaby.py
Normal file
24
Google FooBar/boomBaby.py
Normal file
@ -0,0 +1,24 @@
|
||||
def gcd(a, b):
|
||||
while b > 0:
|
||||
a, b = b, a % b
|
||||
return a
|
||||
|
||||
def solution(x, y):
|
||||
x, y = int(x), int(y)
|
||||
if y < x: x, y = y, x # Reorder
|
||||
|
||||
count = 0
|
||||
while True:
|
||||
div = y/x
|
||||
print(x,y)
|
||||
if x == 1:
|
||||
count += y-1
|
||||
break
|
||||
y -= x*div
|
||||
count += div
|
||||
if y < x: x, y = y, x
|
||||
if x == y or x < 1: return "impossible"
|
||||
|
||||
return str(count)
|
||||
|
||||
print(solution(4, 7))
|
||||
48
Google FooBar/bunnyMessage.py
Normal file
48
Google FooBar/bunnyMessage.py
Normal file
@ -0,0 +1,48 @@
|
||||
from itertools import combinations
|
||||
|
||||
def swap(l, i, j):
|
||||
a, b = l[i], l[j]
|
||||
l[j] = a
|
||||
l[i] = b
|
||||
|
||||
|
||||
def to_int(l):
|
||||
# Coverts list of digits to integer.
|
||||
n = 0
|
||||
for i, x in enumerate(reversed(l)): n += x * 10**i
|
||||
return n
|
||||
|
||||
|
||||
def next_greatest(l):
|
||||
# Finds the next greatest number with the same set of digits.
|
||||
|
||||
# First, the first index (from the right) where Left > Right digit.
|
||||
for i in range(len(l)-1, -1, -1):
|
||||
if l[i] < l[i-1]: break
|
||||
|
||||
if i == 0: return 0 # No digits, found, smallest possible.
|
||||
|
||||
# Find the largest number to the right of that index, including,
|
||||
# and swap. Then, sort the right descending.
|
||||
comp, largest = l[i-1], i
|
||||
for j in range(i, len(l)):
|
||||
if l[j] < comp and l[j] > l[largest]: largest = j
|
||||
|
||||
swap(l, i-1, largest)
|
||||
l = l[:i] + sorted(l[i:], reverse=True)
|
||||
|
||||
|
||||
def solution(l):
|
||||
l = sorted(l, reverse=True)
|
||||
found = False
|
||||
for i in range(len(l), 0, -1):
|
||||
# Get all combinations when removing digits.
|
||||
c = list(combinations(l, i))
|
||||
for m in c:
|
||||
m = list(m)
|
||||
while True:
|
||||
num = to_int(m)
|
||||
if num % 3 == 0: return num
|
||||
if not next_greatest(m): break
|
||||
|
||||
return 0
|
||||
90
Google FooBar/disorderlyEscape.py
Normal file
90
Google FooBar/disorderlyEscape.py
Normal file
@ -0,0 +1,90 @@
|
||||
# Apply Burnside's Lemma to a group
|
||||
# G = S_r x S_c. G is a group action on
|
||||
# the set of R x C matrices with elements
|
||||
# 1 to n. (S_r, S_c can be thought to
|
||||
# permute the rows and columns).
|
||||
# We need only count the total number
|
||||
# matrices unchanged by a group operation.
|
||||
# This is the cycle index of S_r x S_c.
|
||||
|
||||
from itertools import permutations
|
||||
|
||||
def fac(n):
|
||||
a = 1
|
||||
for i in range(2, n+1): a *= i
|
||||
return a
|
||||
|
||||
|
||||
def gcd(a, b):
|
||||
while b > 0:
|
||||
a, b = b, a % b
|
||||
return a
|
||||
|
||||
|
||||
def mult(l):
|
||||
v = 1
|
||||
for x in l: v *= x
|
||||
return v
|
||||
|
||||
|
||||
def gen_struct(full, l, n, i=0, v=0):
|
||||
if v >= n:
|
||||
if v == n: full.append([x for x in l])
|
||||
return
|
||||
if i == n: return
|
||||
l[i] = (n-v) / (i+1)
|
||||
for c in range(l[i]):
|
||||
gen_struct(full, l, n, i+1, v+l[i]*(i+1))
|
||||
l[i] -= 1
|
||||
gen_struct(full, l, n, i+1, v+l[i]*(i+1))
|
||||
|
||||
|
||||
def cycle_monomials(n):
|
||||
# Generates the cycle structures of distinct
|
||||
# lengths of S_n and their number of occurances.
|
||||
a = range(1, n+1)
|
||||
perms = permutations(range(1, n+1))
|
||||
valid = {}
|
||||
structs = []
|
||||
gen_struct(structs, [0]*n, n)
|
||||
|
||||
for s in structs:
|
||||
valid[tuple(s)] = distinct_disjoint(n, s)
|
||||
return valid
|
||||
|
||||
|
||||
def distinct_disjoint(n, s):
|
||||
# Counts distinct number of cycle structures
|
||||
# given a structure.
|
||||
a = mult([fac(x)*(i+1)**x for i,x in enumerate(s)])
|
||||
return fac(n) / a
|
||||
|
||||
|
||||
def precompute_gcds(n):
|
||||
gcds = {}
|
||||
for i in range(1, n+1):
|
||||
for j in range(1, n+1):
|
||||
gcds[(i,j)] = gcd(i, j)
|
||||
return gcds
|
||||
|
||||
|
||||
def count_pow(w, h, gcds):
|
||||
p = 0
|
||||
for i,x in enumerate(w):
|
||||
for j,y in enumerate(h):
|
||||
p += x*y*gcds[(i+1, j+1)]
|
||||
return p
|
||||
|
||||
|
||||
def solution(w, h, s):
|
||||
gcds = precompute_gcds(w if w > h else h)
|
||||
cycle_w = cycle_monomials(w)
|
||||
cycle_h = cycle_monomials(h)
|
||||
|
||||
a = 0
|
||||
for m_w in cycle_w:
|
||||
for m_h in cycle_h:
|
||||
power = count_pow(m_w, m_h, gcds)
|
||||
a += cycle_w[m_w]*cycle_h[m_h]*s**(power)
|
||||
return str(a/(fac(w)*fac(h)))
|
||||
|
||||
27
Google FooBar/dodgeTheLasers.py
Normal file
27
Google FooBar/dodgeTheLasers.py
Normal file
@ -0,0 +1,27 @@
|
||||
from fractions import Fraction
|
||||
|
||||
s2 = Fraction(
|
||||
35332726218913082002358766567827133403671835402604373950214227741215442484749150955273090178912608481198897853368677449335995881087244538678290206830418162774359733435287323797237328954776430706234113433451845011017420071003585630000741417839336284541684996470487244538747886851321045013449097020971979829080007863459398205102274621539252406059437113694061276533416838442752036477377285665580031045075305667660780081786425072132321243484569812363079897761850586673077795635795883465127642978549060248943470341266945351444290281205344606113449121955343732035824675647295545778804839861084648227428027205738691255356908295557230413188833721567060585767808732827617204869412227198237283429379813249866199201416615876892112411524426811419866249990696965745171717817422622562682438363092664485642832947927443151601527359189163417709253561016343488370329029585831327776394329216180144214930909237283637492608470079057271872248952501520874288386823231621192012874782227366578088738868911631337861377623018019037632439341813994901701122235924802807033643138348715789752591317659444556916319088480894501003196095706425280809090500181540773251421775695294520400781732432876502534542845385961208207822267335357830445556698863375695074697445589948526104879367950290305961624127368550768977250835228412091675544074876078513692883156476870744638792993260730998051752445796633655179188384438251649122556708863266126720906055336405070283541885888759326087142666395773249829681135123306671975516588372947658685690152085540674258629344850569601363203602574753855251595448225066391699457,
|
||||
24984010307201163339947983356301141616506447664487440183998810625058752168423324876345697485648790341609412002644655629412905132278379217868484556663287775731050845260730078203242599232472745227920679113063794049752437460981417866332131328395755341349753062559392972068081111918344156477612649348595211491067455489237457910155651004107009048180626919290946081541440148801661958564193598020244065505190786402719245384074252704561095281880456896817874403336969582795243258680340898219825513614657448394985422467221011934983262955360496189619472621400284115715288480382270722104540794780523070446693883270347990895469101178377691926263031421481448827494798554741341670262654080173175016283673279935535934852810962006385757200844486464083629290021915870934966800154480166282275001270982689689154583147508681525494843192315422085012166515924290106489737455158618093568404195679968385318684717834082972614221999122177016269590409818014579764679971236940524480753371978831311605588219064932370351315353772791737116335036856123399572239079392444178222707643932212683788067910953111224799145119835497757908787464889401399155223624057578426686398366195576141848364526279398255637945691268246191955996126558409043995911907057399961628590021716196825459819630668018546857838477083355412835636688350256316068114037351274317433071855241661763541825367319352845206312966830268604961919428245071600234081088836304955895409229527078577447991563333997254415362184904418568880688711037556338564582304559403993718370643949781411157627238782780565038167716008066343635609932346552357957632
|
||||
)
|
||||
|
||||
s2p = 4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727
|
||||
#Good approximate solution
|
||||
def sol_approx(s):
|
||||
x = s2*s*(s+1)/2 - s/2
|
||||
return int(x.numerator/x.denominator)
|
||||
|
||||
def beatty(n):
|
||||
if n == 1: return 1
|
||||
if n < 1: return 0
|
||||
t = n*s2p/(10**100)
|
||||
a,b,c = n*t, n*(n+1)/2, t*(t+1)/2
|
||||
return a+b-c - beatty(t)
|
||||
|
||||
# Beatty sequence
|
||||
def solution(s):
|
||||
#x = sol_approx(int(s))
|
||||
x = beatty(int(s))
|
||||
return str(x)
|
||||
|
||||
print(solution("1000"))
|
||||
70
Google FooBar/doomsdayFuel.py
Normal file
70
Google FooBar/doomsdayFuel.py
Normal file
@ -0,0 +1,70 @@
|
||||
from fractions import Fraction
|
||||
|
||||
def div_row(l, row, m):
|
||||
for i in range(len(l[row])): l[row][i] = l[row][i] / m
|
||||
|
||||
|
||||
def add_row(l, row1, row2, m=1):
|
||||
for i in range(len(l[row1])): l[row1][i] = l[row1][i] + l[row2][i] * m
|
||||
|
||||
|
||||
def process(l):
|
||||
# Converts matrix to fractions, and gets terminal states.
|
||||
# Transforms L into (I - L^T) | (1,0,0,...)^T
|
||||
new_l = [[0]*len(l) for x in range(len(l))]
|
||||
terminal = []
|
||||
for i in range(len(l)):
|
||||
d = sum(l[i])
|
||||
if d == 0: terminal.append(i)
|
||||
for j in range(len(l)):
|
||||
new_l[j][i] = -Fraction(l[i][j], 1 if d == 0 else d)
|
||||
if i == j: new_l[i][j] = 1 + new_l[i][j]
|
||||
|
||||
for i in range(len(l)): new_l[i].append(Fraction(i == 0))
|
||||
return (new_l, terminal)
|
||||
|
||||
|
||||
def gauss_elim(l):
|
||||
for i in range(len(l)): # Column
|
||||
for j in range(len(l)): # Row
|
||||
if i == j:
|
||||
if l[j][i] == 1: continue
|
||||
div_row(l, j, l[j][i])
|
||||
else:
|
||||
if l[j][i] == 0: continue
|
||||
add_row(l, j, i, Fraction(-l[j][i], l[i][i]))
|
||||
|
||||
|
||||
def gcd(a, b):
|
||||
while b > 0:
|
||||
a, b = b, a % b
|
||||
return a
|
||||
|
||||
def lcm(a, b):
|
||||
return a * b / gcd(a, b)
|
||||
|
||||
|
||||
def simplify(p):
|
||||
denom = [x.denominator for x in p]
|
||||
curr_lcm = denom[0]
|
||||
for i in range(1, len(denom)):
|
||||
curr_lcm = lcm(curr_lcm, denom[i])
|
||||
|
||||
for i in range(len(p)):
|
||||
p[i] = p[i].numerator * curr_lcm / denom[i]
|
||||
|
||||
p.append(curr_lcm)
|
||||
|
||||
|
||||
def solution(l):
|
||||
# L^n[i][j] = Probability of arriving at state j starting from state i in n steps
|
||||
# Sum(L^n) from 0 to n = (I - L)^{-1}.
|
||||
# Since we only want the first row, we can do some simplifications by
|
||||
# row reducing with the transpose, and augment with the (1,0,0,0, ...)^T
|
||||
l, terminal = process(l)
|
||||
print(l)
|
||||
gauss_elim(l)
|
||||
|
||||
probs = [x[-1] for i,x in enumerate(l) if i in terminal]
|
||||
simplify(probs)
|
||||
return probs
|
||||
14
Google FooBar/elevatorVersion.py
Normal file
14
Google FooBar/elevatorVersion.py
Normal file
@ -0,0 +1,14 @@
|
||||
def ver_val(s):
|
||||
s = s.split(".")
|
||||
length = len(s)
|
||||
s += ['0']*(3-length) # Outer pad array right zeros.
|
||||
s = ['0'*(3-len(x)) + x for x in s] # Inner pad string left zeros
|
||||
s += [str(length)] # Take length into consideration, less is better.
|
||||
return ''.join(s)
|
||||
|
||||
|
||||
def solution(l):
|
||||
d = dict()
|
||||
for version in l: d[version] = ver_val(version)
|
||||
l.sort(key=lambda x: d[x])
|
||||
return l
|
||||
81
Google FooBar/expandingNebula.py
Normal file
81
Google FooBar/expandingNebula.py
Normal file
@ -0,0 +1,81 @@
|
||||
def gen_masks(h):
|
||||
# Cache numbers with one bit.
|
||||
ones = [1 << x for x in range(h*2)]
|
||||
|
||||
trans = [] # AND masks for applying the transform.
|
||||
init = int(("11"+"0"*(h-2))*2, 2)
|
||||
for i in range(h-1): trans.append(init >> i)
|
||||
|
||||
return (ones, trans)
|
||||
|
||||
|
||||
def col(g, i):
|
||||
return [x[i] for x in g]
|
||||
|
||||
|
||||
def get_preimages(col, o, t, bound=None):
|
||||
# Obtains the valid preimages.
|
||||
valid = {}
|
||||
branches = 0
|
||||
h = len(col) + 1
|
||||
|
||||
if bound == None:
|
||||
for n in range(o[-1]*2): # All possible preimages.
|
||||
if n in o: continue
|
||||
for i,m in enumerate(t):
|
||||
if col[i] != ((n & m) in o): break
|
||||
else:
|
||||
if n not in valid: valid[n] = 0
|
||||
valid[n] += 1
|
||||
# Dictionary not necessary for first run, but keep for consistentcy.
|
||||
branches = sum(valid.values())
|
||||
else:
|
||||
for b in bound.keys(): # Preimages bound by the last valid columns.
|
||||
branches -= bound[b]
|
||||
for x in range(1 << h):
|
||||
n = x + b
|
||||
for i,m in enumerate(t):
|
||||
if col[i] != ((n & m) in o): break
|
||||
else:
|
||||
if n not in valid: valid[n] = 0
|
||||
# Keep track of what to remove later. Carrythrough.
|
||||
valid[n] += bound[b]
|
||||
branches += bound[b]
|
||||
|
||||
new_bound = dict()
|
||||
# AND mask for extracting second column. (Last 4 bits)
|
||||
mask = int("0"*h+"1"*h, 2)
|
||||
for n in valid:
|
||||
a = (n & mask) << h
|
||||
if a not in new_bound: new_bound[a] = 0
|
||||
new_bound[a] += valid[n]
|
||||
|
||||
return (branches, new_bound)
|
||||
|
||||
|
||||
def solution(g):
|
||||
o, t = gen_masks(len(g)+1)
|
||||
|
||||
count, bound = get_preimages(col(g, 0), o, t)
|
||||
for i in range(1, len(g[0])):
|
||||
c, bound = get_preimages(col(g, i), o, t, bound)
|
||||
count += c
|
||||
|
||||
print("Count", count)
|
||||
return count
|
||||
|
||||
|
||||
solution([[True, False, True], [False, True, False], [True, False, True]])
|
||||
solution([
|
||||
[True, False, True, False, False, True, True, True],
|
||||
[True, False, True, False, False, False, True, False],
|
||||
[True, True, True, False, False, False, True, False],
|
||||
[True, False, True, False, False, False, True, False],
|
||||
[True, False, True, False, False, True, True, True]])
|
||||
solution([[True, True, False, True, False, True, False, True, True, False], [True, True, False, False, False, False, True, True, True, False], [True, True, False, False, False, False, False, False, False, True], [False, True, False, False, False, False, True, True, False, False]])
|
||||
solution([
|
||||
[True, False, True, False, False, True, True, True, True, False, True, False, False, True, True, True],
|
||||
[True, False, True, False, False, False, True, False, True, False, True, False, False, False, True, False],
|
||||
[True, True, True, False, False, False, True, False, True, True, True, False, False, False, True, False],
|
||||
[True, False, True, False, False, False, True, False, True, False, True, False, False, False, True, False],
|
||||
[True, False, True, False, False, True, True, True, True, False, True, False, False, True, True, True]])
|
||||
10
Google FooBar/freeBunnies.py
Normal file
10
Google FooBar/freeBunnies.py
Normal file
@ -0,0 +1,10 @@
|
||||
from itertools import combinations
|
||||
|
||||
def solution(buns, reqs):
|
||||
l = [ [] for x in range(buns) ]
|
||||
c = combinations(range(buns), buns-reqs+1)
|
||||
for i,t in enumerate(c):
|
||||
for n in t: l[n].append(i)
|
||||
|
||||
return l
|
||||
|
||||
108
Google FooBar/gunFight.py
Normal file
108
Google FooBar/gunFight.py
Normal file
@ -0,0 +1,108 @@
|
||||
class Vector:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __add__(self, v2):
|
||||
return Vector(self.x + v2.x, self.y + v2.y)
|
||||
|
||||
def __sub__(self, v2):
|
||||
return Vector(self.x - v2.x, self.y - v2.y)
|
||||
|
||||
def __mul__(self, v2):
|
||||
if isinstance(v2, int):
|
||||
return Vector(self.x * v2, self.y * v2)
|
||||
else:
|
||||
return Vector(self.x * v2.x, self.y * v2.y)
|
||||
|
||||
__rmul__ = __mul__
|
||||
|
||||
def __str__(self):
|
||||
return "{" + str(self.x) + ", " + str(self.y) + "}"
|
||||
|
||||
def __repr__(self):
|
||||
return "{" + str(self.x) + ", " + str(self.y) + "}"
|
||||
|
||||
def mag(self):
|
||||
# Magnitude squared. For our scenario, this is
|
||||
# irrelvant, since sqrt is a monotonic function.
|
||||
# Caches magnitude, need to update manually.
|
||||
self.magnitude = self.x**2 + self.y**2
|
||||
return self
|
||||
|
||||
def whole(self):
|
||||
# Gets reduced form of vector for parallel comparison.
|
||||
# Caches, need to update manually
|
||||
if self.x == 0 and self.y == 0:
|
||||
self.whole = (0,0)
|
||||
elif self.x == 0:
|
||||
self.whole = (0, sgn(self.y))
|
||||
elif self.y == 0:
|
||||
self.whole = (sgn(self.x), 0)
|
||||
else:
|
||||
d = gcd(abs(self.x), abs(self.y))
|
||||
self.whole = (self.x/d, self.y/d)
|
||||
return self
|
||||
|
||||
|
||||
def abs(a):
|
||||
return a if a > 0 else -a
|
||||
|
||||
|
||||
def sgn(a):
|
||||
return -1 if a < 0 else 1
|
||||
|
||||
|
||||
def gcd(a, b):
|
||||
while b > 0:
|
||||
a, b = b, a % b
|
||||
return a
|
||||
|
||||
|
||||
def gen_spiral(w):
|
||||
x = []
|
||||
i, j, dc = 0, 0, [0, -1]
|
||||
for z in range((2*w + 1)**2):
|
||||
x.append((i, j))
|
||||
if i == j or (i < 0 and i == -j) or (i > 0 and i == 1 - j):
|
||||
dc = [-dc[1], dc[0]]
|
||||
i, j = i+dc[0], j+dc[1]
|
||||
return x
|
||||
|
||||
|
||||
def solution(dim, pos_y, pos_g, dist):
|
||||
dim, pos_y, pos_g = Vector(*dim), Vector(*pos_y), Vector(*pos_g)
|
||||
|
||||
# Vectors of all mirrors of you and guard.
|
||||
count = 0
|
||||
all_you_set, all_guard_set = set(), set()
|
||||
|
||||
w = (dist / min([dim.x, dim.y])) + 1
|
||||
dist = dist**2
|
||||
spiral = gen_spiral(w)
|
||||
|
||||
hits = set()
|
||||
|
||||
off_y, off_g = (-2*pos_y + dim), (-2*pos_g + dim)
|
||||
for c in spiral:
|
||||
base = Vector(*c) * dim
|
||||
|
||||
# Handle mirror reflections every other.
|
||||
decide = Vector(int(c[0] % 2 == 1), int(c[1] % 2 == 1))
|
||||
|
||||
mir_y = (base + decide * off_y).mag().whole()
|
||||
mir_g = ((base + pos_g + decide * off_g) - pos_y).mag().whole()
|
||||
|
||||
# Check that new vectors don't already exist.
|
||||
y_len, g_len = len(all_you_set), len(all_guard_set)
|
||||
all_you_set.add(mir_y.whole)
|
||||
all_guard_set.add(mir_g.whole)
|
||||
uniq_y = y_len != len(all_you_set)
|
||||
uniq_g = g_len != len(all_guard_set)
|
||||
|
||||
# Since we spiral out, any guard vector in set of you vectors must
|
||||
# hit you first.
|
||||
if mir_g.whole in all_you_set: continue
|
||||
if mir_g.magnitude <= dist and uniq_g: count += 1
|
||||
|
||||
return count
|
||||
10
Google FooBar/luckyTriple.py
Normal file
10
Google FooBar/luckyTriple.py
Normal file
@ -0,0 +1,10 @@
|
||||
def solution(l):
|
||||
divs = [0]*len(l)
|
||||
tups = 0
|
||||
for i in range(len(l)):
|
||||
for j in range(i):
|
||||
if l[i] % l[j] == 0:
|
||||
divs[i] += 1
|
||||
tups += divs[j]
|
||||
|
||||
return tups
|
||||
24
Google FooBar/primeGen.py
Normal file
24
Google FooBar/primeGen.py
Normal file
@ -0,0 +1,24 @@
|
||||
s = "23"
|
||||
i = 4
|
||||
while True:
|
||||
prime = True
|
||||
for j in range(2, i):
|
||||
if i/j == i//j:
|
||||
prime = False
|
||||
|
||||
if prime:
|
||||
s += str(i)
|
||||
print(i)
|
||||
if len(s) >= 10005: break
|
||||
i += 1
|
||||
|
||||
|
||||
final = ""
|
||||
for i in range(len(s)//60):
|
||||
final += "\"" + s[i*60:(i+1)*60] + "\"\\\n"
|
||||
|
||||
final += "\"" + s[60*(len(s)//60):] + "\"\\\n"
|
||||
|
||||
f = open("primes.txt","w")
|
||||
f.write(final)
|
||||
f.close()
|
||||
167
Google FooBar/primes.txt
Normal file
167
Google FooBar/primes.txt
Normal file
@ -0,0 +1,167 @@
|
||||
"235711131719232931374143475359616771737983899710110310710911"\
|
||||
"312713113713914915115716316717317918119119319719921122322722"\
|
||||
"923323924125125726326927127728128329330731131331733133734734"\
|
||||
"935335936737337938338939740140941942143143343944344945746146"\
|
||||
"346747948749149950350952152354154755756356957157758759359960"\
|
||||
"160761361761963164164364765365966167367768369170170971972773"\
|
||||
"373974375175776176977378779780981182182382782983985385785986"\
|
||||
"387788188388790791191992993794194795396797197798399199710091"\
|
||||
"013101910211031103310391049105110611063106910871091109310971"\
|
||||
"103110911171123112911511153116311711181118711931201121312171"\
|
||||
"223122912311237124912591277127912831289129112971301130313071"\
|
||||
"319132113271361136713731381139914091423142714291433143914471"\
|
||||
"451145314591471148114831487148914931499151115231531154315491"\
|
||||
"553155915671571157915831597160116071609161316191621162716371"\
|
||||
"657166316671669169316971699170917211723173317411747175317591"\
|
||||
"777178317871789180118111823183118471861186718711873187718791"\
|
||||
"889190119071913193119331949195119731979198719931997199920032"\
|
||||
"011201720272029203920532063206920812083208720892099211121132"\
|
||||
"129213121372141214321532161217922032207221322212237223922432"\
|
||||
"251226722692273228122872293229723092311233323392341234723512"\
|
||||
"357237123772381238323892393239924112417242324372441244724592"\
|
||||
"467247324772503252125312539254325492551255725792591259326092"\
|
||||
"617262126332647265726592663267126772683268726892693269927072"\
|
||||
"711271327192729273127412749275327672777278927912797280128032"\
|
||||
"819283328372843285128572861287928872897290329092917292729392"\
|
||||
"953295729632969297129993001301130193023303730413049306130673"\
|
||||
"079308330893109311931213137316331673169318131873191320332093"\
|
||||
"217322132293251325332573259327132993301330733133319332333293"\
|
||||
"331334333473359336133713373338933913407341334333449345734613"\
|
||||
"463346734693491349935113517352735293533353935413547355735593"\
|
||||
"571358135833593360736133617362336313637364336593671367336773"\
|
||||
"691369737013709371937273733373937613767376937793793379738033"\
|
||||
"821382338333847385138533863387738813889390739113917391939233"\
|
||||
"929393139433947396739894001400340074013401940214027404940514"\
|
||||
"057407340794091409340994111412741294133413941534157415941774"\
|
||||
"201421142174219422942314241424342534259426142714273428342894"\
|
||||
"297432743374339434943574363437343914397440944214423444144474"\
|
||||
"451445744634481448344934507451345174519452345474549456145674"\
|
||||
"583459145974603462146374639464346494651465746634673467946914"\
|
||||
"703472147234729473347514759478347874789479347994801481348174"\
|
||||
"831486148714877488949034909491949314933493749434951495749674"\
|
||||
"969497349874993499950035009501150215023503950515059507750815"\
|
||||
"087509951015107511351195147515351675171517951895197520952275"\
|
||||
"231523352375261527352795281529753035309532353335347535153815"\
|
||||
"387539353995407541354175419543154375441544354495471547754795"\
|
||||
"483550155035507551955215527553155575563556955735581559156235"\
|
||||
"639564156475651565356575659566956835689569357015711571757375"\
|
||||
"741574357495779578357915801580758135821582758395843584958515"\
|
||||
"857586158675869587958815897590359235927593959535981598760076"\
|
||||
"011602960376043604760536067607360796089609161016113612161316"\
|
||||
"133614361516163617361976199620362116217622162296247625762636"\
|
||||
"269627162776287629963016311631763236329633763436353635963616"\
|
||||
"367637363796389639764216427644964516469647364816491652165296"\
|
||||
"547655165536563656965716577658165996607661966376653665966616"\
|
||||
"673667966896691670167036709671967336737676167636779678167916"\
|
||||
"793680368236827682968336841685768636869687168836899690769116"\
|
||||
"917694769496959696169676971697769836991699770017013701970277"\
|
||||
"039704370577069707971037109712171277129715171597177718771937"\
|
||||
"207721172137219722972377243724772537283729773077309732173317"\
|
||||
"333734973517369739374117417743374517457745974777481748774897"\
|
||||
"499750775177523752975377541754775497559756175737577758375897"\
|
||||
"591760376077621763976437649766976737681768776917699770377177"\
|
||||
"723772777417753775777597789779378177823782978417853786778737"\
|
||||
"877787978837901790779197927793379377949795179637993800980118"\
|
||||
"017803980538059806980818087808980938101811181178123814781618"\
|
||||
"167817181798191820982198221823182338237824382638269827382878"\
|
||||
"291829382978311831783298353836383698377838783898419842384298"\
|
||||
"431844384478461846785018513852185278537853985438563857385818"\
|
||||
"597859986098623862786298641864786638669867786818689869386998"\
|
||||
"707871387198731873787418747875387618779878388038807881988218"\
|
||||
"831883788398849886188638867888788938923892989338941895189638"\
|
||||
"969897189999001900790119013902990419043904990599067909191039"\
|
||||
"109912791339137915191579161917391819187919992039209922192279"\
|
||||
"239924192579277928192839293931193199323933793419343934993719"\
|
||||
"377939193979403941394199421943194339437943994619463946794739"\
|
||||
"479949194979511952195339539954795519587960196139619962396299"\
|
||||
"631964396499661967796799689969797199721973397399743974997679"\
|
||||
"769978197879791980398119817982998339839985198579859987198839"\
|
||||
"887990199079923992999319941994999679973100071000910037100391"\
|
||||
"006110067100691007910091100931009910103101111013310139101411"\
|
||||
"015110159101631016910177101811019310211102231024310247102531"\
|
||||
"025910267102711027310289103011030310313103211033110333103371"\
|
||||
"034310357103691039110399104271042910433104531045710459104631"\
|
||||
"047710487104991050110513105291053110559105671058910597106011"\
|
||||
"060710613106271063110639106511065710663106671068710691107091"\
|
||||
"071110723107291073310739107531077110781107891079910831108371"\
|
||||
"084710853108591086110867108831088910891109031090910937109391"\
|
||||
"094910957109731097910987109931100311027110471105711059110691"\
|
||||
"107111083110871109311113111171111911131111491115911161111711"\
|
||||
"117311177111971121311239112431125111257112611127311279112871"\
|
||||
"129911311113171132111329113511135311369113831139311399114111"\
|
||||
"142311437114431144711467114711148311489114911149711503115191"\
|
||||
"152711549115511157911587115931159711617116211163311657116771"\
|
||||
"168111689116991170111717117191173111743117771177911783117891"\
|
||||
"180111807118131182111827118311183311839118631186711887118971"\
|
||||
"190311909119231192711933119391194111953119591196911971119811"\
|
||||
"198712007120111203712041120431204912071120731209712101121071"\
|
||||
"210912113121191214312149121571216112163121971220312211122271"\
|
||||
"223912241122511225312263122691227712281122891230112323123291"\
|
||||
"234312347123731237712379123911240112409124131242112433124371"\
|
||||
"245112457124731247912487124911249712503125111251712527125391"\
|
||||
"254112547125531256912577125831258912601126111261312619126371"\
|
||||
"264112647126531265912671126891269712703127131272112739127431"\
|
||||
"275712763127811279112799128091282112823128291284112853128891"\
|
||||
"289312899129071291112917129191292312941129531295912967129731"\
|
||||
"297912983130011300313007130091303313037130431304913063130931"\
|
||||
"309913103131091312113127131471315113159131631317113177131831"\
|
||||
"318713217132191322913241132491325913267132911329713309133131"\
|
||||
"332713331133371333913367133811339713399134111341713421134411"\
|
||||
"345113457134631346913477134871349913513135231353713553135671"\
|
||||
"357713591135971361313619136271363313649136691367913681136871"\
|
||||
"369113693136971370913711137211372313729137511375713759137631"\
|
||||
"378113789137991380713829138311384113859138731387713879138831"\
|
||||
"390113903139071391313921139311393313963139671399713999140091"\
|
||||
"401114029140331405114057140711408114083140871410714143141491"\
|
||||
"415314159141731417714197142071422114243142491425114281142931"\
|
||||
"430314321143231432714341143471436914387143891440114407144111"\
|
||||
"441914423144311443714447144491446114479144891450314519145331"\
|
||||
"453714543145491455114557145611456314591145931462114627146291"\
|
||||
"463314639146531465714669146831469914713147171472314731147371"\
|
||||
"474114747147531475914767147711477914783147971481314821148271"\
|
||||
"483114843148511486714869148791488714891148971492314929149391"\
|
||||
"494714951149571496914983150131501715031150531506115073150771"\
|
||||
"508315091151011510715121151311513715139151491516115173151871"\
|
||||
"519315199152171522715233152411525915263152691527115277152871"\
|
||||
"528915299153071531315319153291533115349153591536115373153771"\
|
||||
"538315391154011541315427154391544315451154611546715473154931"\
|
||||
"549715511155271554115551155591556915581155831560115607156191"\
|
||||
"562915641156431564715649156611566715671156791568315727157311"\
|
||||
"573315737157391574915761157671577315787157911579715803158091"\
|
||||
"581715823158591587715881158871588915901159071591315919159231"\
|
||||
"593715959159711597315991160011600716033160571606116063160671"\
|
||||
"606916073160871609116097161031611116127161391614116183161871"\
|
||||
"618916193162171622316229162311624916253162671627316301163191"\
|
||||
"633316339163491636116363163691638116411164171642116427164331"\
|
||||
"644716451164531647716481164871649316519165291654716553165611"\
|
||||
"656716573166031660716619166311663316649166511665716661166731"\
|
||||
"669116693166991670316729167411674716759167631678716811168231"\
|
||||
"682916831168431687116879168831688916901169031692116927169311"\
|
||||
"693716943169631697916981169871699317011170211702717029170331"\
|
||||
"704117047170531707717093170991710717117171231713717159171671"\
|
||||
"718317189171911720317207172091723117239172571729117293172991"\
|
||||
"731717321173271733317341173511735917377173831738717389173931"\
|
||||
"740117417174191743117443174491746717471174771748317489174911"\
|
||||
"749717509175191753917551175691757317579175811759717599176091"\
|
||||
"762317627176571765917669176811768317707177131772917737177471"\
|
||||
"774917761177831778917791178071782717837178391785117863178811"\
|
||||
"789117903179091791117921179231792917939179571795917971179771"\
|
||||
"798117987179891801318041180431804718049180591806118077180891"\
|
||||
"809718119181211812718131181331814318149181691818118191181991"\
|
||||
"821118217182231822918233182511825318257182691828718289183011"\
|
||||
"830718311183131832918341183531836718371183791839718401184131"\
|
||||
"842718433184391844318451184571846118481184931850318517185211"\
|
||||
"852318539185411855318583185871859318617186371866118671186791"\
|
||||
"869118701187131871918731187431874918757187731878718793187971"\
|
||||
"880318839188591886918899189111891318917189191894718959189731"\
|
||||
"897919001190091901319031190371905119069190731907919081190871"\
|
||||
"912119139191411915719163191811918319207192111921319219192311"\
|
||||
"923719249192591926719273192891930119309193191933319373193791"\
|
||||
"938119387193911940319417194211942319427194291943319441194471"\
|
||||
"945719463194691947119477194831948919501195071953119541195431"\
|
||||
"955319559195711957719583195971960319609196611968119687196971"\
|
||||
"969919709197171972719739197511975319759197631977719793198011"\
|
||||
"981319819198411984319853198611986719889198911991319919199271"\
|
||||
"993719949199611996319973199791999119993199972001120021200232"\
|
||||
"002920047200512006320071200892010120107201132011720123201292"\
|
||||
"0143201472014920161201732017720183202012021920231"\
|
||||
170
Google FooBar/reid.py
Normal file
170
Google FooBar/reid.py
Normal file
@ -0,0 +1,170 @@
|
||||
def solution(i):
|
||||
primes = "235711131719232931374143475359616771737983899710110310710911"\
|
||||
"312713113713914915115716316717317918119119319719921122322722"\
|
||||
"923323924125125726326927127728128329330731131331733133734734"\
|
||||
"935335936737337938338939740140941942143143343944344945746146"\
|
||||
"346747948749149950350952152354154755756356957157758759359960"\
|
||||
"160761361761963164164364765365966167367768369170170971972773"\
|
||||
"373974375175776176977378779780981182182382782983985385785986"\
|
||||
"387788188388790791191992993794194795396797197798399199710091"\
|
||||
"013101910211031103310391049105110611063106910871091109310971"\
|
||||
"103110911171123112911511153116311711181118711931201121312171"\
|
||||
"223122912311237124912591277127912831289129112971301130313071"\
|
||||
"319132113271361136713731381139914091423142714291433143914471"\
|
||||
"451145314591471148114831487148914931499151115231531154315491"\
|
||||
"553155915671571157915831597160116071609161316191621162716371"\
|
||||
"657166316671669169316971699170917211723173317411747175317591"\
|
||||
"777178317871789180118111823183118471861186718711873187718791"\
|
||||
"889190119071913193119331949195119731979198719931997199920032"\
|
||||
"011201720272029203920532063206920812083208720892099211121132"\
|
||||
"129213121372141214321532161217922032207221322212237223922432"\
|
||||
"251226722692273228122872293229723092311233323392341234723512"\
|
||||
"357237123772381238323892393239924112417242324372441244724592"\
|
||||
"467247324772503252125312539254325492551255725792591259326092"\
|
||||
"617262126332647265726592663267126772683268726892693269927072"\
|
||||
"711271327192729273127412749275327672777278927912797280128032"\
|
||||
"819283328372843285128572861287928872897290329092917292729392"\
|
||||
"953295729632969297129993001301130193023303730413049306130673"\
|
||||
"079308330893109311931213137316331673169318131873191320332093"\
|
||||
"217322132293251325332573259327132993301330733133319332333293"\
|
||||
"331334333473359336133713373338933913407341334333449345734613"\
|
||||
"463346734693491349935113517352735293533353935413547355735593"\
|
||||
"571358135833593360736133617362336313637364336593671367336773"\
|
||||
"691369737013709371937273733373937613767376937793793379738033"\
|
||||
"821382338333847385138533863387738813889390739113917391939233"\
|
||||
"929393139433947396739894001400340074013401940214027404940514"\
|
||||
"057407340794091409340994111412741294133413941534157415941774"\
|
||||
"201421142174219422942314241424342534259426142714273428342894"\
|
||||
"297432743374339434943574363437343914397440944214423444144474"\
|
||||
"451445744634481448344934507451345174519452345474549456145674"\
|
||||
"583459145974603462146374639464346494651465746634673467946914"\
|
||||
"703472147234729473347514759478347874789479347994801481348174"\
|
||||
"831486148714877488949034909491949314933493749434951495749674"\
|
||||
"969497349874993499950035009501150215023503950515059507750815"\
|
||||
"087509951015107511351195147515351675171517951895197520952275"\
|
||||
"231523352375261527352795281529753035309532353335347535153815"\
|
||||
"387539353995407541354175419543154375441544354495471547754795"\
|
||||
"483550155035507551955215527553155575563556955735581559156235"\
|
||||
"639564156475651565356575659566956835689569357015711571757375"\
|
||||
"741574357495779578357915801580758135821582758395843584958515"\
|
||||
"857586158675869587958815897590359235927593959535981598760076"\
|
||||
"011602960376043604760536067607360796089609161016113612161316"\
|
||||
"133614361516163617361976199620362116217622162296247625762636"\
|
||||
"269627162776287629963016311631763236329633763436353635963616"\
|
||||
"367637363796389639764216427644964516469647364816491652165296"\
|
||||
"547655165536563656965716577658165996607661966376653665966616"\
|
||||
"673667966896691670167036709671967336737676167636779678167916"\
|
||||
"793680368236827682968336841685768636869687168836899690769116"\
|
||||
"917694769496959696169676971697769836991699770017013701970277"\
|
||||
"039704370577069707971037109712171277129715171597177718771937"\
|
||||
"207721172137219722972377243724772537283729773077309732173317"\
|
||||
"333734973517369739374117417743374517457745974777481748774897"\
|
||||
"499750775177523752975377541754775497559756175737577758375897"\
|
||||
"591760376077621763976437649766976737681768776917699770377177"\
|
||||
"723772777417753775777597789779378177823782978417853786778737"\
|
||||
"877787978837901790779197927793379377949795179637993800980118"\
|
||||
"017803980538059806980818087808980938101811181178123814781618"\
|
||||
"167817181798191820982198221823182338237824382638269827382878"\
|
||||
"291829382978311831783298353836383698377838783898419842384298"\
|
||||
"431844384478461846785018513852185278537853985438563857385818"\
|
||||
"597859986098623862786298641864786638669867786818689869386998"\
|
||||
"707871387198731873787418747875387618779878388038807881988218"\
|
||||
"831883788398849886188638867888788938923892989338941895189638"\
|
||||
"969897189999001900790119013902990419043904990599067909191039"\
|
||||
"109912791339137915191579161917391819187919992039209922192279"\
|
||||
"239924192579277928192839293931193199323933793419343934993719"\
|
||||
"377939193979403941394199421943194339437943994619463946794739"\
|
||||
"479949194979511952195339539954795519587960196139619962396299"\
|
||||
"631964396499661967796799689969797199721973397399743974997679"\
|
||||
"769978197879791980398119817982998339839985198579859987198839"\
|
||||
"887990199079923992999319941994999679973100071000910037100391"\
|
||||
"006110067100691007910091100931009910103101111013310139101411"\
|
||||
"015110159101631016910177101811019310211102231024310247102531"\
|
||||
"025910267102711027310289103011030310313103211033110333103371"\
|
||||
"034310357103691039110399104271042910433104531045710459104631"\
|
||||
"047710487104991050110513105291053110559105671058910597106011"\
|
||||
"060710613106271063110639106511065710663106671068710691107091"\
|
||||
"071110723107291073310739107531077110781107891079910831108371"\
|
||||
"084710853108591086110867108831088910891109031090910937109391"\
|
||||
"094910957109731097910987109931100311027110471105711059110691"\
|
||||
"107111083110871109311113111171111911131111491115911161111711"\
|
||||
"117311177111971121311239112431125111257112611127311279112871"\
|
||||
"129911311113171132111329113511135311369113831139311399114111"\
|
||||
"142311437114431144711467114711148311489114911149711503115191"\
|
||||
"152711549115511157911587115931159711617116211163311657116771"\
|
||||
"168111689116991170111717117191173111743117771177911783117891"\
|
||||
"180111807118131182111827118311183311839118631186711887118971"\
|
||||
"190311909119231192711933119391194111953119591196911971119811"\
|
||||
"198712007120111203712041120431204912071120731209712101121071"\
|
||||
"210912113121191214312149121571216112163121971220312211122271"\
|
||||
"223912241122511225312263122691227712281122891230112323123291"\
|
||||
"234312347123731237712379123911240112409124131242112433124371"\
|
||||
"245112457124731247912487124911249712503125111251712527125391"\
|
||||
"254112547125531256912577125831258912601126111261312619126371"\
|
||||
"264112647126531265912671126891269712703127131272112739127431"\
|
||||
"275712763127811279112799128091282112823128291284112853128891"\
|
||||
"289312899129071291112917129191292312941129531295912967129731"\
|
||||
"297912983130011300313007130091303313037130431304913063130931"\
|
||||
"309913103131091312113127131471315113159131631317113177131831"\
|
||||
"318713217132191322913241132491325913267132911329713309133131"\
|
||||
"332713331133371333913367133811339713399134111341713421134411"\
|
||||
"345113457134631346913477134871349913513135231353713553135671"\
|
||||
"357713591135971361313619136271363313649136691367913681136871"\
|
||||
"369113693136971370913711137211372313729137511375713759137631"\
|
||||
"378113789137991380713829138311384113859138731387713879138831"\
|
||||
"390113903139071391313921139311393313963139671399713999140091"\
|
||||
"401114029140331405114057140711408114083140871410714143141491"\
|
||||
"415314159141731417714197142071422114243142491425114281142931"\
|
||||
"430314321143231432714341143471436914387143891440114407144111"\
|
||||
"441914423144311443714447144491446114479144891450314519145331"\
|
||||
"453714543145491455114557145611456314591145931462114627146291"\
|
||||
"463314639146531465714669146831469914713147171472314731147371"\
|
||||
"474114747147531475914767147711477914783147971481314821148271"\
|
||||
"483114843148511486714869148791488714891148971492314929149391"\
|
||||
"494714951149571496914983150131501715031150531506115073150771"\
|
||||
"508315091151011510715121151311513715139151491516115173151871"\
|
||||
"519315199152171522715233152411525915263152691527115277152871"\
|
||||
"528915299153071531315319153291533115349153591536115373153771"\
|
||||
"538315391154011541315427154391544315451154611546715473154931"\
|
||||
"549715511155271554115551155591556915581155831560115607156191"\
|
||||
"562915641156431564715649156611566715671156791568315727157311"\
|
||||
"573315737157391574915761157671577315787157911579715803158091"\
|
||||
"581715823158591587715881158871588915901159071591315919159231"\
|
||||
"593715959159711597315991160011600716033160571606116063160671"\
|
||||
"606916073160871609116097161031611116127161391614116183161871"\
|
||||
"618916193162171622316229162311624916253162671627316301163191"\
|
||||
"633316339163491636116363163691638116411164171642116427164331"\
|
||||
"644716451164531647716481164871649316519165291654716553165611"\
|
||||
"656716573166031660716619166311663316649166511665716661166731"\
|
||||
"669116693166991670316729167411674716759167631678716811168231"\
|
||||
"682916831168431687116879168831688916901169031692116927169311"\
|
||||
"693716943169631697916981169871699317011170211702717029170331"\
|
||||
"704117047170531707717093170991710717117171231713717159171671"\
|
||||
"718317189171911720317207172091723117239172571729117293172991"\
|
||||
"731717321173271733317341173511735917377173831738717389173931"\
|
||||
"740117417174191743117443174491746717471174771748317489174911"\
|
||||
"749717509175191753917551175691757317579175811759717599176091"\
|
||||
"762317627176571765917669176811768317707177131772917737177471"\
|
||||
"774917761177831778917791178071782717837178391785117863178811"\
|
||||
"789117903179091791117921179231792917939179571795917971179771"\
|
||||
"798117987179891801318041180431804718049180591806118077180891"\
|
||||
"809718119181211812718131181331814318149181691818118191181991"\
|
||||
"821118217182231822918233182511825318257182691828718289183011"\
|
||||
"830718311183131832918341183531836718371183791839718401184131"\
|
||||
"842718433184391844318451184571846118481184931850318517185211"\
|
||||
"852318539185411855318583185871859318617186371866118671186791"\
|
||||
"869118701187131871918731187431874918757187731878718793187971"\
|
||||
"880318839188591886918899189111891318917189191894718959189731"\
|
||||
"897919001190091901319031190371905119069190731907919081190871"\
|
||||
"912119139191411915719163191811918319207192111921319219192311"\
|
||||
"923719249192591926719273192891930119309193191933319373193791"\
|
||||
"938119387193911940319417194211942319427194291943319441194471"\
|
||||
"945719463194691947119477194831948919501195071953119541195431"\
|
||||
"955319559195711957719583195971960319609196611968119687196971"\
|
||||
"969919709197171972719739197511975319759197631977719793198011"\
|
||||
"981319819198411984319853198611986719889198911991319919199271"\
|
||||
"993719949199611996319973199791999119993199972001120021200232"\
|
||||
"002920047200512006320071200892010120107201132011720123201292"\
|
||||
"0143201472014920161201732017720183202012021920231"\
|
||||
|
||||
return primes[i:i+5]
|
||||
22
Google FooBar/setCounting.txt
Normal file
22
Google FooBar/setCounting.txt
Normal file
@ -0,0 +1,22 @@
|
||||
Distributing keys to A people, where
|
||||
B people are required to unlock, requires:
|
||||
A choose B-1 keys.
|
||||
|
||||
We can distribute following possible combinations:
|
||||
|
||||
Ex: 5 people, 2 required: 5 C 3 = 10
|
||||
|
||||
0123
|
||||
012 4
|
||||
01 34
|
||||
0 234
|
||||
1234
|
||||
|
||||
We obtain A choose B-1, from seeing that we require
|
||||
the combinations to be generated from A-B+1.
|
||||
|
||||
This is obtained from A-G+1 = B,
|
||||
People - GroupSize + 1 = Required,
|
||||
G = A-B+1
|
||||
|
||||
A choose A-B+1 = A choose B-1
|
||||
Loading…
x
Reference in New Issue
Block a user