Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
- Fixed translator credits
- Fixed Monokai with Use Accent Color selected not using accent for back button hover (#319)
  • Loading branch information
TCNOco committed Jun 26, 2023
1 parent 2c469a6 commit 38b7814
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
37 changes: 14 additions & 23 deletions TcNo-Acc-Switcher-Server/Pages/General/GeneralInvocableFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
using System.Net.Http;
using System.Reflection;
using System.Runtime.Versioning;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using System.Web;
using Microsoft.JSInterop;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TcNo_Acc_Switcher_Globals;
using TcNo_Acc_Switcher_Server.Data;
Expand Down Expand Up @@ -402,46 +404,35 @@ public static async Task<string> GiExportAccountList(string platform)
[JSInvokable]
public static string GiLocaleObj(string k, object obj) => Lang.Instance[k, obj];

struct crowdinDataObject
{
public SortedDictionary<string, string> ProofReaders { get; set; }
public List<string> Translators { get; set; }
}

[JSInvokable]
public static string GiCrowdinList()
{
try
{
var html = new HttpClient().GetStringAsync(
"https://tcno.co/Projects/AccSwitcher/api/crowdin/").Result;
var persons = html.Split("</li><li>");
List<string> proofreaders = new();
List<string> normal = new();

// Loop once for proofreaders.
// Then again for those who aren't.
foreach (var person in persons)
{
if (person.Contains(" - ")) proofreaders.Add(GiCrowdinPersonHtml(person));
if (!person.Contains(" - ")) normal.Add(GiCrowdinPersonHtml(person));
}
var crowdinData = JsonConvert.DeserializeObject<crowdinDataObject>(html);

var proofreaders = crowdinData.ProofReaders.Select(crowdinDataProofReader => $"<li>{crowdinDataProofReader.Key} ({crowdinDataProofReader.Value})</li>").ToList();
proofreaders.Sort();
normal.Sort();

return string.Join("", proofreaders) + "<li>----------</li>" + string.Join("", normal);
crowdinData.Translators.Sort();
var translatorsString = string.Join("</li><li>", crowdinData.Translators);

return string.Join("", proofreaders) + "<li>----------</li>" + translatorsString;
}
catch (Exception)
{
return "<b>Failed to load Crowdin supporters!</b>";
}
}

private static string GiCrowdinPersonHtml(string person)
{

if (person.StartsWith("<li>"))
return $"{person}</li>";
if (person.EndsWith("</li>"))
return $"<li>{person}";
return $"<li>{person}</li>";
}

[JSInvokable]
public static string GiCurrentBasicPlatform(string platform)
{
Expand Down
2 changes: 1 addition & 1 deletion TcNo-Acc-Switcher-Server/themes/Monokai/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ button#LocateProgramExe,
#modalBtnBack:hover,
#btnRestore:hover,
#btnMax:hover {
background: #fce5668f;
background: var(--accent);
}

.clearingRight {
Expand Down

0 comments on commit 38b7814

Please sign in to comment.