Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <style type="text/css">
- #main,#result{
- margin:0 auto;
- width:500px;
- }
- #result{
- margin-top: 20px;
- }
- #buttons{
- width:500px;
- margin:0 auto;
- text-align:center;
- }
- </style>
- <title>Pomocniczek okienny</title>
- </head>
- <body>
- <div id="main">
- <textarea id="txt" style="width:500px;height:200px;""></textarea>
- <div id="buttons">
- <input id="zP" type="button" value="Zaznacz pole"/>
- <input id="bR" type="button" value="Ogarnij liczby"/>
- <input id="wierszCen" type="button" value="Dodaj wiersz cen"/>
- <select id="coKonkretnie">
- <option value="">Co to jest?</option>
- <option value="0">Cena</option>
- <option value="1">Szerokość</option>
- <option value="2">Wysokość</option>
- </select>
- </div>
- </div>
- <div id="result">
- <textarea id="txtR" style="width:500px;height:200px;""></textarea>
- <div id="buttons">
- <input id="cP" type="button" value="Czyść pole"/>
- </div>
- </div>
- <script type="text/javascript">
- var d = document;
- var sch = "";
- function ogarnijLiczby(){
- var ele = d.getElementById('txt');
- var wartosc = ele.value;
- if(wartosc == '' || (wartosc == sch && sch != '')){
- alert('Nie wprowadziłeś nowych danych!');
- return false;
- }
- var selectW = d.getElementById('coKonkretnie');
- if(selectW.value == ''){
- alert('Ale co tam wkleiłeś?');
- return false;
- }
- wartosc = wartosc.replace(/\n/g,' ');
- var przerabiane = '';
- przerabiane = wartosc;
- switch(parseInt(selectW.value)){
- case 0:{
- przerabiane = przerabiane.replace(/ /g,';');
- przerabiane += ';~';
- break;}
- case 1:{
- var pojedyncze = przerabiane.split(' ');
- var pary = '';
- var ktZKolei = 0;
- for(var i = 0; i < pojedyncze.length ; i++){
- ktZKolei++;
- if(ktZKolei % 2 == 1) pary += pojedyncze[i]+'-';
- else pary += pojedyncze[i]+';';
- }
- przerabiane = pary;
- break;}
- case 2:{
- przerabiane = przerabiane.replace(/ - /g,'-');
- przerabiane = przerabiane.replace(/ /g,';');
- przerabiane += ';';
- break;}
- }
- ele.value = przerabiane;
- sch = ele.value;
- }
- var buttonLiczby = d.getElementById('bR');
- buttonLiczby.onclick = ogarnijLiczby;
- dodajWiersz = d.getElementById('wierszCen');
- var txt = d.getElementById('txt');
- var zaznaczPole = d.getElementById('zP');
- zaznaczPole.onclick = function(){
- txt.select();
- }
- var txtR = d.getElementById('txtR');
- dodajWiersz.onclick = function(){
- if(txtR.value.indexOf(txt.value) == -1){
- txtR.value += txt.value;
- txt.value = '';
- }
- else if(txtR.value != '') alert('Już to dodałeś!');
- }
- txtR.onclick = function(){
- this.select();
- }
- var czyscPoleZb = d.getElementById('cP');
- czyscPoleZb.onclick = function(){
- txtR.value = '';
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment