PageSourceSearch

https://suyo.be/games/catno/js/states/result.js

js suyo.be collected 2026-10-03 20:27:48 UTC 9,007 bytes, 203 lines download raw bytes

1let nameinput = "";
2
3var state_result = {
4    init: function (s, t) {
5        this.keys = undefined;
6
7        this.nameinputtext = undefined;
8        this.initialenter = undefined;
9        this.initiallabel = undefined;
10        this.initialskip = false;
11        this.borders = undefined;
12        this.pcimage = undefined;
13        this.screenlight = undefined;
14
15        this.score = s;
16        this.time = t;
17        this.starttime = undefined;
18
19        this.submittingA = undefined;
20        this.submittingB = undefined;
21    },
22    create: function () {
23        game.input.keyboard.addCallbacks(this, this.nameInputHandler);
24
25        this.borders = game.add.graphics(560, 200);
26        this.borders.beginFill(0x000000);
27        this.borders.drawRect(0, 0, 270, 450);
28        this.borders.drawRect(530, 0, 270, 450);
29        this.borders.beginFill(0xFFFFFF);
30        this.borders.drawRect(270, 0, 5, 450);
31        this.borders.drawRect(525, 0, 5, 450);
32        this.borders.generateTexture();
33
34        let scorelabel = game.add.bitmapText(960, 250, "carrier_command", "YOU SCORED", 15);
35        scorelabel.x -= scorelabel.width / 2;
36        scorelabel.alpha = 0.75;
37        let scorevalue = game.add.bitmapText(960, 270, "carrier_command", "" + this.score, 20);
38        scorevalue.x -= scorevalue.width / 2;
39
40        if (this.score === 0) {
41            this.startSubmit();
42        } else {
43            this.initiallabel = game.add.bitmapText(960, 350, "carrier_command", "ENTER NAME", 15);
44            this.initiallabel.x -= this.initiallabel.width / 2;
45
46            this.nameinputtext = game.add.bitmapText(960, 400, "carrier_command", nameinput.padEnd(3, "_"), 45);
47            this.nameinputtext.x -= this.nameinputtext.width / 2;
48
49            this.initialenter = game.add.bitmapText(960, 500, "carrier_command", "PRESS ENTER\n\nTO CONFIRM", 15);
50            this.initialenter.align = "center";
51            this.initialenter.x -= this.initialenter.width / 2;
52            this.initialenter.alpha = 0.75;
53        }
54
55        this.pcimage = game.add.sprite(0, 0, 'pc');
56        this.pcimage.fixedToCamera = true;
57
58        this.screenlight = game.add.sprite(0, 0, 'screenlight');
59        this.screenlight.fixedToCamera = true;
60        this.screenlight.alpha = 0.2;
61    },
62    startSubmit: function () {
63        if (nameinput.length === 0) this.submitScore("AAA", 0);
64        else this.submitScore(nameinput, this.score);
65        game.input.keyboard.removeCallbacks();
66
67        this.keys = game.input.keyboard.addKeys({
68            "return": Phaser.KeyCode.SPACEBAR
69        });
70        this.starttime = game.time.now;
71
72        if (this.score !== 0) {
73            this.initiallabel.kill();
74            this.nameinputtext.kill();
75            this.initialenter.kill();
76        }
77
78        let catstring = Math.random();
79        if (catstring < 0.33) catstring = "AND WERE\n\nBLESSED BY\n\nTHE PRESENCE\n\nOF CAT FOR";
80        else if (catstring < 0.66) catstring = "AND HAVE\n\nENJOYED THE\n\nCOMPANIONSHIP\n\nOF CAT FOR";
81        else catstring = "AND GOT\n\nTO WITNESS\n\nTHE BEAUTY\n\nOF CAT FOR";
82
83        let timelabel = game.add.bitmapText(960, 350, "carrier_command", catstring, 15);
84        timelabel.align = "center";
85        timelabel.x -= timelabel.width / 2;
86        timelabel.alpha = 0.75;
87
88        let sec = Math.floor(this.time / 1000);
89        let min = Math.floor(sec / 60);
90        sec = sec % 60;
91
92        let timevalue = game.add.bitmapText(960, 460, "carrier_command", min + " MINUTE" + (min === 1 ? "" : "S") + "\nAND\n" + sec + " SECOND" + (sec === 1 ? "" : "S"), 20);
93        timevalue.align = "center";
94        timevalue.x -= timevalue.width / 2;
95
96        let returnlabel = game.add.bitmapText(960, 580, "carrier_command", "PRESS SPACE", 15);
97        returnlabel.x -= returnlabel.width / 2;
98        returnlabel.alpha = 0.75;
99
100        let topheader = game.add.bitmapText(695, 240, "carrier_command", "TOP SCORES", 20);
101        topheader.x -= topheader.width / 2;
102        this.submittingA = game.add.bitmapText(695, 300, "carrier_command", "SUBMITTING...", 10);
103        this.submittingA.x -= this.submittingA.width / 2;
104        this.submittingA.alpha = 0.75;
105
106        let nearheader = game.add.bitmapText(1225, 240, "carrier_command", "NEAR YOU", 20);
107        nearheader.x -= nearheader.width / 2;
108        this.submittingB = game.add.bitmapText(1225, 300, "carrier_command", "SUBMITTING...", 10);
109        this.submittingB.x -= this.submittingB.width / 2;
110        this.submittingB.alpha = 0.75;
111    },
112    update: function () {
113        if (this.starttime !== undefined && this.keys.return.justReleased() && this.starttime < game.time.now - 100) {
114            game.state.start('title');
115        }
116
117        if (flicker) {
118            this.screenlight.alpha = 0.2 + Math.random() / 16;
119        }
120    },
121    submitScore: function (name, score) {
122        /*
123        * Hi! If you're reading this, you're probably trying to find out how to spoof scores or something. Yeah, there's
124        * no score verification at all. Didn't have an idea how to do that, and I've got better uses of my time during
125        * a 48h jam, so technically you could just call this method with anything you want and it would add it to the
126        * highscore table. But uh... be cool? Not like it really does anything except create work for me? Thanks for
127        * reading this far though! If you have a good idea for score verification let me know!
128        * (btw: while there's no verification for score, the client-side checks for the user input below are also done
129        * on the server side, of course. I'm not dumb. Just short on time.)
130        * */
131        name = name.replace(/[^0-9A-Z]/g, '').substring(0, 3).padEnd(3, " ");
132        score = Number(score);
133
134        let xmlhttp = new XMLHttpRequest();
135        let thisref = this;
136
137        xmlhttp.open("POST", "/games/catno/score.php", true);
138        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
139        xmlhttp.onreadystatechange = function () {
140            if (this.readyState === 4) {
141                if (this.status === 200) thisref.showSubmitResult(JSON.parse(this.responseText));
142                else thisref.submittingA.text = thisref.submittingB.text = "ERROR.";
143            }
144        };
145        xmlhttp.send("name=" + name + "&score=" + score);
146    },
147    showSubmitResult: function (json) {
148        if (json.error) {
149            this.submittingA.text = this.submittingB.text = "ERROR.";
150            return;
151        }
152
153        this.submittingA.kill();
154        this.submittingB.kill();
155
156        let markedtop = false;
157        let markednear = false;
158        for (let i = 0; i < 5; i++) {
159            let top = game.add.bitmapText(580, 300 + i * 60, "carrier_command", (json.top[i].rank + ")").padEnd(10, " ") + json.top[i].name, 15);
160            if (!markedtop && json.top[i].score === this.score) {
161                markedtop = true;
162                top.tint = 0xFF0000;
163            }
164            let near = game.add.bitmapText(1110, 300 + i * 60, "carrier_command", (json.near[i].rank + ")").padEnd(10, " ") + json.near[i].name, 15);
165            if (!markednear && json.near[i].score === this.score) {
166                markednear = true;
167                near.tint = 0xFF0000;
168            }
169            top = game.add.bitmapText(800, 325 + i * 60, "carrier_command", ("" + json.top[i].score).padStart(13, "."), 15);
170            top.x -= top.width;
171            top.alpha = 0.75;
172            near = game.add.bitmapText(1330, 325 + i * 60, "carrier_command", ("" + json.near[i].score).padStart(13, "."), 15);
173            near.x -= near.width;
174            near.alpha = 0.75;
175        }
176    },
177    nameInputHandler: function (e) {
178        if (e.keyCode === 13 && nameinput.length === 0) {
179            if (this.initialskip) {
180                this.startSubmit();
181            } else {
182                this.initialenter.text = "PRESS ENTER\n\nAGAIN TO SKIP";
183                this.initialenter.x = 960 - this.initialenter.width / 2;
184                this.initialskip = true;
185            }
186        } else {
187            if (this.initialskip) {
188                this.initialenter.text = "PRESS ENTER\n\nTO CONFIRM";
189                this.initialenter.x = 960 - this.initialenter.width / 2;
190                this.initialskip = false;
191            }
192
193            if (((e.keyCode >= 65 && e.keyCode <= 90) || (e.keyCode >= 48 && e.keyCode <= 57)) && nameinput.length < 3) {
194                nameinput += e.key.toUpperCase();
195            } else if (e.keyCode === 8 && nameinput.length > 0) {
196                nameinput = nameinput.slice(0, -1);
197            } else if (e.keyCode === 13 && nameinput.length > 0) {
198                this.startSubmit();
199            }
200        }
201        this.nameinputtext.text = nameinput.padEnd(3, "_");
202    }
203};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.