Skip to content

Commit 9aa6887

Browse files
committed
[refactor] add random string adjectives count
1 parent 33990b8 commit 9aa6887

File tree

7 files changed

+71
-26
lines changed

7 files changed

+71
-26
lines changed

‎package-lock.json‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nightTab",
3-
"version": "5.5.4",
3+
"version": "5.6.0",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
55
"main": "index.js",
66
"scripts":{

‎src/js/helper.js‎

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ var helper = (function(){
2222

2323
varrandomString=function(override){
2424
varoptions={
25-
mix: null,
26-
letter: null
25+
letter: null,
26+
adjectivesCount: null
2727
};
2828
if(override){
2929
options=applyOptions(options,override);
3030
};
31-
varalphabet="abcdefghijklmnopqrstuvwxyz";
31+
varalphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
3232
varadjectives={
3333
a: ["Aback","Abaft","Abandoned","Abashed","Aberrant","Abhorrent","Abiding","Abject","Ablaze","Able","Abnormal","Aboriginal","Abortive","Abounding","Abrasive","Abrupt","Absent","Absorbed","Absorbing","Abstracted","Absurd","Abundant","Abusive","Acceptable","Accessible","Accidental","Accurate","Acid","Acidic","Acoustic","Acrid","Adamant","Adaptable","Addicted","Adhesive","Adjoining","Adorable","Adventurous","Afraid","Aggressive","Agonizing","Agreeable","Ahead","Ajar","Alert","Alike","Alive","Alleged","Alluring","Aloof","Amazing","Ambiguous","Ambitious","Amuck","Amused","Amusing","Ancient","Angry","Animated","Annoyed","Annoying","Anxious","Apathetic","Aquatic","Aromatic","Arrogant","Ashamed","Aspiring","Assorted","Astonishing","Attractive","Auspicious","Automatic","Available","Average","Aware","Awesome","Axiomatic"],
3434
b: ["Bad","Barbarous","Bashful","Bawdy","Beautiful","Befitting","Belligerent","Beneficial","Bent","Berserk","Bewildered","Big","Billowy","Bitter","Bizarre","Black","Bloody","Blue","Blushing","Boiling","Boorish","Bored","Boring","Bouncy","Boundless","Brainy","Brash","Brave","Brawny","Breakable","Breezy","Brief","Bright","Broad","Broken","Brown","Bumpy","Burly","Bustling","Busy"],
@@ -83,26 +83,71 @@ var helper = (function(){
8383
w: ["Wallaby","Walrus","Wasp","Weasel","Whale","Wolf","Wolverine","Wombat","Woodcock","Woodpecker","Worm","Wren"],
8484
x: ["Xaviers Greenbul","Xeme","Xingu Corydoras","Xolo"],
8585
y: ["Yabby","Yak","Yellowhammer","Yellowjacket"],
86-
z: ["Zebra","Zebu","Zokor","Zorilla"],
87-
};
88-
varseed;
89-
varmix=function(){
90-
varadjectivesSeed=alphabet[Math.floor(Math.random()*alphabet.length)];
91-
varanimalsSeed=alphabet[Math.floor(Math.random()*alphabet.length)];
92-
returnadjectives[adjectivesSeed][Math.floor(Math.random()*adjectives[adjectivesSeed].length)]+" "+animals[animalsSeed][Math.floor(Math.random()*animals[animalsSeed].length)];
86+
z: ["Zebra","Zebu","Zokor","Zorilla"]
87+
};
88+
89+
varaction={
90+
alliteration: {
91+
short: function(){
92+
varrandomAdjective=adjectives[options.letter.toLowerCase()][Math.floor(Math.random()*adjectives[options.letter.toLowerCase()].length)];
93+
varrandomAnimal=animals[options.letter.toLowerCase()][Math.floor(Math.random()*animals[options.letter.toLowerCase()].length)];
94+
returnrandomAdjective+" "+randomAnimal;
95+
},
96+
long: function(){
97+
varrandomAdjective="";
98+
for(vari=1;i<=options.adjectivesCount;i++){
99+
if(adjectives[options.letter.toLowerCase()].length>0){
100+
if(randomAdjective.length>0){
101+
randomAdjective=randomAdjective+" ";
102+
};
103+
randomAdjective=randomAdjective+adjectives[options.letter.toLowerCase()].splice(Math.floor(Math.random()*adjectives[options.letter.toLowerCase()].length),1);
104+
};
105+
};
106+
varrandomAnimal=animals[options.letter.toLowerCase()][Math.floor(Math.random()*animals[options.letter.toLowerCase()].length)];
107+
returnrandomAdjective+" "+randomAnimal;
108+
}
109+
},
110+
mix: {
111+
short: function(){
112+
varadjectivesSeed=alphabet[Math.floor(Math.random()*(alphabet.length-1))];
113+
varanimalsSeed=alphabet[Math.floor(Math.random()*(alphabet.length-1))];
114+
varrandomAdjective=adjectives[adjectivesSeed][Math.floor(Math.random()*adjectives[adjectivesSeed].length)];
115+
varrandomAnimal=animals[animalsSeed][Math.floor(Math.random()*animals[animalsSeed].length)];
116+
returnrandomAdjective+" "+randomAnimal;
117+
},
118+
long: function(){
119+
varrandomAdjective="";
120+
for(vari=1;i<=options.adjectivesCount;i++){
121+
varadjectiveLetter=alphabet[Math.floor(Math.random()*(alphabet.length-1))];
122+
if(adjectiveLetterinadjectives&&adjectives[adjectiveLetter].length>0){
123+
if(randomAdjective.length>0){
124+
randomAdjective=randomAdjective+" ";
125+
};
126+
randomAdjective=randomAdjective+adjectives[adjectiveLetter].splice(Math.floor(Math.random()*adjectives[adjectiveLetter].length),1);
127+
if(adjectives[adjectiveLetter].length==0){
128+
deleteadjectives[adjectiveLetter];
129+
};
130+
};
131+
};
132+
varrandomAnimalArray=animals[alphabet[Math.floor(Math.random()*(alphabet.length-1))]]
133+
varrandomAnimal=randomAnimalArray[Math.floor(Math.random()*(randomAnimalArray.length-1))];
134+
returnrandomAdjective+" "+randomAnimal;
135+
}
136+
}
93137
};
94-
varalliteration=function(){
95-
if(options.letter!=null){
96-
returnadjectives[options.letter.toLowerCase()][Math.floor(Math.random()*adjectives[options.letter.toLowerCase()].length)]+" "+animals[options.letter.toLowerCase()][Math.floor(Math.random()*animals[options.letter.toLowerCase()].length)];
138+
139+
if(options.letter!=null&&alphabet.includes(options.letter.toLowerCase())){
140+
if(options.adjectivesCount!=null&&options.adjectivesCount>0){
141+
returnaction.alliteration.long();
97142
}else{
98-
varseed=alphabet[Math.floor(Math.random()*alphabet.length)];
99-
returnadjectives[seed][Math.floor(Math.random()*adjectives[seed].length)]+" "+animals[seed][Math.floor(Math.random()*animals[seed].length)];
143+
returnaction.alliteration.short();
100144
};
101-
};
102-
if(options.mix){
103-
returnmix();
104145
}else{
105-
returnalliteration();
146+
if(options.adjectivesCount!=null&&options.adjectivesCount>0){
147+
returnaction.mix.long();
148+
}else{
149+
returnaction.mix.short();
150+
};
106151
};
107152
};
108153

‎src/js/link.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ var link = (function(){
647647
},false);
648648
groupFormRandomNameButton.addEventListener("click",function(event){
649649
varrandomName=helper.randomString({
650-
mix: true
650+
adjectivesCount: 2
651651
});
652652
stagedGroup.group.name.text=randomName;
653653
groupFormInputName.value=randomName;
@@ -1187,7 +1187,7 @@ var link = (function(){
11871187
},false);
11881188
groupNewRandomNameButton.addEventListener("click",function(event){
11891189
varrandomName=helper.randomString({
1190-
mix: true
1190+
adjectivesCount: 2
11911191
});
11921192
stagedLink.position.group.name.text=randomName;
11931193
groupNewInput.value=randomName;

‎src/js/theme.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,7 @@ var theme = (function(){
20792079

20802080
randomButton.addEventListener("click",function(event){
20812081
varrandomName=helper.randomString({
2082-
mix: true
2082+
adjectivesCount: 2
20832083
});
20842084
stagedThemeCustom.theme.name=randomName;
20852085
nameInput.value=randomName;

‎src/js/version.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
varversion=(function(){
22

3-
varcurrent="5.5.4";
3+
varcurrent="5.6.0";
44

55
varname="Zonked Tarsier";
66

‎src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nightTab",
33
"short_name": "nightTab",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
5-
"version": "5.5.4",
5+
"version": "5.6.0",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)