Code Duplication    Length = 88-92 lines in 2 locations

Themes/default/Calendar.template.php 2 locations

@@ 714-805 (lines=92) @@
711
		</form>';
712
}
713
714
function template_bcd()
715
{
716
	global $context, $scripturl;
717
	$alt = false;
718
	echo '
719
		<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;">
720
			<tr>
721
				<th class="windowbg2" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;" colspan="6">BCD Clock</th>
722
			</tr>
723
			<tr class="windowbg">';
724
			foreach ($context['clockicons'] as $t => $v)
725
			{
726
				echo '<td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">';
727
				foreach ($v as $i)
728
				{
729
					echo '<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>';
730
				}
731
				echo '</td>';
732
				$alt = !$alt;
733
			}
734
			echo '</tr>
735
			<tr class="', $alt ? 'windowbg2' : 'windowbg', '" style="border-top: 1px solid #ccc; text-align: center;">
736
				<td colspan="6">
737
					<a href="', $scripturl, '?action=clock;rb">Are you hardcore?</a>
738
				</td>
739
			</tr>
740
		</table>
741
742
		<script>
743
		var icons = new Object();';
744
745
		foreach ($context['clockicons'] as $t => $v)
746
		{
747
			foreach ($v as $i)
748
				echo '
749
			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
750
		}
751
752
		echo '
753
		function update()
754
		{
755
			// Get the current time
756
			var time = new Date();
757
			var hour = time.getHours();
758
			var min = time.getMinutes();
759
			var sec = time.getSeconds();
760
761
			// Break it up into individual digits
762
			var h1 = parseInt(hour / 10);
763
			var h2 = hour % 10;
764
			var m1 = parseInt(min / 10);
765
			var m2 = min % 10;
766
			var s1 = parseInt(sec / 10);
767
			var s2 = sec % 10;
768
769
			// For each digit figure out which ones to turn off and which ones to turn on
770
			var turnon = new Array();';
771
772
		foreach ($context['clockicons'] as $t => $v)
773
		{
774
			foreach ($v as $i)
775
				echo '
776
			if (', $t, ' >= ', $i, ')
777
			{
778
				turnon.push("', $t, '_', $i, '");
779
				', $t, ' -= ', $i, ';
780
			}';
781
		}
782
783
		echo '
784
			for (var i in icons)
785
				if (!in_array(i, turnon))
786
					icons[i].src = "', $context['offimg'], '";
787
				else
788
					icons[i].src = "', $context['onimg'], '";
789
790
			window.setTimeout("update();", 500);
791
		}
792
		// Checks for variable in theArray.
793
		function in_array(variable, theArray)
794
		{
795
			for (var i = 0; i < theArray.length; i++)
796
			{
797
				if (theArray[i] == variable)
798
					return true;
799
			}
800
			return false;
801
		}
802
803
		update();
804
		</script>';
805
}
806
807
function template_hms()
808
{
@@ 807-894 (lines=88) @@
804
		</script>';
805
}
806
807
function template_hms()
808
{
809
	global $context, $scripturl;
810
	$alt = false;
811
	echo '
812
		<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;">
813
			<tr>
814
				<th class="windowbg2" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;">Binary Clock</th>
815
			</tr>';
816
			foreach ($context['clockicons'] as $t => $v)
817
			{
818
				echo '
819
					<tr class="', $alt ? 'windowbg2' : 'windowbg', '">
820
						<td>';
821
						foreach ($v as $i)
822
						{
823
							echo '<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
824
						}
825
						echo '</td>
826
					</tr>
827
				';
828
				$alt = !$alt;
829
			}
830
			echo '</tr>
831
			<tr class="', $alt ? 'windowbg2' : 'windowbg', '" style="border-top: 1px solid #ccc; text-align: center;">
832
				<td>
833
					<a href="', $scripturl, '?action=clock">Too tough for you?</a>
834
				</td>
835
			</tr>
836
		</table>';
837
838
	echo '
839
	<script>
840
	var icons = new Object();';
841
842
	foreach ($context['clockicons'] as $t => $v)
843
	{
844
		foreach ($v as $i)
845
			echo '
846
		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
847
	}
848
849
	echo '
850
	function update()
851
	{
852
		// Get the current time
853
		var time = new Date();
854
		var h = time.getHours();
855
		var m = time.getMinutes();
856
		var s = time.getSeconds();
857
858
		// For each digit figure out which ones to turn off and which ones to turn on
859
		var turnon = new Array();';
860
861
	foreach ($context['clockicons'] as $t => $v)
862
	{
863
		foreach ($v as $i)
864
			echo '
865
		if (', $t, ' >= ', $i, ')
866
		{
867
			turnon.push("', $t, '_', $i, '");
868
			', $t, ' -= ', $i, ';
869
		}';
870
	}
871
872
	echo '
873
		for (var i in icons)
874
			if (!in_array(i, turnon))
875
				icons[i].src = "', $context['offimg'], '";
876
			else
877
				icons[i].src = "', $context['onimg'], '";
878
879
		window.setTimeout("update();", 500);
880
	}
881
	// Checks for variable in theArray.
882
	function in_array(variable, theArray)
883
	{
884
		for (var i = 0; i < theArray.length; i++)
885
		{
886
			if (theArray[i] == variable)
887
				return true;
888
		}
889
		return false;
890
	}
891
892
	update();
893
	</script>';
894
}
895
896
function template_omfg()
897
{