Add initial code
This commit is contained in:
commit
bdb63f5837
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
require_once('/var/www/fwd/template/build.php');
|
||||
|
||||
print(buildFelixPage(array(
|
||||
'scriptBottomInclude' => [array('src' => 'js/jaro-winkler.min.js'), array('src' => 'js/levenshtein.min.js'), array('src' => 'js/main.min.js')],
|
||||
|
||||
'metaDescription' => 'Choose a fitting name for your character that Codsworth can pronounce.',
|
||||
'metaKeywords' => 'Fallout 4 fo4 Codsworth robot name character creation choose good',
|
||||
'metaAuthor' => 'Felix Dekker',
|
||||
'metaApplicationName' => 'Fallout 4 Codsworth name generator',
|
||||
'pageTitle' => 'Codsworth name generator',
|
||||
|
||||
//'navbar' => '/views/navbar.html',
|
||||
'contents' => 'views/index.html'
|
||||
)));
|
||||
?>
|
|
@ -0,0 +1,132 @@
|
|||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Jordan Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var jaro_winkler = function(a, b, options)
|
||||
{
|
||||
// Load default options
|
||||
options = optionDefault(
|
||||
{
|
||||
"caseSensitive" : true
|
||||
},
|
||||
options
|
||||
);
|
||||
|
||||
// Convert to lowercase if not case-sensitive
|
||||
if(!options.caseSensitive)
|
||||
{
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
var alen = a.length,
|
||||
blen = b.length;
|
||||
|
||||
// Short-circuit if either is empty
|
||||
if(alen === 0 || blen === 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Short-circuit if exact match
|
||||
if(a === b)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Calculate difference
|
||||
var i, j;
|
||||
var low, high,
|
||||
m = 0,
|
||||
range = (Math.floor(Math.max(alen, blen) / 2)) - 1,
|
||||
aMatches = [],
|
||||
bMatches = [];
|
||||
|
||||
// Find matches
|
||||
for(i = 0; i < alen; i++)
|
||||
{
|
||||
low = ((i >= range) ? i - range : 0);
|
||||
high = ((i + range <= blen) ? (i + range) : (blen - 1));
|
||||
|
||||
for(j = low; j <= high; j++)
|
||||
{
|
||||
if(aMatches[i] !== true && bMatches[j] !== true && a[i] === b[j])
|
||||
{
|
||||
aMatches[i] = true;
|
||||
bMatches[j] = true;
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Short-circuit if not matches found
|
||||
if(m === 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Count transpositions
|
||||
var k = 0,
|
||||
numTrans = 0;
|
||||
|
||||
for(i = 0; i < alen; i++)
|
||||
{
|
||||
if(aMatches[i] === true)
|
||||
{
|
||||
for(j = k; j < blen; j++)
|
||||
{
|
||||
if(bMatches[j] === true)
|
||||
{
|
||||
k = j + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(a[i] !== b[j])
|
||||
{
|
||||
numTrans++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var weight = (((m / alen) + (m / blen) + (m - (numTrans / 2)) / m) / 3);
|
||||
var l = 0,
|
||||
p = 0.1;
|
||||
|
||||
if(weight > 0.7)
|
||||
{
|
||||
while(a[l] === b[l] && l < 4)
|
||||
{
|
||||
l++;
|
||||
}
|
||||
|
||||
weight += l * p * (1 - weight);
|
||||
}
|
||||
|
||||
return weight;
|
||||
};
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2011 Andrei Mackenzie
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var levenshtein = function(a, b, options)
|
||||
{
|
||||
// Load default options
|
||||
options = optionDefault(
|
||||
{
|
||||
"caseSensitive" : true
|
||||
},
|
||||
options
|
||||
);
|
||||
|
||||
// Convert to lowercase if not case-sensitive
|
||||
if(!options.caseSensitive)
|
||||
{
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
var alen = a.length,
|
||||
blen = b.length;
|
||||
|
||||
if(alen == 0)
|
||||
{
|
||||
return blen;
|
||||
}
|
||||
if(blen == 0)
|
||||
{
|
||||
return alen;
|
||||
}
|
||||
|
||||
var matrix = [];
|
||||
|
||||
// Increment along the first column of each row
|
||||
for(var i = 0; i <= blen; i++)
|
||||
{
|
||||
matrix[i] = [i];
|
||||
}
|
||||
|
||||
// Increment each column in the first row
|
||||
for(var j = 0; j <= alen; j++)
|
||||
{
|
||||
matrix[0][j] = j;
|
||||
}
|
||||
|
||||
// Fill in the rest of the matrix
|
||||
for(i = 1; i <= blen; i++)
|
||||
{
|
||||
for(j = 1; j <= alen; j++)
|
||||
{
|
||||
if(b.charAt(i - 1) == a.charAt(j - 1))
|
||||
{
|
||||
matrix[i][j] = matrix[i - 1][j - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix[i][j] =
|
||||
min(
|
||||
matrix[i - 1][j - 1] + 1, // Substitution
|
||||
matrix[i][j - 1] + 1, // Insertion
|
||||
matrix[i - 1][j] + 1 // Deletion
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matrix[blen][alen];
|
||||
};
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Meta -->
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="author" content="Felix Dekker" />
|
||||
<meta name="application-name" content="Codsworth Name Generator" />
|
||||
|
||||
<!-- Stylesheets -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
|
||||
|
||||
<!-- Title -->
|
||||
<title>Codsworth Name Generator</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page-header">
|
||||
<h1>Codsworth name generator <small>for Fallout 4</small></h1>
|
||||
</div>
|
||||
|
||||
<p>Use these generators to help you choose a name for your <a href="https://www.fallout4.com/">Fallout 4</a> character that <a href="http://fallout.wikia.com/wiki/Codsworth">Codsworth</a> can pronounce! The names are selected from the list found in <a href="http://www.cinemablend.com/games/Fallout-4-Full-List-Names-Codsworth-Can-Say-98407.html">this article</a>.<br />
|
||||
Note that this only works for the English version of the game.</p>
|
||||
|
||||
<!-- Generators -->
|
||||
<div class="row">
|
||||
<!-- Similar -->
|
||||
<div class="col-md-6">
|
||||
<h2>Similar names</h2>
|
||||
<p>Want a name that is similar to your own (or your friend's) name? Enter your name below and the best matches are automatically selected!</p>
|
||||
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<input id="similarInput" class="form-control" type="text" placeholder="Your name" autofocus />
|
||||
</div>
|
||||
<button id="generateSimilar" class="btn btn-primary" type="submit">Generate similar names</button>
|
||||
</form><br /><br />
|
||||
|
||||
Similar names are...
|
||||
<textarea id="similarNames" class="form-control" rows="11" style="resize:vertical;" readonly></textarea>
|
||||
</div>
|
||||
<!-- /Similar -->
|
||||
|
||||
<!-- Random -->
|
||||
<div class="col-md-6">
|
||||
<h2>Random names</h2>
|
||||
<p>Not even a slight clue what you want your name to be and in for a surprise? Generate a random name!</p>
|
||||
|
||||
<form class="form-inline">
|
||||
<button id="generateRandom" class="btn btn-primary" type="submit">Generate random name</button>
|
||||
</form><br /><br />
|
||||
|
||||
Your name is...
|
||||
<textarea id="randomNames" class="form-control" rows="11" style="resize:vertical;" readonly></textarea>
|
||||
</div>
|
||||
<!-- /Random -->
|
||||
</div>
|
||||
<!-- /Generators -->
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue