|
1 |
| -<!DOCTYPE html> |
2 | 1 | <html>
|
3 | 2 | <head>
|
4 | 3 | <title>Banned | Coding Hut</title>
|
@@ -36,34 +35,36 @@ <h1>Banned From Coding Hut</h1>
|
36 | 35 |
|
37 | 36 | <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
|
38 | 37 | <script type="text/javascript">
|
39 |
| - function getParameterByName(name, url) { |
40 |
| - if (!url) url = window.location.href; |
41 |
| - name = name.replace(/[\[\]]/g, "\\$&"); |
42 |
| - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), |
43 |
| - results = regex.exec(url); |
44 |
| - if (!results) return null; |
45 |
| - if (!results[2]) return ''; |
46 |
| - return decodeURIComponent(results[2].replace(/\+/g, " ")); |
47 |
| - } |
48 |
| - |
49 |
| - $(document).ready(function() { |
50 |
| - var username = getParameterByName('username'); |
51 |
| - const username = localStorage.getItem('username') |
52 |
| - |
53 |
| - $.getJSON('bannedusers.json', function(data) { |
54 |
| - var bannedUsers = data.bannedusers; |
55 |
| - var foundUser = bannedUsers.find(user => user.username === username); |
56 |
| - |
57 |
| - if (foundUser) { |
58 |
| - var reason = foundUser.reason.toLowerCase(); |
59 |
| - if (reason && $("#" + reason).length) { |
60 |
| - $("#" + reason).show(); |
61 |
| - } else { |
62 |
| - $('#default-content').show(); |
63 |
| - } |
64 |
| - } else { |
65 |
| - $('#default-content').show(); |
66 |
| - } |
67 |
| - }); |
68 |
| - }); |
| 38 | + // Parse the URL parameter |
| 39 | + function getParameterByName(name, url) { |
| 40 | + if (!url) url = window.location.href; |
| 41 | + name = name.replace(/[\[\]]/g, "\\$&"); |
| 42 | + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), |
| 43 | + results = regex.exec(url); |
| 44 | + if (!results) return null; |
| 45 | + if (!results[2]) return ''; |
| 46 | + return decodeURIComponent(results[2].replace(/\+/g, " ")); |
| 47 | + } |
| 48 | + // Give the parameter a variable name |
| 49 | + var dynamicContent = getParameterByName('reason'); |
| 50 | + |
| 51 | + $(document).ready(function() { |
| 52 | + |
| 53 | + // Check if the URL parameter is apples |
| 54 | + if (dynamicContent == 'spam') { |
| 55 | + $('#spam').show(); |
| 56 | + } |
| 57 | + // Check if the URL parameter is oranges |
| 58 | + else if (dynamicContent == 'rude') { |
| 59 | + $('#rude').show(); |
| 60 | + } |
| 61 | + // Check if the URL parameter is bananas |
| 62 | + else if (dynamicContent == 'nosnip') { |
| 63 | + $('#nosnip').show(); |
| 64 | + } |
| 65 | + // Check if the URL parmeter is empty or not defined, display default content |
| 66 | + else { |
| 67 | + $('#default-content').show(); |
| 68 | + } |
| 69 | + }); |
69 | 70 | </script>
|
0 commit comments