提问人:Yosuf 提问时间:4/18/2023 最后编辑:Scott MarcusYosuf 更新时间:4/18/2023 访问量:39
变量为 true,但图像未转换为 Gifs - 类 / ElementID
Variable is true but images are not turning to Gifs - Class / ElementID
问:
我正在尝试将图像转换为 gif,而不是当 GifsActive 为 true 时,当有人勾选该框时。
我试图在类内和类外创建函数并调用它们,但这似乎不起作用,我创建了this.gif = gifs并尝试调用一个函数将其从false设置为true,但它仍然不起作用。
class Queen {
constructor(name, acting, comedy, dance, design, improv, runway, lipsync, image = "noimage", custom = false, guestjudge = false, country = "none", gifs = false) {
this.trackRecord = [];
this.friends = [];
this.enemies = [];
this.sisters = [];
this.miniEpisode = [];
this.tCaptain = [];
this.voteHerstory = [];
this.immuneEp = [];
this.runwayScore = 0;
this.lipsyncScore = 0;
this.performanceScore = 0;
this.finaleScore = 0;
this.favoritism = 0;
this.unfavoritism = 0;
this.ppe = 0;
this.stars = 0;
this.episodesOn = 0;
this.votes = 0;
this.rankP = 0;
this.retEp = 0;
this.blocked = false;
this.QueenDisqOrDept = false;
this.customqueen = false;
this.immune = false;
this.chocolate = false;
this.maxiT = false;
this._name = name;
this._actingStat = acting;
this._comedyStat = comedy;
this._danceStat = dance;
this._designStat = design;
this._improvStat = improv;
this._runwayStat = runway;
this._lipsyncStat = lipsync;
if (image == "noimage")
this.image = "image/queens/noimage.jpg";
else if (custom == true)
this.image = image;
else if (guestjudge == true)
this.image = "image/judges/" + image + ".webp";
else if (gifsActive == true)
this.image = "image/judges/" + image + ".gif";
else
this.image = "image/queens/" + image + ".webp";
if (country == "none")
this.country = "image/country/noimage.jpg";
else if (country == "UK")
this.country = "image/country/UK.png";
else if (country == "USA")
this.country = "image/country/USA.png";
else if (country == "SWEDEN")
this.country = "image/country/SWEDEN.png";
else if (country == "CAN")
this.country = "image/country/CAN.png";
else if (country == "THAI")
this.country = "image/country/THAI.png";
else if (country == "BELGIUM")
this.country = "image/country/BELGIUM.png";
else if (country == "DU")
this.country = "image/country/DU.png";
else if (country == "SPAIN")
this.country = "image/country/SPAIN.png";
else if (country == "FRANCE")
this.country = "image/country/FRANCE.png";
else if (country == "DEN")
this.country = "image/country/DEN.png";
else if (country == "AUS")
this.country = "image/country/AUS.png";
else if (country == "INDIA")
this.country = "image/country/INDIA.png";
else if (country == "BRAZIL")
this.country = "image/country/BRAZIL.png";
else if (country == "ISRAEL")
this.country = "image/country/ISRAEL.png";
else if (country == "PHIL")
this.country = "image/country/PHIL.png";
else if (country == "CHINA")
this.country = "image/country/CHINA.png";
else if (country == "HOL")
this.country = "image/country/HOL.png";
else if (country == "ITALY")
this.country = "image/country/ITALY.png";
else
this.country = "image/queens/" + country + ".png";
}
_calculateScores(min, max, stat = 0) {
let score = randomNumber(min, max);
return score - stat;
}
getName() {
return this._name;
}
getLipSyncStat() {
return this._lipsyncStat;
}
getActing() {
this.performanceScore = this._calculateScores(15, 35, this._actingStat);
}
getComedy() {
this.performanceScore = this._calculateScores(15, 35, this._comedyStat);
}
getMarketing() {
this.performanceScore = this._calculateScores(25, 45, this._comedyStat + this._actingStat);
}
getDance() {
this.performanceScore = this._calculateScores(15, 35, this._danceStat);
}
getDesign() {
this.performanceScore = this._calculateScores(15, 35, this._designStat);
}
getRunwayChallenge() {
this.performanceScore = this._calculateScores(15, 35, this._runwayStat);
}
getImprov() {
this.performanceScore = this._calculateScores(15, 35, this._improvStat);
}
//special 'gets':
getSnatch() {
this.performanceScore = this._calculateScores(25, 45, this._improvStat + this._comedyStat);
}
getRusical() {
this.performanceScore = this._calculateScores(25, 45, this._danceStat + this._lipsyncStat);
}
getBall() {
this.performanceScore = this._calculateScores(25, 45, this._designStat + this._runwayStat);
}
getRumix() {
this.performanceScore = this._calculateScores(25, 45, this._danceStat + this._improvStat);
}
getTalentShow() {
this.performanceScore = this._calculateScores(15, 35, randomNumber(1, 35));
}
getFinale() {
this.finaleScore = this.favoritism - this.unfavoritism;
}
getRunway() {
this.runwayScore = this._calculateScores(12, 35, this._runwayStat);
}
getLipsync() {
this.lipsyncScore = this._calculateScores(0, this._lipsyncStat, this.unfavoritism) + this.favoritism;
}
getASLipsync() {
this.lipsyncScore = this._calculateScores(0, this._lipsyncStat);
}
addToTrackRecord(placement) {
this.trackRecord.push(placement);
}
editTrackRecord(added) {
this.trackRecord[this.trackRecord.length - 1] += added;
}
}
用于将变量变为 true 的按钮
let gifsActive = false;
if (document.getElementById("gifMode").checked == true) {
gifsActive = true;
}
gifMode 在 HTML 中作为复选框,并且拼写正确。
这是我试图更改为 gif 的人
let sashaColby = new Queen("Sasha Colby", 12, 9, 13, 10, 8, 14, 14, "SashaColby", false, false,"USA", false);
第二个字符串“”是作为WEBP的图像,但我在同一个文件夹中还有一个GIF格式的同名,以确保当它切换时,它应该只改变格式。
HTML ---
<input class="optleft" type="checkbox" id="gifMode"> Enable Gifs
任何帮助都是值得赞赏的,我已经尝试了几个小时,但无论我做什么,它都行不通。
答:
1赞
Yosuf
4/18/2023
#1
我更改了图像 src dom 元素以显示 gif 而不是带有 .replaceALL 的 webp,它现在可以工作了!
谢谢你们的帮助!
评论