Skip to content

Commit

Permalink
Update to 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
NidukaAkalanka authored Nov 20, 2022
1 parent b41ac34 commit 08d30a4
Show file tree
Hide file tree
Showing 56 changed files with 3,005 additions and 1,656 deletions.
79 changes: 79 additions & 0 deletions web/assets/js/langs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
supportLangs = [
{
name : "English",
value : "en-US",
icon : "🇺🇸"
},
{
name : "Perisan",
value : "pr",
icon : "pr"
},
]

function getLang(){
let lang = getCookie('lang')

if (! lang){
if (window.navigator){
lang = window.navigator.language || window.navigator.userLanguage;

if (isSupportLang(lang)){
setCookie('lang' , lang , 150)
}else{
setCookie('lang' , 'en-US' , 150)
window.location.reload();
}
}else{
setCookie('lang' , 'en-US' , 150)
window.location.reload();
}
}

return lang;
}

function setLang(lang){

if (!isSupportLang(lang)){
lang = 'en-US';
}

setCookie('lang' , lang , 150)
window.location.reload();
}

function isSupportLang(lang){
for (l of supportLangs){
if (l.value === lang){
return true;
}
}

return false;
}



function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
4 changes: 3 additions & 1 deletion web/assets/js/model/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DBInbound {
this.streamSettings = "";
this.tag = "";
this.sniffing = "";

this.clientStats = ""
if (data == null) {
return;
}
Expand Down Expand Up @@ -125,6 +125,7 @@ class DBInbound {
if (!ObjectUtil.isEmpty(this.sniffing)) {
sniffing = JSON.parse(this.sniffing);
}

const config = {
port: this.port,
listen: this.listen,
Expand All @@ -133,6 +134,7 @@ class DBInbound {
streamSettings: streamSettings,
tag: this.tag,
sniffing: sniffing,
clientStats: this.clientStats,
};
return Inbound.fromJson(config);
}
Expand Down
Loading

0 comments on commit 08d30a4

Please sign in to comment.