Skip to content

Commit a087184

Browse files
author
mreishman
committed
started change to pre gen watchlist blocks in function. Works for load, need add for new
1 parent 6aa983a commit a087184

File tree

8 files changed

+140
-194
lines changed

8 files changed

+140
-194
lines changed

core/js/watchlist.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
var urlForCurl = "./core/php/functions/sendCurl.php";
2+
var countOfAddedFiles = 0;
3+
var countOfClicks = 0;
4+
var locationInsert = "newRowLocationForWatchList";
25

36
function addRowFunction()
47
{
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
function generateWatchlistBlock($defaultArray, $arrayKeys, $key, $item, $i)
4+
{
5+
$stringToReturn = "
6+
<script type=\"text/javascript\">
7+
var dataForWatchFolder" . $i . " = " . json_encode($item) . ";
8+
</script>
9+
<li class=\"watchFolderGroups\" id=\"rowNumber" . $i . "\" >
10+
<span class=\"leftSpacingserverNames\" > Name: </span>
11+
<input class='inputWidth300' type='text' name='watchListKey" . $i . "' value='" . $key . "'>";
12+
$j = 0;
13+
foreach($defaultArray as $key2 => $item2)
14+
{
15+
$j++;
16+
$stringToReturn .= "
17+
<br>
18+
<span class=\"leftSpacingserverNames\" >" . $arrayKeys[$key2] . ": </span>
19+
<input style=\"display: none;\" type=\"text\" name='watchListItem" . $i . "-" . $j . "-Name' value=\"" . $key2 . "\" >";
20+
if($key2 === "type")
21+
{
22+
$stringToReturn .= "
23+
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >
24+
<option value=\"local\" ";
25+
if($item[$key2] === "local")
26+
{
27+
$stringToReturn .= " selected ";
28+
}
29+
$stringToReturn .= " >Local</option>
30+
<option value=\"external\" ";
31+
if($item[$key2] === "external")
32+
{
33+
$stringToReturn .= " selected ";
34+
}
35+
$stringToReturn .= ">External</option>
36+
</select>";
37+
}
38+
elseif($key2 === "gitType")
39+
{
40+
$stringToReturn .= "
41+
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >
42+
<option value=\"github\" ";
43+
if($item[$key2] === "github")
44+
{
45+
$stringToReturn .= " selected ";
46+
}
47+
$stringToReturn .= " >GitHub</option>
48+
<option value=\"gitlab\" ";
49+
if($item[$key2] === "gitlab")
50+
{
51+
$stringToReturn .= "selected";
52+
}
53+
$stringToReturn .= ">GitLab</option>
54+
</select>";
55+
}
56+
elseif($key2 === "Archive")
57+
{
58+
$value = "false";
59+
if(isset($item[$key2]))
60+
{
61+
$value = (string)$item[$key2];
62+
}
63+
$stringToReturn .= "
64+
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >
65+
<option value=\"true\" ";
66+
if($value === "true")
67+
{
68+
$stringToReturn .= " selected ";
69+
}
70+
$stringToReturn .= " >True</option>
71+
<option value=\"false\" ";
72+
if($value === "false")
73+
{
74+
$stringToReturn .= " selected ";
75+
}
76+
$stringToReturn .= " >False</option>
77+
</select>";
78+
}
79+
else
80+
{
81+
$stringToReturn .= "
82+
<input class='inputWidth300' type='text' name='watchListItem" . $i . "-" . $j . "' value='";
83+
if(isset($item[$key2]))
84+
{
85+
$stringToReturn .= "$item[$key2]";
86+
}
87+
$stringToReturn .= "'>";
88+
}
89+
}
90+
$stringToReturn .= "
91+
<input style=\"display: none\" type=\"text\" name=\"watchListItem" . $i . "-0\" value='" . $j . "'>
92+
<table width=\"100%\">
93+
<tr>
94+
<th width=\"50%\" style=\" text-align: center;\">
95+
<a style=\"display: block;\" class=\"mainLinkClass\" onclick=\"deleteRowFunction(" . $i . ", true);\">Remove</a>
96+
</th>
97+
<th width=\"50%\" style=\" text-align: center;\">
98+
<a style=\"display: block;\" class=\"mainLinkClass\" onclick=\"testConnection(dataForWatchFolder" . $i . ");\" >Check Connection</a>
99+
</th>
100+
</tr>
101+
</table>
102+
<table width=\"100%\">
103+
<tr>
104+
<th width=\"50%\" style=\" text-align: center;\">
105+
<a style=\"display: block;\" class=\"mainLinkClass\" > Move Up One </a>
106+
</th>
107+
<th width=\"50%\" style=\" text-align: center;\">
108+
<a style=\"display: block;\" class=\"mainLinkClass\" > Move Down One </a>
109+
</th>
110+
</tr>
111+
</table>
112+
</li>";
113+
return $stringToReturn;
114+
}

core/php/templateFiles/watchList.php

Lines changed: 10 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</li>
4343
<?php
4444

45-
$approvedArrayKeys = array(
45+
$arrayKeys = array(
4646
"Name" => "Name",
4747
"WebsiteBase" => "Website Base",
4848
"Folder" => "Folder",
@@ -82,7 +82,7 @@
8282
</li>
8383
<?php
8484

85-
$approvedArrayKeys = array(
85+
$arrayKeys = array(
8686
"Name" => "Name",
8787
"WebsiteBase" => "Website Base",
8888
"urlHit" => "URl Hit",
@@ -91,99 +91,24 @@
9191

9292
$defaultArray = array(
9393
'WebsiteBase' => '',
94-
'Folder' => '',
9594
'urlHit' => '',
96-
"type" => "",
9795
"Archive" => 'false'
9896
);
9997

10098
endif; ?>
10199
<script type="text/javascript">
102-
var arrayOfKeysNonEnc = <?php echo json_encode(array_keys($defaultArray)); ?>
100+
var arrayOfKeysNonEnc = <?php echo json_encode(array_keys($defaultArray)); ?>;
101+
var numberOfSubRows = <?php echo count(array_keys($defaultArray)); ?>;
102+
var countOfWatchList = <?php echo count(array_keys($config['serverWatchList'])); ?>;
103103
</script>
104104
<li><h2>Your Watch List: </h2></li>
105105
<?php
106106
$i = 0;
107-
$numCount = 0;
108-
foreach($config['watchList'] as $key => $item): $i++;
109-
$type = "internal";
110-
if(isset($item["type"]) && $pollType === "2")
111-
{
112-
$type = $item["type"];
113-
}
114-
?>
115-
<script type="text/javascript">
116-
var dataForWatchFolder<?php echo $i?> = JSON.parse('<?php echo json_encode($item); ?>');
117-
</script>
118-
<li class="watchFolderGroups" id="rowNumber<?php echo $i; ?>" >
119-
<span class="leftSpacingserverNames" > Name: </span>
120-
<input <?php if ($type === "external"){ echo "disabled= \"true\";";}?> class='inputWidth300' type='text' name='watchListKey<?php echo $i; ?>' value='<?php echo $key; ?>'>
121-
<?php
122-
$j = 0;
123-
foreach($defaultArray as $key2 => $item2):
124-
if(isset($approvedArrayKeys[$key2])):
125-
$j++;
126-
?>
127-
<br>
128-
<span class="leftSpacingserverNames" > <?php echo $approvedArrayKeys[$key2]; ?>: </span>
129-
<input style="display: none;" type="text" name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>-Name' value="<?php echo $key2;?>" >
130-
<?php
131-
if($key2 === "gitType"):
132-
$gitType = $item2;
133-
if(isset($item[$key2]))
134-
{
135-
$gitType = $item[$key2];
136-
}
137-
?>
138-
<select class='inputWidth300' name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>' >
139-
<option value="github" <?php if($gitType === "github"){echo "selected"; }?> >GitHub</option>
140-
<option value="gitlab" <?php if($gitType === "gitlab"){echo "selected"; }?> >GitLab</option>
141-
</select>
142-
<?php elseif($key2 === "Archive"): ?>
143-
<?php
144-
$value = "false";
145-
if(isset($item[$key2]))
146-
{
147-
$value = (string)$item[$key2];
148-
}
149-
?>
150-
<select class='inputWidth300' name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>' >
151-
<option value="true" <?php if($value === "true"){echo "selected"; }?> >True</option>
152-
<option value="false" <?php if($value === "false"){echo "selected"; }?> >False</option>
153-
</select>
154-
<?php else: ?>
155-
<input class='inputWidth300' type='text' name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>' value='<?php if(isset($item[$key2])){ echo $item[$key2]; }?>'>
156-
<?php endif;
157-
endif;
158-
endforeach;
159-
if($numCount < $j)
160-
{
161-
$numCount = $j;
162-
}
163-
?>
164-
<input style="display: none" type="text" name="watchListItem<?php echo $i;?>-0" value='<?php echo $j;?>'>
165-
<table width="100%">
166-
<tr>
167-
<th width="50%" style=" text-align: center;">
168-
<a style="display: block;" class="mainLinkClass" onclick="deleteRowFunction(<?php echo $i; ?>, true);">Remove</a>
169-
</th>
170-
<th width="50%" style=" text-align: center;">
171-
<a style="display: block;" class="mainLinkClass" onclick="testConnection(dataForWatchFolder<?php echo $i; ?>);" >Check Connection</a>
172-
</th>
173-
</tr>
174-
</table>
175-
<table width="100%">
176-
<tr>
177-
<th width="50%" style=" text-align: center;">
178-
<a style="display: block;" class="mainLinkClass" > Move Up One </a>
179-
</th>
180-
<th width="50%" style=" text-align: center;">
181-
<a style="display: block;" class="mainLinkClass" > Move Down One </a>
182-
</th>
183-
</tr>
184-
</table>
185-
</li>
186-
<?php endforeach; ?>
107+
foreach($config['watchList'] as $key => $item)
108+
{
109+
$i++;
110+
echo generateWatchlistBlock($defaultArray, $arrayKeys, $key, $item, $i);
111+
} ?>
187112
<div style="display: inline-block;" id="newRowLocationForWatchList"></div>
188113
</ul>
189114
<ul class="settingsUl">

core/php/templateFiles/watchListServer.php

Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -78,84 +78,16 @@
7878
);
7979
?>
8080
<script type="text/javascript">
81-
var arrayOfKeysNonEnc = <?php echo json_encode(array_keys($defaultArray)); ?>
81+
var arrayOfKeysNonEnc = <?php echo json_encode(array_keys($defaultArray)); ?>;
82+
var numberOfSubRows = <?php echo count(array_keys($defaultArray)); ?>;
83+
var countOfWatchList = <?php echo count(array_keys($config['serverWatchList'])); ?>;
8284
</script>
8385
<?php
8486
$i = 0;
85-
$numCount = 0;
86-
foreach($config['serverWatchList'] as $key => $item): $i++; ?>
87-
<script type="text/javascript">
88-
var dataForWatchFolder<?php echo $i?> = JSON.parse('<?php echo json_encode($item); ?>');
89-
</script>
90-
<li class="watchFolderGroups" id="rowNumber<?php echo $i; ?>" >
91-
<span class="leftSpacingserverNames" > Name: </span>
92-
<input class='inputWidth300' type='text' name='watchListKey<?php echo $i; ?>' value='<?php echo $key; ?>'>
93-
<?php
94-
$j = 0;
95-
foreach($defaultArray as $key2 => $item2):
96-
$j++;
97-
?>
98-
<br>
99-
<span class="leftSpacingserverNames" > <?php echo $arrayKeys[$key2]; ?>: </span>
100-
<input style="display: none;" type="text" name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>-Name' value="<?php echo $key2;?>" >
101-
<?php
102-
if($key2 === "type"):
103-
?>
104-
<select class='inputWidth300' name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>' >
105-
<option value="local" <?php if($item[$key2] === "local"){echo "selected"; }?> >Local</option>
106-
<option value="external" <?php if($item[$key2] === "external"){echo "selected"; }?> >External</option>
107-
</select>
108-
<?php
109-
elseif($key2 === "gitType"):
110-
?>
111-
<select class='inputWidth300' name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>' >
112-
<option value="github" <?php if($item[$key2] === "github"){echo "selected"; }?> >GitHub</option>
113-
<option value="gitlab" <?php if($item[$key2] === "gitlab"){echo "selected"; }?> >GitLab</option>
114-
</select>
115-
<?php elseif($key2 === "Archive"): ?>
116-
<?php
117-
$value = "false";
118-
if(isset($item[$key2]))
119-
{
120-
$value = (string)$item[$key2];
121-
}
122-
?>
123-
<select class='inputWidth300' name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>' >
124-
<option value="true" <?php if($value === "true"){echo "selected"; }?> >True</option>
125-
<option value="false" <?php if($value === "false"){echo "selected"; }?> >False</option>
126-
</select>
127-
<?php else: ?>
128-
<input class='inputWidth300' type='text' name='watchListItem<?php echo $i; ?>-<?php echo $j; ?>' value='<?php if (isset($item[$key2])){ echo $item[$key2]; } ?>'>
129-
<?php endif; ?>
130-
<?php endforeach;
131-
if($numCount < $j)
132-
{
133-
$numCount = $j;
134-
}
135-
?>
136-
<input style="display: none" type="text" name="watchListItem<?php echo $i;?>-0" value='<?php echo $j;?>'>
137-
<table width="100%">
138-
<tr>
139-
<th width="50%" style=" text-align: center;">
140-
<a style="display: block;" class="mainLinkClass" onclick="deleteRowFunction(<?php echo $i; ?>, true);">Remove</a>
141-
</th>
142-
<th width="50%" style=" text-align: center;">
143-
<a style="display: block;" class="mainLinkClass" onclick="testConnection(dataForWatchFolder<?php echo $i; ?>);" >Check Connection</a>
144-
</th>
145-
</tr>
146-
</table>
147-
<table width="100%">
148-
<tr>
149-
<th width="50%" style=" text-align: center;">
150-
<a style="display: block;" class="mainLinkClass" > Move Up One </a>
151-
</th>
152-
<th width="50%" style=" text-align: center;">
153-
<a style="display: block;" class="mainLinkClass" > Move Down One </a>
154-
</th>
155-
</tr>
156-
</table>
157-
</li>
158-
<?php endforeach; ?>
87+
foreach($config['serverWatchList'] as $key => $item){
88+
$i++;
89+
echo generateWatchlistBlock($defaultArray, $arrayKeys, $key, $item, $i);
90+
} ?>
15991
<div style="display: inline-block;" id="newRowLocationForWatchList"></div>
16092
</ul>
16193
<ul class="settingsUl">

settings-watchList.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
require_once("core/php/functions/commonFunctions.php");
3+
require_once("core/php/functions/watchlistFunctions.php");
34
$baseUrl = "core/";
45
if(file_exists('local/layout.php'))
56
{
@@ -108,13 +109,6 @@ function saveWatchList(post)
108109
}
109110

110111
}
111-
112-
113-
var countOfWatchList = <?php echo $i; ?>;
114-
var countOfAddedFiles = 0;
115-
var countOfClicks = 0;
116-
var locationInsert = "newRowLocationForWatchList";
117-
var numberOfSubRows = <?php echo $numCount; ?>;
118112
<?php
119113
echo "var currentVersion = '".$configStatic['version']."';";
120114
?>

settings-watchListServer.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
require_once("core/php/functions/commonFunctions.php");
3+
require_once("core/php/functions/watchlistFunctions.php");
34
$baseUrl = "core/";
45
if(file_exists('local/layout.php'))
56
{
@@ -108,13 +109,6 @@ function saveWatchList(post)
108109
}
109110

110111
}
111-
112-
113-
var countOfWatchList = <?php echo $i; ?>;
114-
var countOfAddedFiles = 0;
115-
var countOfClicks = 0;
116-
var locationInsert = "newRowLocationForWatchList";
117-
var numberOfSubRows = <?php echo $numCount; ?>;
118112
<?php
119113
echo "var currentVersion = '".$configStatic['version']."';";
120114
?>

0 commit comments

Comments
 (0)