Keldos commited on
Commit
d23e1ca
1 Parent(s): d7b687f

Update assets/custom.js

Browse files
Files changed (1) hide show
  1. assets/custom.js +3 -15
assets/custom.js CHANGED
@@ -16,19 +16,7 @@ var chatbot = null;
16
 
17
  var ga = document.getElementsByTagName("gradio-app");
18
  var targetNode = ga[0];
19
- var isInHuggingFace = false;
20
-
21
- // 您是抱抱脸吗?
22
- function areYouHuggingFace() {
23
- const metaTags = document.getElementsByTagName('meta');
24
- for (var i = 0; i < metaTags.length; i++) {
25
- var tag = metaTags[i];
26
- if (tag.getAttribute('name') === 'twitter:site' && tag.getAttribute('content') === '@huggingface') {
27
- isInHuggingFace = true;
28
- }
29
- break;
30
- }
31
- }
32
 
33
  // gradio 页面加载好了么??? 我能动你的元素了么??
34
  function gradioLoaded(mutations) {
@@ -195,7 +183,7 @@ function setChatbotHeight() {
195
  const wrap = chatbot.querySelector('.wrap');
196
  const vh = window.innerHeight * 0.01;
197
  document.documentElement.style.setProperty('--vh', `${vh}px`);
198
- if (isInHuggingFace) {
199
  chatbot.style.height = `500px`;
200
  wrap.style.maxHeight = `calc(500px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`
201
  } else {
@@ -220,7 +208,7 @@ observer.observe(targetNode, { childList: true, subtree: true });
220
 
221
  // 监视页面变化
222
  window.addEventListener("DOMContentLoaded", function () {
223
- areYouHuggingFace();
224
  });
225
  window.addEventListener('resize', setChatbotHeight);
226
  window.addEventListener('scroll', setChatbotHeight);
 
16
 
17
  var ga = document.getElementsByTagName("gradio-app");
18
  var targetNode = ga[0];
19
+ var isInIframe = (window.self !== window.top);
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  // gradio 页面加载好了么??? 我能动你的元素了么??
22
  function gradioLoaded(mutations) {
 
183
  const wrap = chatbot.querySelector('.wrap');
184
  const vh = window.innerHeight * 0.01;
185
  document.documentElement.style.setProperty('--vh', `${vh}px`);
186
+ if (isInIframe) {
187
  chatbot.style.height = `500px`;
188
  wrap.style.maxHeight = `calc(500px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`
189
  } else {
 
208
 
209
  // 监视页面变化
210
  window.addEventListener("DOMContentLoaded", function () {
211
+ isInIframe = (window.self !== window.top);
212
  });
213
  window.addEventListener('resize', setChatbotHeight);
214
  window.addEventListener('scroll', setChatbotHeight);