Code Duplication    Length = 90-92 lines in 2 locations

Themes/default/Calendar.template.php 2 locations

@@ 1020-1111 (lines=92) @@
1017
		</script>';
1018
}
1019
1020
function template_hms()
1021
{
1022
	global $context, $scripturl;
1023
	$alt = false;
1024
1025
	echo '
1026
		<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;">
1027
			<tr>
1028
				<th class="windowbg" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;">Binary Clock</th>
1029
			</tr>';
1030
1031
	foreach ($context['clockicons'] as $t => $v)
1032
	{
1033
		echo '
1034
			<tr class="windowbg">
1035
				<td>';
1036
1037
		foreach ($v as $i)
1038
			echo '
1039
					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1040
1041
		echo '
1042
				</td>
1043
			</tr>';
1044
1045
		$alt = !$alt;
1046
	}
1047
	echo '
1048
			<tr class="windowbg" style="border-top: 1px solid #ccc; text-align: center;">
1049
				<td>
1050
					<a href="', $scripturl, '?action=clock">Too tough for you?</a>
1051
				</td>
1052
			</tr>
1053
		</table>';
1054
1055
	echo '
1056
		<script>
1057
			var icons = new Object();';
1058
1059
	foreach ($context['clockicons'] as $t => $v)
1060
	{
1061
		foreach ($v as $i)
1062
			echo '
1063
			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1064
	}
1065
1066
	echo '
1067
			function update()
1068
			{
1069
				// Get the current time
1070
				var time = new Date();
1071
				var h = time.getHours();
1072
				var m = time.getMinutes();
1073
				var s = time.getSeconds();
1074
1075
				// For each digit figure out which ones to turn off and which ones to turn on
1076
				var turnon = new Array();';
1077
1078
	foreach ($context['clockicons'] as $t => $v)
1079
	{
1080
		foreach ($v as $i)
1081
			echo '
1082
				if (', $t, ' >= ', $i, ')
1083
				{
1084
					turnon.push("', $t, '_', $i, '");
1085
					', $t, ' -= ', $i, ';
1086
				}';
1087
	}
1088
1089
	echo '
1090
				for (var i in icons)
1091
					if (!in_array(i, turnon))
1092
						icons[i].src = "', $context['offimg'], '";
1093
					else
1094
						icons[i].src = "', $context['onimg'], '";
1095
1096
				window.setTimeout("update();", 500);
1097
			}
1098
			// Checks for variable in theArray.
1099
			function in_array(variable, theArray)
1100
			{
1101
				for (var i = 0; i < theArray.length; i++)
1102
				{
1103
					if (theArray[i] == variable)
1104
						return true;
1105
				}
1106
				return false;
1107
			}
1108
1109
			update();
1110
		</script>';
1111
}
1112
1113
function template_omfg()
1114
{
@@ 1113-1202 (lines=90) @@
1110
		</script>';
1111
}
1112
1113
function template_omfg()
1114
{
1115
	global $context;
1116
	$alt = false;
1117
1118
	echo '
1119
		<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;">
1120
			<tr>
1121
				<th class="windowbg" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;">OMFG Binary Clock</th>
1122
			</tr>';
1123
1124
	foreach ($context['clockicons'] as $t => $v)
1125
	{
1126
		echo '
1127
			<tr class="windowbg">
1128
				<td>';
1129
1130
		foreach ($v as $i)
1131
			echo '
1132
					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1133
1134
		echo '
1135
				</td>
1136
			</tr>';
1137
1138
		$alt = !$alt;
1139
	}
1140
1141
	echo '
1142
		</table>
1143
		<script>
1144
			var icons = new Object();';
1145
1146
	foreach ($context['clockicons'] as $t => $v)
1147
	{
1148
		foreach ($v as $i)
1149
			echo '
1150
			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1151
	}
1152
1153
	echo '
1154
			function update()
1155
			{
1156
				// Get the current time
1157
				var time = new Date();
1158
				var month = time.getMonth() + 1;
1159
				var day = time.getDate();
1160
				var year = time.getFullYear();
1161
				year = year % 100;
1162
				var hour = time.getHours();
1163
				var min = time.getMinutes();
1164
				var sec = time.getSeconds();
1165
1166
				// For each digit figure out which ones to turn off and which ones to turn on
1167
				var turnon = new Array();';
1168
1169
	foreach ($context['clockicons'] as $t => $v)
1170
	{
1171
		foreach ($v as $i)
1172
		echo '
1173
				if (', $t, ' >= ', $i, ')
1174
				{
1175
					turnon.push("', $t, '_', $i, '");
1176
					', $t, ' -= ', $i, ';
1177
				}';
1178
	}
1179
1180
	echo '
1181
				for (var i in icons)
1182
					if (!in_array(i, turnon))
1183
						icons[i].src = "', $context['offimg'], '";
1184
					else
1185
						icons[i].src = "', $context['onimg'], '";
1186
1187
				window.setTimeout("update();", 500);
1188
			}
1189
			// Checks for variable in theArray.
1190
			function in_array(variable, theArray)
1191
			{
1192
				for (var i = 0; i < theArray.length; i++)
1193
				{
1194
					if (theArray[i] == variable)
1195
						return true;
1196
				}
1197
				return false;
1198
			}
1199
1200
			update();
1201
		</script>';
1202
}
1203
1204
function template_thetime()
1205
{