[Scummvm-cvs-logs] SF.net SVN: scummvm: [27092] web/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Jun 5 00:50:43 CEST 2007
Revision: 27092
http://scummvm.svn.sourceforge.net/scummvm/?rev=27092&view=rev
Author: fingolfin
Date: 2007-06-04 15:50:42 -0700 (Mon, 04 Jun 2007)
Log Message:
-----------
Greatly simplified the code for the random screenshot on the front page
Modified Paths:
--------------
web/trunk/include/screenshots.php
web/trunk/index.php
Modified: web/trunk/include/screenshots.php
===================================================================
--- web/trunk/include/screenshots.php 2007-06-04 22:34:24 UTC (rev 27091)
+++ web/trunk/include/screenshots.php 2007-06-04 22:50:42 UTC (rev 27092)
@@ -15,46 +15,6 @@
return implode("", file($file_root."/screenshots/scummvm_".$id.".txt"));
}
-function getScr($n) {
- global $categories;
- global $scrcatnums;
- $scr_cats = array();
- $cat0 = 0;
- $cat1 = 0;
- $cat2 = 0;
- $curnum = 0;
- $idx = 0;
-
- foreach ($categories as $i) {
- foreach ($i->_list as $j)
- array_push($scr_cats, $scrcatnums[$i->_catnum][$j['catnum']]);
- array_push($scr_cats, 0);
- }
-
-
- while ($curnum < $n) {
- if ($scr_cats[$idx] == 0) {
- $idx++;
- }
-
- if ($curnum + $scr_cats[$idx] <= $n) {
- $curnum += $scr_cats[$idx];
- $cat1++;
- $idx++;
- } else {
- $cat2 = $n - $curnum;
- $curnum = $n;
- }
- if ($cat1 >= count($categories[$cat0]->_list)) {
- $cat1 = 0;
- $cat0++;
- }
- }
-
- return "scummvm_{$categories[$cat0]->_catnum}_{$categories[$cat0]->_list[$cat1]['catnum']}_{$cat2}.jpg";
-}
-
-
// Grab list of images from screenshot dir
// and loop through them and add to $screenshots array
$screenshots = array();
Modified: web/trunk/index.php
===================================================================
--- web/trunk/index.php 2007-06-04 22:34:24 UTC (rev 27091)
+++ web/trunk/index.php 2007-06-04 22:50:42 UTC (rev 27092)
@@ -34,77 +34,21 @@
<script type="text/javascript">
<?php
- echo "scr_cats = [\n";
+ echo "screenshotIds = [\n";
+ echo '"' . join('", "', $screenshots) . '"' . "\n";
+ echo "];\n";
- foreach ($categories as $i) {
- echo "// {$i->_name}\n";
- echo " ";
- foreach ($i->_list as $j)
- echo $scrcatnums[$i->_catnum][$j['catnum']] . ", ";
- echo "0,\n";
- }
+ echo "var curScreenshotId = $randImg;\n";
- echo "-1];\n";
-
- echo "var i_jn = $randImg;\n";
-
- echo "scr_cats0 = [";
- foreach ($categories as $i) {
- echo '"'.$i->_catnum.'", ';
- }
- echo '""];'."\n";
-
- echo "scr_cats1 = new Array();\n";
-
- $c = 0;
- foreach ($categories as $i) {
- echo "scr_cats1[$c] = [";
- foreach ($i->_list as $j)
- echo '"'.$j['catnum'] . '", ';
- echo '"-1"];'."\n";
- $c++;
- }
-
?>
-function getScr(n) {
- cat0 = 0;
- cat1 = 0;
- cat2 = 0;
- curnum = 0;
- idx = 0;
+function scrshot_jn(n) {
+ curScreenshotId += n;
+ if (curScreenshotId >= screenshotIds.length) curScreenshotId = 0;
+ if (curScreenshotId < 0) curScreenshotId = screenshotIds.length-1;
- while (curnum < n) {
- if (scr_cats[idx] == 0) {
- idx++;
- }
-
- if (curnum + scr_cats[idx] <= n) {
- curnum += scr_cats[idx];
- cat1++;
- idx++;
- } else {
- cat2 = n - curnum;
- curnum = n;
- }
- if (scr_cats1[cat0][cat1] == "-1") {
- cat1 = 0;
- cat0++;
- }
- }
-
- return "scummvm_" + scr_cats0[cat0] + "_" + scr_cats1[cat0][cat1] + "_" + cat2;
+ document['curScreenshotId'].src = "./screenshots/scummvm_" + screenshotIds[curScreenshotId] + ".jpg";
}
-
-
-function scrshot_jn(x,n) {
- i_jn += n;
- if (i_jn >= x) i_jn = 0;
- if (i_jn < 0) i_jn = x-1;
-
-
- document['img_jn'].src = "./screenshots/" + getScr(i_jn) + ".jpg";
-}
</script>
<table class="intro" cellspacing="0" style="margin-bottom:8px;">
@@ -127,14 +71,14 @@
<tr><td>
<!-- We use a height of 483 instead of 480 to workaround something which
appears to be a bug in Mozilla? -->
- <a href="javascript:openWin('./screenshots/big'+getScr(i_jn)+'.png','Screenshot Viewer',640,483);"
+ <a href="javascript:openWin('./screenshots/bigscummvm_'+screenshotIds[curScreenshotId]+'.png','Screenshot Viewer',640,483);"
onMouseOver="window.status='Click to View Full Size Image';return true;"
onMouseOut="window.status='';return true;"><img
<?php
- echo 'src="./screenshots/'.getScr($randImg) . '" width="128" height="96"'."\n";
+ echo 'src="' . screenshot_thumb_path($screenshots[$randImg]) . '" width="128" height="96"'."\n";
?>
style="margin: 5px"
- name="img_jn" title="Click to view Full Size" alt="Random screenshot"></a>
+ name="curScreenshotId" title="Click to view Full Size" alt="Random screenshot"></a>
</td></tr>
</table>
</td></tr>
@@ -143,11 +87,11 @@
<td class="blc"></td>
<td class="nav-prev">
<?php
- echo '<a href="javascript:scrshot_jn('.count($screenshots).',-1);"><< previous</a> </td>';
+ echo '<a href="javascript:scrshot_jn(-1);"><< previous</a> </td>';
?>
<td class="nav-next">
<?php
- echo '<a href="javascript:scrshot_jn('.count($screenshots).',+1);">next >></a> </td>';
+ echo '<a href="javascript:scrshot_jn(+1);">next >></a> </td>';
?>
<td class="brc"></td>
</tr></table></td></tr>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list