Jump to content

Web Form Javascript Tweaks


thesys

Recommended Posts

I have a simple form with "input" and then generates an "output" based on a text template that is inline on my code. I want to make some changes to simplify my amount of work. Here is the basic code I have right now.

 

<!DOCTYPE html>
<html>
 <head>
   <title>file reps</title>


</head>
<body style="zoom: 1.5"> <center>
<input type="file" onchange='readText(this)' /> <br />


<textarea rows=10 cols=84 id="txtReps">123456, 123000</textarea> <br />
 <button onclick="rip()">run script</button>
 <button onclick="output.value=output.defaultValue;">reset</button>
<br />


<textarea rows=10 cols=84 id="output">http://www.mysite.com/file/folder/blah/xxxxxx/_something_else here/zzzzzz/image250  
http://www.mysite.com/file/folder/blah/xxxxxx/_something_else here/zzzzzz/image500  
http://www.mysite.com/file/folder/blah/xxxxxx/_something_else here/zzzzzz/image800  
http://www.mysite.com/file/folder/blah/xxxxxx/_something_else here/zzzzzz/image1000  </textarea>



   <script type="text/javascript">


 var reader = new FileReader();


 function rip(e) {  
  var out=(e && e.target && e.target.result) || output.value ;
  var reps=txtReps.value.split(/\s*,\s*/);

  output.value= out.split("\n").map(function(a){
   return a .split("xxxxxx").join(reps[0])
  .split("zzzzzz").join(reps[1]);
  }).join("\n");
 }



 function readText(that){


  if(that.files && that.files[0]){
   var reader = new FileReader();
   reader.onload = rip;
   reader.readAsText(that.files[0]);
  }//end if html5 filelist support
 } 


</script>


</center>  </body>
</html>

 

What it does right now: I put in a number, number i.e. "123456, 123000" in the input area. The form then replaces my generic place holders on my text template "123456=xxxxxx, 123000=zzzzzz".

 

What I want it to do: Just put the "123456" in the input box and have the Javascript split the number up and automatically replace the last 3 numbers with "000" to make the "123000", then also allow me to put multiple numbers separated by commas in the input box and generate multiple filled in templates in my output box. See image below for example. I hope this make sense.

 

 

25ezgif.jpg

Link to comment
Share on other sites

<!DOCTYPE html>
<html>
 <head>
   <title>file reps</title>

     <script type="text/javascript">
       var reader = new FileReader();
       function rip(e)
       {
          var out=(e && e.target && e.target.result) || output.value ;
          var reps=txtReps.value.split(/\s*,\s*/);

          output.value= out.split("\n").map(function(a){
               return a .split("xxxxxx").join(reps[0])
                 .split("zzzzzz").join(reps[1]);
          }).join("\n");
       }

       function readText(that)
       {
          if(that.files && that.files[0]){
               var reader = new FileReader();
               reader.onload = rip;
               reader.readAsText(that.files[0]);
          }//end if html5 filelist support
       }

       String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};

       var urls = new Array();
       urls[0] = "http://www.mysite.com/file/folder/blah/[xxxxxx]/_something_else here/[yyyyyy]/image250";
       urls[1] = "http://www.mysite.com/file/folder/blah/[xxxxxx]/_something_else here/[yyyyyy]/image500";
       urls[2] = "http://www.mysite.com/file/folder/blah/[xxxxxx]/_something_else here/[yyyyyy]/image800";
       urls[3] = "http://www.mysite.com/file/folder/blah/[xxxxxx]/_something_else here/[yyyyyy]/image1000";

       function updateURLs(numbers)
       {
           var output = '';
      	 var numAry = numbers.split(',');
           var numLen = numAry.length
           var urlLen = urls.length;
           for(var i=0; i<numLen; i++)
           {
               var num = numAry[i].replace(/^\s+|[^\d]*|\s+$/g, '');
               if(num.length != 6)
               {
              	 //Error condition, don't use. Add error handling
               }
               else
               {
                   //add number replacement to each URL
                   for(j=0; j<urlLen; j++)
                   {
                  	 url = urls[j].replace("[xxxxxx]", num);
                       url = url.replace("[yyyyyy]", num.substr(0, 3)+'000');
                       output += url + '\n';
                   }
                   //Add line break between each section
                   output += '\n';
               }
           }
           document.getElementById('output').value = output;
       }
