< >

unwetterwarnumgen-options-liste-mit-cors.php


Quell Code


 <style>
   body {
  background: grey;
}

#out{
  position:absolute:
    left:-1111px;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div id="out"></div>
<select id="sec" name="select">
</select>
<div id="info"></div>

<script>
//  var  url ="https://plugins.jquery.com/tag/ui/page/2/";
(function() {
    var cors_api_host = 'cors-anywhere.herokuapp.com';
    var cors_api_url = 'https://' + cors_api_host + '/';
    var slice = [].slice;
    var origin = window.location.protocol + '//' + window.location.host;
    var open = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function() {
        var args = slice.call(arguments);
        var targetOrigin = /^https?:\/\/([^\/]+)/i.exec(args[1]);
        if (targetOrigin && targetOrigin[0].toLowerCase() !== origin &&
            targetOrigin[1] !== cors_api_host) {
            args[1] = cors_api_url + args[1];
        }
        return open.apply(this, args);
    };
        $.ajax({
  url: url,
  cache: false
})
  .done(function( html ) {
   // $( "body" ).html( html );
  });
})();
</script>

<script>

     $.ajax({
        type: "GET",
        url: "http://www.wettergefahren.de/DWD/warnungen/warnapp/warnings.html",
        success: function(data){
        var code=data;
        los(data);

function los(code){
 var stadt=[];
   sel=document.getElementById('sec');   
 var sammeln='';
//code=$('textarea').text();
 last=code.split('strong>')[1].split('<')[0];
      
landkreis=code.split('<h2');
        
landkreismenge=landkreis.length;
console.log(landkreismenge);
 for(d=1;d<landkreismenge;d++){
    landkreisname=code.split('<h2')[d].split('h2')[0].split('>')[1].split('<')[0];
  landkreisname=landkreisname.replace('Kreis ','');
   landkreisname=landkreisname.replace('und ','');  
   landkreisname=landkreisname.replace('Stadt ','');  
   
   stadt.push(landkreisname);
 } 
  stadt.sort();
  for(k=0;k<stadt.length;k++){
   sammeln+='<option value="'+stadt[k]+'">'+stadt[k]+'</option>';
  
  }
sel.innerHTML=sammeln;  
sel.addEventListener('change',function(e){
  console.log(this.value)
 
  text1=code.split(''+this.value+'">')[1];
 
  text=text1.split('</table>')[0];
 $('#info').html(text)
})    
          
       }
           }
          
       });

</script>