File size: 6,102 Bytes
657d0c9
 
 
 
 
 
 
 
 
352d580
 
 
 
 
 
 
 
657d0c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3656b60
 
657d0c9
 
 
 
 
 
 
 
 
 
fb82e89
657d0c9
b15512c
657d0c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b15512c
 
9901832
7fe9c56
 
 
 
 
3656b60
 
 
7fe9c56
 
 
657d0c9
3656b60
 
 
b07b28d
3656b60
34225fe
7dc2088
b15512c
 
352d580
657d0c9
 
 
 
 
 
 
 
b0b3e56
657d0c9
 
34225fe
657d0c9
34225fe
657d0c9
 
 
 
34225fe
 
 
 
 
 
 
 
 
 
 
 
657d0c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855180d
 
 
657d0c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3656b60
 
657d0c9
 
 
 
 
34225fe
 
657d0c9
98d07bf
657d0c9
 
481579f
96403b2
 
 
657d0c9
643fd58
 
 
657d0c9
352d580
657d0c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
document.getElementById('jd').onclick = ()=>{
    window.open('https://discord.gg/ju4yQBfQ7p')
  }
  
 
  
  /*document.getElementById('ow').onclick = ()=>{
    window.open('https://www.buymeacoffee.com/mygx')
  }*/
  let isimg = false
if(isimg == true){
  img = document.getElementById('hehe')
img.addEventListener("click", function() {
    var imageUrl = this.src;
    window.open(imageUrl, "_blank");
});
}
  let dialog = document.getElementById('dialog')
  let openbtn = document.getElementById('Advance Setting')
  let closebtn = document.getElementById('close')
  openbtn.onclick = ()=>{
    dialog.show()
    document.getElementById('imshow').style.border = '0px solid black transparent'
  }
  closebtn.onclick= ()=>{
    dialog.close()
    document.getElementById('imshow').style.background = 'linear-gradient(black, black) padding-box,linear-gradient(to right, red, blue) border-box' 
  }
  let inp = document.getElementById('inp')
  let np = document.getElementById('np')
  let gd = document.getElementById('gds')
  let step = document.getElementById('step')
  let seed = document.getElementById('seed')
  let seedp = document.getElementById('seedp')
  let stepp = document.getElementById('stepp')
  let gdsp = document.getElementById('gdsp')
  let btn = document.getElementById('create') 
let cn = false
  gd.addEventListener('input',()=>{
   gdsp.innerText = gd.value
  })
  step.addEventListener('input',()=>{
   stepp.innerText = step.value
  })
  seed.addEventListener('input',()=>{
   seedp.innerText = seed.value
  })
  isFumes = true
  let prompt = 'CINEMATIC'
  let nps = ' ,(bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3),poorly drawn,deformed hands,deformed fingers,deformed faces,deformed eyes,mutated fingers,deformedbody parts,mutated body parts,mutated hands, disfigured,oversaturated,bad anatom,cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, deformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck,deformed eyes'
let reload = false
  
  document.getElementById('styles').onchange = ()=>{
    const selectedStyle = document.querySelector('input[name="style"]:checked');
    if(selectedStyle.value =='photo'){
      
      prompt = 'PHOTOGRAPHY'
    
    
    }
    if(selectedStyle.value == 'cinema'){
    
      prompt = "CINEMATIC"}
    if(selectedStyle.value == 'fantasy'){
   
      prompt = "CREATIVE"
    }

    if(selectedStyle.value == 'fumes'){
    
       prompt = 'FILM'
}
    if(selectedStyle.value == 'no'){
      prompt = 'LEONARDO'
     
    }
  }
setTimeout(()=>{
  reload = true
},2000000)











  btn.onclick = async ()=>{ 
    if(cn==true){
  window.location.reload()
}
btn.innerText = "CANCEL"
    cn = true
let div = document.getElementById('imshow');
    if(reload==true){
      window.location.reload();
    }
    isimg = false
    let isc = false
    let id = ''


  

  
  negative_prompt = nps
 // btn.disabled = true
  div.innerHTML = '';
  document.getElementById('imshow').innerHTML = ''
  let pi = document.createElement('h5')
  pi.innerText = 'Generating Image... Estimated Time: 20s'
 // document.getElementById('imshow').append(pi)
  let count = 0;
  seed = seed




let progress = document.createElement('progress');
progress.value = 1;
progress.max = 100;

div.appendChild(progress);
setInterval(()=>{
progress.value+=3},1100)

    

    async function generate(){
    cookie = localStorage.getItem("cookie")
    u = localStorage.getItem("u")
    sub = localStorage.getItem("sub")
    if(cookie == null){
        cookie = ''
    }
    if(cookie == "undefined"){
        cookie = ''
    }
      params={
      
      'prompt': inp.value,
      'nprompt': np.value,
      "steps": step.value,
      'gd': gd.value,
      "style": prompt,
      "width": 1024,
   "height":1024,
   "alchemy":true,
   "pr":true
        
   
  };

   
       try {
           const response = await fetch('https://l-d83c.onrender.com/leonardo', {
               method: 'POST',
               headers: {
                   'Content-Type': 'application/json',
                   'Connection': 'keep-alive',
               },
               body: JSON.stringify(params)
           });
           if (response.status ===  429) {
             pi.innerText = 'you have reached your limit of 50 generation per hour, you will get 50 more image generaions after an hour!!'
           }
       /*    console.log(np.value)
           const imgData = await response.text(); 
           const div = document.getElementById('imshow')
           const img = document.createElement('img');
           pi.innerHTML = ''
           pi.innerText = ''
           img.src = imgData;
           div.appendChild(img);
           */
           cn = false
         btn.innerText = "CREATE" 
           const data = await response.json(); 
           localStorage.setItem("cookie", data.token);
           localStorage.setItem("sub", data.sub);
           localStorage.setItem("u", data.u);
           console.log(data.result)
         progress.innerHTML = ''
         progress.style.display = 'none';
           const img = document.createElement('img');
           img.id = "hehe"
           pi.innerHTML = ''
           pi.innerText = ''
           img.src = data.result[2];
         if(window.innerWidth<600){
           img.id = "i1"
         }
           div.appendChild(img);
          const img2 = document.createElement('img');
          img2.src = data.result[1];
           div.appendChild(img2);
           btn.disabled = false
           isimg = true
           
       } catch (error) {
         btn.disabled = false
           console.error('An error occurred:', error);
           pi.innerText = 'An error occurred, try changing your prompt';
       }
   
   
   }
   
   await Promise.all([generate()]);
   

 
  
}