</script>

</head>

<body style="zoom: 1.5"> <center>
 <input type="file" onchange='readText(this)' /><br />
 <textarea rows=10 cols=84 id="txtReps" onblur="updateURLs(this.value);">123456, 123000</textarea><br />
 <button onclick="rip()">run script</button>
 <button onclick="output.value=output.defaultValue;">reset</button><br />
 <textarea rows=10 cols=84 id="output"></textarea>

</center>  </body>
</html>

Link to comment
Share on other sites

wow, looks more complicated then I would of expected. It works, except I guess I didn't say that the input number could be "x to xxxxxxxxx" the number of digits varies. I hope its not to much to alter. So to be clear If I put 4567893 in the input it would replace "xxxxxx" and "zzzzzz" with "4567893 and 4567000" or if I put in 2345 it would replace "xxxxxx and zzzzzz" with "2345 and 2000"

 

either way, what you did works perfect for 6 digit numbers! I have been trying to get this right for so long so a BIG help so far, I really appreciate it.

Link to comment
Share on other sites

. . . the input number could be "x to xxxxxxxxx" the number of digits varies. . . . If I put 4567893 in the input it would replace "xxxxxx" and "zzzzzz" with "4567893 and 4567000" or if I put in 2345 it would replace "xxxxxx and zzzzzz" with "2345 and 2000"

 

I find it amusing that people will expand the parameters allowed but then only give examples using the values that are "easy". You say that the input can be one to nine digits. But, all your examples show where the second permutation of the input has the last three digits replaced by zeros. Ok, so what happens if the user inputs a number that is one to three digits in length?

 

 

1234 replaces "xxxxxx and zzzzzz" with 1234 and 1000

123 replaces "xxxxxx and zzzzzz" with ??? and ???

12 replaces "xxxxxx and zzzzzz" with ??? and ???

1 replaces "xxxxxx and zzzzzz" with ??? and ???

Link to comment
Share on other sites

My apologies for simplifying my example so much. I didn't realize it would have be that much more complicated. What if the digits go from 4 to 9 long? Forget 1,2,3 digit numbers. I rarely have to use this on anything that small and I could do it manually in those cases. The actual template wasn't made by me and has always had "xxxxxx" and "zzzzzz" and is 102 url lines long. 95% of the time it's 6 digits, but we are using more and more 7 digit numbers, and sometimes 8, 9. The way we have been replacing the generic x and z variables has been with Windows .txt file editor.

 

"find xxxxxx, replace with 1234567, click replace all, then find zzzzzz, replace 1234000, click replace all. Same thing for any size number.

 

Such a pain so I made the original form I posted and it helps a lot, but sometimes we have to replace say 15+ templates at a time so you can see how this would speed up the process. I don't know Javascript yet as well as you to have done what you did for me. So again I apologize for my lack of clarity and I greatly appreciate what you've done thus far.

Link to comment
Share on other sites

Assuming you can just create the links, here's an example.

Demo: http://xaotique.no-ip.org/tmp/27/

 

Javascript

window.addEventListener("load", function()
{
   var img = [ 250, 500, 800, 1000 ];
   var btn = window.document.querySelectorAll(".btn");
   var txt = window.document.querySelectorAll(".txt");

   btn[0].addEventListener("click", function()
   {
       var input = txt[0].value.split(', ');
       txt[1].value = "";

       for (var i in input)
       {
           var num = [ input[i], input[i].substr(0, input[i].length - 3) + "000"];

           if (i > 0)
               txt[1].value += "\n";

           for (var n in img)
           {
               txt[1].value += "http://www.mysite.com/file/folder/blah/" + num[0] + "/_something_else here/" + num[1] + "/image" + img[n] + "\n";
           }
       }
   }, false);

   btn[1].addEventListener("click", function()
   {
       for (var i in txt)
       {
           txt[i].value = "";
       }

       txt[0].focus();
   }, false);
}, false);

Edited by Xaotique
Link to comment
Share on other sites

This is my template:

 

http://images.mysite.com/productImages/_zzzzzz/FF_xxxxxx_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/FF_xxxxxx_l.jpg
http://images.mysite.com/productImages/_zzzzzz/FF_xxxxxx_s.jpg
https://images.mysite.com/productimages/_zzzzzz/FF_xxxxxx_s.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/ff_xxxxxx_xl.jpg&w=68
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_zzzzzz/ff_xxxxxx_xl.jpg&w=68
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_zzzzzz/FF_xxxxxx_xl.jpg&w=90
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/FF_xxxxxx_xl.jpg&w=108
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/FF_xxxxxx_xl.jpg&w=140
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/FF_xxxxxx_xl.jpg&w=148
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/FF_xxxxxx_xl.jpg&w=160
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/FF_xxxxxx_xl.jpg&w=165
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_zzzzzz/FF_xxxxxx_xl.jpg&w=165
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/FF_xxxxxx_xl.jpg&w=180
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/FF_xxxxxx_xl.jpg&w=200
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_zzzzzz/ff_xxxxxx_xl.jpg&w=250
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/ff_xxxxxx_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz%2fFF_xxxxxx_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=%2fproductImages%2f_zzzzzz%2fff_xxxxxx_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/ff_xxxxxx_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz%2fFF_xxxxxx_xl.jpg&w=600
http://images.mysite.com/FFImage/thumb.aspx?i=%2fproductImages%2f_zzzzzz%2fff_xxxxxx_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT1_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT1_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT1_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT1_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT1_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT1_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT1_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT1_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT2_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT2_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT2_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT2_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT2_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT2_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT2_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT2_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT3_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT3_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT3_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT3_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT3_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT3_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT3_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT3_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT4_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT4_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT4_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT4_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT4_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT4_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT4_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT4_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT5_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT5_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT5_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT5_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT5_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT5_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT5_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT5_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT6_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT6_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT6_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT6_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT6_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT6_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT6_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT6_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT7_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT7_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT7_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT7_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT7_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT7_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT7_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT7_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT8_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT8_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT8_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT8_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT8_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT8_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT8_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT8_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT9_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT9_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT9_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT9_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT9_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT9_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT9_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT9_xl.jpg&w=600
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT10_xl.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT10_l.jpg
http://images.mysite.com/productImages/_zzzzzz/altImages/FF_xxxxxxALT10_tb.jpg
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altImages/FF_xxxxxxALT10_xl.jpg&w=35
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT10_xl.jpg&w=60
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT10_xl.jpg&w=400
http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_zzzzzz/altimages/FF_xxxxxxALT10_xl.jpg&w=500
http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_zzzzzz/altImages/FF_xxxxxxALT10_xl.jpg&w=600

Link to comment
Share on other sites

I added the entire template, But still can't figure out how to get the input digits to go from 4 digits long to 9 digits. Xaotique thank you for making that happen, but I don't think i can plug my template into your script. Is there some way to adjust the x input variable to be more flexible.

 

 


<!DOCTYPE html>
<html>
 <head>
       <title>Purge List Generator</title><br>
<br>
<style>
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url('bg1.jpg');
background-repeat:repeat-x;
}
</style><br>

         <script type="text/javascript">
               var reader = new FileReader();
               function rip(e)
               {
                  var out=(e && e.target && e.target.result) || output.value ;
                  var reps=txtReps.value.split(/\s*,\s*/);

                  output.value= out.split("\n").map(function(a){
                               return a .split("xxxxxx").join(reps[0])
                                 .split("zzzzzz").join(reps[1]);
                  }).join("\n");
               }

               function readText(that)
               {
                  if(that.files && that.files[0]){
                               var reader = new FileReader();
                               reader.onload = rip;
                               reader.readAsText(that.files[0]);
                  }//end if html5 filelist support
               }

               String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};

               var urls = new Array();
   urls[0] = "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg";
   urls[1] = "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_l.jpg";
   urls[2] = "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_s.jpg";
   urls[3] = "https://images.mysite.com/productimages/_[xxxxxx]/FF_[yyyyyy]_s.jpg";
   urls[4] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=68";
   urls[5] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=68";
   urls[6] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=90";
   urls[7] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=108";
   urls[8] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=140";
   urls[9] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=148";
   urls[10] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=160";
   urls[11] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=165";
   urls[12] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=165";
   urls[13] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=180";
   urls[14] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=200";
   urls[15] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages//_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=250";
   urls[16] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=400";
   urls[17] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]%2fFF_[yyyyyy]_xl.jpg&w=400";
   urls[18] = "http://images.mysite.com/FFImage/thumb.aspx?i=%2fproductImages%2f_[xxxxxx]%2fff_[yyyyyy]_xl.jpg&w=400";
   urls[19] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=500";
   urls[20] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]%2fFF_[yyyyyy]_xl.jpg&w=600";
   urls[21] = "http://images.mysite.com/FFImage/thumb.aspx?i=%2fproductImages%2f_[xxxxxx]%2fff_[yyyyyy]_xl.jpg&w=600";
   urls[22] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg";
   urls[23] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_l.jpg";
   urls[24] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_tb.jpg";
   urls[25] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=35";
   urls[26] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=60";
   urls[27] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=400";
   urls[28] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT1_xl.jpg&w=500";
   urls[29] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=600";
   urls[30] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg";
   urls[31] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_l.jpg";
   urls[32] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_tb.jpg";
   urls[33] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=35";
   urls[34] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=60";
   urls[35] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=400";
   urls[36] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT2_xl.jpg&w=500";
   urls[37] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=600";
   urls[38] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg";
   urls[39] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_l.jpg";
   urls[40] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_tb.jpg";
   urls[41] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=35";
   urls[42] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=60";
   urls[43] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=400";
   urls[44] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT3_xl.jpg&w=500";
   urls[45] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=600";
   urls[46] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg";
   urls[47] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_l.jpg";
   urls[48] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_tb.jpg";
   urls[49] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=35";
   urls[50] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=60";
   urls[51] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=400";
   urls[52] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT4_xl.jpg&w=500";
   urls[53] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=600";
   urls[54] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg";
   urls[55] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_l.jpg";
   urls[56] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_tb.jpg";
   urls[57] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=35";
   urls[58] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=60";
   urls[59] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=400";
   urls[60] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT5_xl.jpg&w=500";
   urls[61] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=600";
   urls[62] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg";
   urls[63] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_l.jpg";
   urls[64] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_tb.jpg";
   urls[65] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=35";
   urls[66] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=60";
   urls[67] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=400";
   urls[68] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT6_xl.jpg&w=500";
   urls[69] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=600";
   urls[70] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg";
   urls[71] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_l.jpg";
   urls[72] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_tb.jpg";
   urls[73] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=35";
   urls[74] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=60";
   urls[75] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=400";
   urls[76] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT7_xl.jpg&w=500";
   urls[77] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=600";
   urls[78] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg";
   urls[79] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_l.jpg";
   urls[80] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_tb.jpg";
   urls[81] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=35";
   urls[82] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=60";
   urls[83] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=400";
   urls[84] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT8_xl.jpg&w=500";
   urls[85] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=600";
   urls[86] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg";
   urls[87] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_l.jpg";
   urls[88] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_tb.jpg";
   urls[89] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=35";
   urls[90] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=60";
   urls[91] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=400";
   urls[92] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT9_xl.jpg&w=500";
   urls[93] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=600";
   urls[94] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg";
   urls[95] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_l.jpg";
   urls[96] = "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_tb.jpg";
   urls[97] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=35";
   urls[98] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=60";
   urls[99] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=400";
   urls[100] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT10_xl.jpg&w=500";
   urls[101] = "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=600";

               function updateURLs(numbers)
               {
                       var output = '';
                var numAry = numbers.split(',');
                       var numLen = numAry.length
                       var urlLen = urls.length;
                       for(var i=0; i<numLen; i++)
                       {
                               var num = numAry[i].replace(/^\s+|[^\d]*|\s+$/g, '');
                               if(num.length != 6)
                               {
                                //Error condition, don't use. Add error handling
                               }
                               else
                               {
                                       //add number replacement to each URL
                                       for(j=0; j<urlLen; j++)
                                       {
                                        url = urls[j].replace("[yyyyyy]", num);
                                               url = url.replace("[xxxxxx]", num.substr(0, 3)+'000');
                                               output += url + '\n';
                                       }
                                       //Add line break between each section
                                       output += '\n';
                               }
                       }
                       document.getElementById('output').value = output;
               }
</script>

</head>

<body style=": 1.5"> <center>
 <input type="file" onchange='readText(this)' /><br />
 <textarea rows=5 cols=84 id="txtReps" onblur="updateURLs(this.value);">123456</textarea><br />
 <button onclick="rip()">run script</button>
 <button onclick="output.value=output.defaultValue;">reset</button><br />
 <textarea rows=30 cols=130 id="output"></textarea><br>

</center>  </body>
</html>

Link to comment
Share on other sites

<!DOCTYPE html>
<html>
 <head>
   <title>Purge List Generator</title>

   <style>
   hr {color:sienna;}
   p {margin-left:20px;}
   body {
    background-image:url('bg1.jpg');
    background-repeat:repeat-x;
   }
   </style>

<script type="text/javascript">
var reader = new FileReader();
function rip(e)
{
var out=(e && e.target && e.target.result) || output.value ;
var reps=txtReps.value.split(/\s*,\s*/);

output.value= out.split("\n").map(function(a){
return a .split("xxxxxx").join(reps[0])
.split("zzzzzz").join(reps[1]);
}).join("\n");
}

function readText(that)
{
if(that.files && that.files[0]){
var reader = new FileReader();
reader.onload = rip;
reader.readAsText(that.files[0]);
}//end if html5 filelist support
}

String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};

var urls = '';
urls += "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_s.jpg\n";
urls += "https://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_s.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=68\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=68\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=90\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=108\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=140\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=148\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=160\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=165\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=165\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=180\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg&w=200\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=250\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]%2fFF_[yyyyyy]_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=%2fproductImages%2f_[xxxxxx]%2fff_[yyyyyy]_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/ff_[yyyyyy]_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]%2fFF_[yyyyyy]_xl.jpg&w=600\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=%2fproductImages%2f_[xxxxxx]%2fff_[yyyyyy]_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT1_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT2_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT2_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT3_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT3_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT4_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT4_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT5_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT5_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT6_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT6_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT7_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT7_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT8_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT8_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT9_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT9_xl.jpg&w=600\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_l.jpg\n";
urls += "http://images.mysite.com/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_tb.jpg\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=35\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=60\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=400\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productimages/_[xxxxxx]/altimages/FF_[yyyyyy]ALT10_xl.jpg&w=500\n";
urls += "http://images.mysite.com/FFImage/thumb.aspx?i=/productImages/_[xxxxxx]/altImages/FF_[yyyyyy]ALT10_xl.jpg&w=600\n";

function updateURLs(numbers)
{
   var numAry = numbers.split(',');
   var numLen = numAry.length
   var output = '';
   var urlSet;
   for(var i=0; i<numLen; i++)
   {
    var num = numAry[i].replace(/^\s+|[^\d]*|\s+$/g, '');
    if(num.length < 4 || num.length > 9)
    {
	    //Error condition, don't use. Add error handling
    }
    else
    {
	    urlSet = urls.replace(/\[yyyyyy\]/g, num);
	    urlSet = urlSet.replace(/\[xxxxxx\]/g, num.substr(0, num.length-3)+'000');
	    output += urlSet + '\n';
    }
   }
   document.getElementById('output').value = output;
}
</script>

</head>

<body> <center>
 <input type="file" onchange='readText(this)' /><br />
 <textarea rows=5 cols=84 id="txtReps" onblur="updateURLs(this.value);">123456</textarea><br />
 <button onclick="rip()">run script</button>
 <button onclick="output.value=output.defaultValue;">reset</button><br />
 <textarea rows=30 cols=130 id="output"></textarea><br>

</center>  </body>
</html>

Link to comment
Share on other sites

. . . just trying to get it to work in IE9.

 

I guess it's been too long since I've done much Javascript. For some reason IE is not seeing the variable 'urls', the string with all the base urls, as a global variable. One easy fic is to just move the declaration of urls inside the function.

 

function updateURLs(numbers)
{
   var urls = '';
   urls += "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_xl.jpg\n";
   urls += "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_l.jpg\n";
   urls += "http://images.mysite.com/productImages/_[xxxxxx]/FF_[yyyyyy]_s.jpg\n";
   // . . . include all other base URLS

   var numAry = numbers.split(',');
   var numLen = numAry.length
   var output = '';
   var urlSet;
   for(var i=0; i<numLen; i++)
   {
    var num = numAry[i].replace(/^\s+|[^\d]*|\s+$/g, '');
    if(num.length < 4 || num.length > 9)
    {
	    //Error condition, don't use. Add error handling
    }
    else
    {
		 urlSet = urls.replace(/\[yyyyyy\]/g, num);
		 urlSet = urlSet.replace(/\[xxxxxx\]/g, num.substr(0, num.length-3)+'000');
		 output += urlSet + '\n';
    }
   }
   document.getElementById('output').value = output;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.