freealise commited on
Commit
6c76b19
1 Parent(s): 9730921

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -360,16 +360,20 @@ with gr.Blocks(css=css) as demo:
360
  }
361
  document.getElementById(\"pl\").setAttribute(\"points\", pts);
362
  this.onpointermove = function(event) {
363
- var x = event.clientX - event.target.getBoundingClientRect().x;
364
- var y = event.clientY - event.target.getBoundingClientRect().y;
365
- var pl_a = document.getElementById(\"pl\").getAttribute(\"points\").split(\" \");
366
- pl_a[x] = x+\",\"+y;
367
- document.getElementById(\"pl\").setAttribute(\"points\", pl_a.join(\" \"));
 
 
368
  }
369
  this.onpointerup = function(event) {
370
- document.getElementsByTagName(\"input[type=text]\")[1].value = document.getElementById(\"pl\").getAttribute(\"points\");
 
371
  }
372
  }
 
373
  }catch(e){alert(e);}
374
  '>
375
  <defs>
 
360
  }
361
  document.getElementById(\"pl\").setAttribute(\"points\", pts);
362
  this.onpointermove = function(event) {
363
+ if (this.style.borderBottom == \"1px dotted white\") {
364
+ var x = event.clientX - event.target.getBoundingClientRect().x;
365
+ var y = event.clientY - event.target.getBoundingClientRect().y;
366
+ var pl_a = document.getElementById(\"pl\").getAttribute(\"points\").split(\" \");
367
+ pl_a[x] = x+\",\"+y;
368
+ document.getElementById(\"pl\").setAttribute(\"points\", pl_a.join(\" \"));
369
+ }
370
  }
371
  this.onpointerup = function(event) {
372
+ document.getElementsByTagName(\"textarea\")[1].value = document.getElementById(\"pl\").getAttribute(\"points\").replace(/\d+,/g, \"\");
373
+ this.style.borderBottom = \"1px dotted black\";
374
  }
375
  }
376
+ this.style.borderBottom = \"1px dotted white\";
377
  }catch(e){alert(e);}
378
  '>
379
  <defs>