-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from amaan-ahmad/download_code
- Loading branch information
Showing
2 changed files
with
174 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,66 @@ | ||
export const generateRoomId = () => { | ||
var tempId = ""; | ||
var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | ||
var charactersLength = characters.length; | ||
for (var i = 0; i < 12; i++) { | ||
tempId += characters.charAt(Math.floor(Math.random() * charactersLength)); | ||
if ((i + 1) % 4 === 0 && i !== 11) { | ||
tempId += "-"; | ||
} | ||
var tempId = ""; | ||
var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | ||
var charactersLength = characters.length; | ||
for (var i = 0; i < 12; i++) { | ||
tempId += characters.charAt(Math.floor(Math.random() * charactersLength)); | ||
if ((i + 1) % 4 === 0 && i !== 11) { | ||
tempId += "-"; | ||
} | ||
return tempId; | ||
} | ||
} | ||
return tempId; | ||
}; | ||
|
||
export const validateRoomID = (roomId) => { | ||
var patt = new RegExp("(([A-Za-z]{4})(-)){2}[A-Za-z]{4}"); | ||
return patt.test(roomId.trim()) && roomId.length == 14; | ||
}; | ||
|
||
var patt = new RegExp("(([A-Za-z]{4})(-)){2}[A-Za-z]{4}"); | ||
return patt.test(roomId.trim()) && roomId.length == 14; | ||
|
||
} | ||
export const getExtensionByLangCode = (langCode) => { | ||
switch (langCode) { | ||
case "C++": | ||
return "cpp"; | ||
case "C": | ||
return "c"; | ||
case "JAVA": | ||
return "java"; | ||
case "Python": | ||
return "py"; | ||
case "JavaScript": | ||
return "js"; | ||
case "TypeScript": | ||
return "ts"; | ||
case "Clojure": | ||
return "clj"; | ||
case "C#": | ||
return "cs"; | ||
case "COBOL": | ||
return "cbl"; | ||
case "COBOL": | ||
return "cob"; | ||
case "Erlang": | ||
return "erl"; | ||
case "Go": | ||
return "go"; | ||
case "Python": | ||
return "py"; | ||
case "FortRan": | ||
return "f90"; | ||
case "Groovy": | ||
return "groovy"; | ||
case "Kotlin": | ||
return "kt"; | ||
case "PHP": | ||
return "php"; | ||
case "R": | ||
return "r"; | ||
case "Ruby": | ||
return "rb"; | ||
case "SQL": | ||
return "sql"; | ||
case "Swift": | ||
return "swift"; | ||
default: | ||
return "txt"; | ||
} | ||
}; |
57b5343
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: