iMacros: Pauze after x amount of loops (Javascript)

What I’ve read so far is that pausing in between loops is only
possible in javascript. I have a hard time getting my code to work in
Javascript.

What i want my code to execute:
Go to a website and click a button.
Loop trough the sites different sub domains via my datasource text file.
I want to run 90 loops (going trough 90 sub domains) pause for 1 hour, continue the loop for another 90 and pause again for 1 hour etc etc.. (my datasource text file consists of 1000+ sub domains).

This i my code:

SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*10 + 2); randomNumber;") /*after a button is pushed wait for a random number of seconds*/ 
SET !TIMEOUT_PAGE 120
SET !ERRORIGNORE YES
SET !DATASOURCE_DELIMITER ;
SET !DATASOURCE data_list.txt
SET !DATASOURCE_COLUMNS 1
URL GOTO=http://www.website.com/{{!COL1}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:Button
WAIT SECONDS={{!var1}}

This works fine i can put an x amount of loops and the code Will run just fine. But i can’t / don’t know how to pause after 90 loops in javascript.

This is how far i got in converting my code to javascript:

var macro;
var rand = "Math.floor(Math.random()*10 + 2)"; /*after a button is pushed wait for a random number of seconds*/ 
macro =  "CODE:";
macro +=  "SET !TIMEOUT_PAGE 120" + "n"; 
macro +=  "SET !TIMEOUT_TAG 0" + "n"; 
macro +=  "SET !ERRORIGNORE YES" + "n"; 
macro +=  "SET !DATASOURCE ACCOUNTS_NO.txt" + "n"; 
macro +=  "SET !DATASOURCE_COLUMNS 1" + "n"; 
macro +=  "SET !DATASOURCE_LINE {{!LOOP}}" + "n"; 
macro +=  "URL GOTO=https://www.website.com/{{!COL1}}" + "n"; 
macro +=  "TAG POS=1 TYPE=BUTTON ATTR=TXT:Button" + "n"; 
macro +=  "WAIT SECONDS = {{rand}}" + "n"; /***this does not seem to work in javascript*/**
iimPlay(macro)

The random number in javascript does not work. Also the code to loop for 90 times, pause for 1 hour and continue still needs to be added.

Can anybody please help out?


Source: stackoverflow-javascript

Iterating through a javascript object to get key-value pairs

Here’s my code:

obj = {"TIME":123,"DATE":456}

console.log(obj.TIME);
console.log("---------")

for (var key in obj) {
  console.log(key);
  console.log(obj.key);
}

It prints as the following:

123
---------
TIME
undefined
DATE
undefined

Why does console.log(obj.key) print as undefined?

I want my code to print out the following, using obj.key to print out the value for each key:

123
---------
TIME
123
DATE
456

How do I do so?


Source: stackoverflow-javascript

Looping queries to an API is really slow

I’ve heard that it is possible to loop JSON datas by using only one query and not doing querries for every loop. Any ideas how to make this from this code?
I really need to do it because it takes up to 3 minutes to successfully load the page..

* PHP *

<?php foreach ($return as $user) {

                        $link = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$devkey&steamids=$user->SteamID";
                        $json = file_get_contents($link);
                        $decoding = json_decode($json);
                        $avatar = $decoding->response->players[0]->avatar;
                        ?>
                        <td id="addme"><img src="<?php echo $avatar; ?>" width="32" height="32"></td>
                        <td><?php echo $user->DisplayName; ?></td>
                        <td><?php echo $user->SteamID; ?>  <a href="http://steamcommunity.com/profiles/<?php echo $user->SteamID; ?>/" target="_blank"><span class="glyphicon glyphicon-new-window" id="gotosteamprofile"></span></a></td>
                        <td><?php
                        $ipredc = substr($user->Address, 0, -6);
                        echo $ipredc; ?></td>
                        <td><?php 
                        $toconver = $user->ConnectedSeconds;
                        $hours = floor($toconver / 3600);
                        $mins = floor($toconver / 60 % 60);
                        $secs = floor($toconver % 60);
                        $timeFormat = sprintf('%02d:%02d:%02d', $hours, $mins, $secs);
                        echo $timeFormat;
                        ?></td>
                        </tr>

                    <?php
                    }
                    ?>


Source: stackoverflow-php

How can I order a table in a loop depending on the highest number in a specific <td>

How can I order lines of a table depending on the highest number in a loop like this :

<?php
while ($d = $data->fetch()) {
$champs_files = fopen("champions/".$champion."_".$d['user_id'].".txt", "r");
$mastery_points = fread($champs_files,filesize("champions/".$champion."_".$d['user_id'].".txt"));
fclose($champs_files);
?>
<tr>
    <td><?= $rank += 1 ?></td>

        <td><?= $d['user_name'] ?></td>

        <td><?= $mastery_points ?></td>

        <td><?= $d['user_region'] ?></td>

    </tr>
<?php
}
?>

I want to put at the top the line who has the biggest $mastery_points .

I can’t use MySql cause I have limited number of tables thats why I use files .


Source: stackoverflow-php

PHP, for <= not expected results with decimals

When I run this PHP (5.4.31, running on 32-bit windows xp) code I get the result I’d expect:

for($i = 0; $i <= 10; $i = $i + 0.5)
    echo $i .' ';

But if I move the decimal point over as so:

for($i = 0; $i <= 1; $i = $i + 0.05)
    echo $i .' ';

despite the <= clause, the loop quits at 0.95 instead of at 1.

I’m aware that there is an imprecise nature to floating point numbers, but this seems kind of extreme.


Source: stackoverflow-php

How can I submit form data from a foreach loop?

This is my form:

<form action="update.php" method="post">
    
<button type="submit"> Submit</button> </form>

I insert data via Ajax:

 $.ajax({
     url: "data.php",
     data: {
         id: id,
     },
     type: "POST",
     success: function(data) {
         $("#data").html(data);
     }
 })

data.php:

<?php
$pdo = $db->prepare("SELECT * FROM data WHERE id = ?");
$pdo->execute(array($id));
while ($row = $pdo->fetch(PDO::FETCH_ASSOC))
    {
   ?>
   <input name="id[]" type="text" value="<?php echo $row['id'];?>">
   <input name="name[]" type="text" value="<?php echo $row['name'];?>">
<?php
}

As an Output I have for example:

2  Jim
3  Alan
5  Bob

Now in my update.php I want to update my data in the mySQL database:

<?php
foreach($_POST['id'] as $key => $value) {
    $id = $_POST['id'][$key];
    $name = $_POST['name'][$key];
    $pdo = $db->prepare("UPDATE data SET name=?, WHERE id=?;");
    $pdo->execute(array(
        $name,
        $id
    ));
        echo $id." ".$name;
}

As a result I expect to get again:

2  Jim
3  Alan
5  Bob

But what happens, I get only:

2  Jim


Source: stackoverflow-php

How to dynamically loop through different arrays in PHP?

If I want to loop through both of these arrays:

array (size=3)
  0 => 
    array (size=1)
      'email' => string 'testr@example.com' (length=17)
  1 => 
    array (size=1)
      'name' => string 'Joe' (length=3)
  2 => 
    array (size=1)
      'lastName' => string 'Doe' (length=3)

and

array (size=2)
  'email' => string 'taylor@example.com' (length=18)
  'name' => string 'Jay' (length=3)

The reason I am showing both arrays is I am trying to write a function to handle both arrays. I understand how to loop through the second array as I have been using in my function:

foreach($inserts as $colName => $colValue)
{
  //...
}

However, its the first array that I am struggling with, how can I handle looping through the first array while still supporting looping through the second array as my function could be passed both types of arrays that I showed above?

I did try and have a go with two foreach loops for the first array but I am wondering if there is a way where I can just have one loop to handle both types of arrays and if there is a way to detect the first type of array as I need to do something if the first type of array is passed in?


Source: stackoverflow-php