Commit d77238d0 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

kml template uploading

parent f781af46
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
div{
  padding-bottom: 4px;
}
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -52,11 +52,22 @@ function parse_list(res){

function copy_models(){

  // testing
  $.ajax({
    url: "select.php?cmd=copy",
    success: function(response){
      console.log(response);
    }
  });

  $(".chkbox").each(function(){

    if ($(this).prop("checked")){
      $.ajax({
        url: "select.php?cmd=copy&set="+$(this).attr('set')+"&model="+$(this).attr('model'),
        type:'post',
        data: $('#kml')[0].files[0],
        processData: false,
        success: function(response){
          console.log(response);
        }
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@

  </head>
  <body>
    <div>
      KML template: <input id='kml' type='file' />
    </div>
    <div>
      <button class='copy'>Copy checked to <i>models/</i></button>
    </div>
+8 −1
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ if (isset($_GET['showall'])){

if ($_GET['cmd']=='copy'){

  $kml_template = file_get_contents('php://input');

  $set = $_GET['set'];
  $model = $_GET['model'];

@@ -33,7 +35,12 @@ if ($_GET['cmd']=='copy'){
  $kml = "$base0/$model/$model.kml";

  if (!is_file($kml)){
    file_put_contents($kml,generate_default_kml($model,$ts));
    if ($kml_template==""){
      $kml_data = generate_default_kml($model,$ts);
    }else{
      $kml_data = $kml_template;
    }
    file_put_contents($kml,$kml_data);
  }

  //gen thumbnail