Advertisement
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:800px;
- }
- #result{
- margin-top: 20px;
- }
- #buttons{
- width:800px;
- margin:0 auto;
- text-align:center;
- }
- </style>
- <title>Sortowanie po partach</title>
- </head>
- <body>
- <div id="main">
- <textarea id="txt" style="width:800px;height:200px;" placeholder="Podaj linki w tym miejscu"></textarea>
- </div>
- <div id="result">
- <textarea id="txtR" style="width:800px;height:200px;" placeholder="Tu pojawi się wynik"></textarea>
- <div id="buttons">
- <input id="sort" type="button" value="Sortuj po partach"/>
- </div>
- </div>
- <script type="text/javascript">
- var d = document;
- function regx (ab) {
- abT = ab.match(/\.part([\d]+)\./);
- return abT != undefined ? abT[1] : ab;
- }
- d.getElementById("sort").onclick = function() {
- var urls = d.getElementById("txt");
- urls = urls.value.split('\n');
- var newUrls = [];
- for (key in urls) {
- if (urls[key] != '') {
- newUrls.push(urls[key]);
- }
- }
- newUrls.sort(function(a, b) {
- a = regx(a);
- b = regx(b);
- return (a > b) - (a < b);
- });
- var sortedUrls = d.getElementById("txtR");
- sortedUrls.value = '';
- for (var i = 0; i < newUrls.length; i++) {
- sortedUrls.value += newUrls[i];
- if (i < newUrls.length - 1) {
- sortedUrls.value += '\n';
- }
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement