-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
165 lines (157 loc) · 6.3 KB
/
Copy pathscript.js
File metadata and controls
165 lines (157 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
let userName = prompt("Please Enter your name to visit our website? ")
window.onload = function(){
let message ="Have a Good Day"
// // let firstName = prompt("Please Enter Your First Name?")
// // let lastName = prompt("Please Enter Your Last Name?")
// // let fullName = firstName +" "+ lastName
let emoji = ('✨')
document.getElementById("userName").innerHTML = message + " " + userName+ emoji // Emoji tranformation //
}
// -----------------Clear Output ----------------//
document.getElementById('clearOutputButton').onclick = function(){
document.getElementById('output').innerHTML = ""
}
// -----------------Clear Input ----------------//
function clearInput(){
document.getElementById('inputText').value = ""
}
// -----------------Input ----------------//
function inputValue(){
return document.getElementById('inputText').value;
}
// -----------------Round A Number----------------//
function roundANumber(){
let number = document.getElementById('inputText').value;
if (!number){
Toastify({ /// Toastify ///
text: "Please enter a floating point numbers...",
duration: 3000, //milisec m ha duration // 3000 = 3 sec ,,, 4000 = 4 sec
// destination: "https://github.com/apvarun/toastify-js",
// newWindow: true,
close: true,
gravity: "top", // `top` or `bottom`
position: "right", // `left`, `center` or `right`
stopOnFocus: true, // Prevents dismissing of toast on hover
style: {
background: "linear-gradient(to right, #00b09b, #96c93d)",
},
// onClick: function(){} // Callback after click
}).showToast();
}
let roundTheNumber = Math.round(number)
let html = '<h1 class="text-primarytheme mb-0">'+ roundTheNumber + '</h1>'
document.getElementById('output').innerHTML = html
}
// -----------------Ceil A Number----------------//
function ceilANumber(){
let number = document.getElementById('inputText').value;
if (!number){
alert('Please enter a floating point numbers...')
return
}
let ceilTheNumber = Math.ceil(number)
let html = '<h1 class="text-primarytheme mb-0">'+ ceilTheNumber + '</h1>'
document.getElementById('output').innerHTML = html
}
// -----------------Floor A Number----------------//
function floorANumber(){
let number = document.getElementById('inputText').value;
if (!number){
alert('Please enter a floating point numbers...')
return
}
let floorTheNumber = Math.floor(number)
let html = '<h1 class="text-primarytheme mb-0">'+ floorTheNumber + '</h1>'
document.getElementById('output').innerHTML = html
}
// -----------------Generate A Random Number----------------//
function randomNumber(){
let generateNumber = Math.random() //generate 16 17 word digit number
let html = '<h1 class="text-primarytheme mb-0">'+ generateNumber + '</h1>'
document.getElementById('output').innerHTML = html
}
//-----------------------Throw A Dice----------------------//
function Dice(){
let randomNumber = Math.random()
randomNumber = (randomNumber * 6 ) + 1
let dice = Math.floor(randomNumber)
let html = '<h1 class="text-primarytheme mb-0">'+ dice + '</h1><span>Generating a random number from 1 to 6</span>'
document.getElementById('output').innerHTML = html
}
//-----------------------Generate A Strong Password----------------------//
function generateAStrongPassword(){
let length = document.getElementById('inputText').value
let randomString = ""
let upperCaseAlphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
let lowerCaseAlphabets = "abcdefghijklmnopqrstuvwxyz"
let numbers = '0123456789'
let symbols = '`~@#$%^&*-_=+/?.,'
let posssibleString = upperCaseAlphabets + lowerCaseAlphabets + numbers + symbols
// console.log(posssibleString.length)
let limit = length
for (let i = 0;i < limit ; i++){
let randomNumber = Math.random()
//console.log(randomString * 80)
randomString += posssibleString.charAt(Math.floor(randomNumber * posssibleString.length ))
}
let html = '<span class="text-primarytheme mb-0">'+ randomString + '</span><br><span>Generating a Strong password & random string and the length is ' + limit + '.</span>'
document.getElementById('output').innerHTML = html
}
//-----------------------Converting Strings----------------------//
function convertingStrings(){
let num = document.getElementById('inputText').value;
num = Number(num)
num = num.toFixed(2) //function tofixed sirf number datatype pr chalta ha // lakin datatype string hi ho gi
num = Number(num)
if(num == 0){
alert("Enter your string to convert in number!")
} else{
document.getElementById('output').innerHTML = "<div>num = " +num +"</div>"
+ "<div>Datatype is = " + (typeof num) + "</div>"
}
}
//-----------------------Controlling Length----------------------//
function controllingLength(){
let num = inputValue()
if (!num){
alert('Please type something to control the length of string....')
return
}
// console.log(typeof num)
num = Number(num)
let limit = prompt("Please enter the limit for decimal number...")
if(limit == 0 || limit == null){
alert("Enter your limit please...")
return
}
num = num.toFixed(limit);
// num = num.toFixed(2);
num = Number(num);
if (num == 0) {
alert("Enter your string to convert in number!");
} else {
document.getElementById("output").innerHTML =
"<div>num = " +
num +
"</div>" +
"<div>Datatype is = " +
typeof num +
"</div>";
}
}
//------------------------Calculate GST------------------------//
function calculateGST(){
let cost = inputValue()
if (!cost){
alert('Please type something to calculate')
return
}
cost = Number(cost)
let textInput = +prompt('Enter your tax')
let tax = cost * (textInput / 100)
let totalCost = cost + tax
totalCost = Math.round(totalCost)
document.getElementById('output').innerHTML = 'Your bill = <span class=" text-primaryTheme fw-bold fw-18">' + cost + '</span>'
document.getElementById('output').innerHTML += '<br> Tax' + textInput + '% = <span class="text-danger fw-bold fw-18" >' + tax.toFixed(2) + '</span>'
document.getElementById('output').innerHTML += '<br> Total amount icluding tax = <span class=" text-success fw-bold fw-18">' + totalCost + '</span>'
}