[rkward-cvs] SF.net SVN: rkward:[2755] trunk/rkward/rkward/plugins/x11device

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Feb 25 21:29:13 UTC 2010


Revision: 2755
          http://rkward.svn.sourceforge.net/rkward/?rev=2755&view=rev
Author:   tfry
Date:     2010-02-25 21:29:09 +0000 (Thu, 25 Feb 2010)

Log Message:
-----------
Convert x11device plugins to JS

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/x11device/export.js
    trunk/rkward/rkward/plugins/x11device/export.xml
    trunk/rkward/rkward/plugins/x11device/grid.js
    trunk/rkward/rkward/plugins/x11device/grid.xml

Removed Paths:
-------------
    trunk/rkward/rkward/plugins/x11device/export.php
    trunk/rkward/rkward/plugins/x11device/grid.php

Modified: trunk/rkward/rkward/plugins/x11device/export.js
===================================================================
--- trunk/rkward/rkward/plugins/x11device/export.js	2010-02-25 21:04:32 UTC (rev 2754)
+++ trunk/rkward/rkward/plugins/x11device/export.js	2010-02-25 21:29:09 UTC (rev 2755)
@@ -1,57 +1,12 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
-// globals
-var undefined;
-
-
 function calculate () {
-	var type = "";
-	var file = "";
+	var type = getValue ("format");
+	var file = getValue ("file");
+
 	var gstype = "";
 	var jpegpng = "";
 	var eps = "";
 	var ext = "";
-	var options = "";
-	var autores = "";
-	var resolution = "";
-	var autoW = "";
-	var autoH = "";
-	var paper = "";
-	var pagecentre = "";
-	var pshoriz = "";
-	var family = "";
-	var enc = "";
-	type = getValue ("format");
-	file = getValue ("file");
-
-	if (type == "gs" ) {
+	if (type == "gs") {
 		gstype = getValue ("gsformat");
 		if (gstype == "other") gstype = getValue ("gs_specifiedformat");
 	} else {
@@ -62,24 +17,24 @@
 		// If not, add the appropriate extension.
 		if (getValue ("autoextension")) {
 			if (type == "jpeg") {
-				if (!( ereg("\.jpeg$",file)|ereg("\.jpg$",file) )) file += ".jpg";
-			}
-			elseif (type == "postscript") {
+				if (file.search (/\.jpg$/i) < 0) file += ".jpg";
+			} else if (type == "postscript") {
 				if (eps) {
-					if (!( ereg("\.ps$",file)|ereg("\.eps$",file) )) file += ".eps";
+					if (file.search (/\.e?ps$/i) < 0) file += ".eps";
 				} else {
-					if (!( ereg("\.ps$",file)|ereg("\.eps$",file) )) file += ".ps";
+					if (file.search (/\.e?ps$/i) < 0) file += ".ps";
 				}
+			} else {
+				var regexp = new RegExp ("\." + type + "$", "i");
+				if (file.search (regexp) < 0) file += "." + type;
 			}
-			else {
-				ext = "." + type;
-				if (!ereg(ext+"$",file)) file += ext;
-			}
 		}
 	}
-	options = "";
+	var options = "";
 	if ((type == "postscript") && eps) options += ", onefile=FALSE";
 
+	var autores = "";
+	var resolution = "";
 	// set $resolution appropriately:
 	if (jpegpng || (type == "gs")) {
 		autores = getValue ("autores");
@@ -89,44 +44,46 @@
 		}	else resolution = getValue ("resolution");
 	}
 
-	autoW = getValue ("autowidth");
-	autoH = getValue ("autoheight");
+	var autoW = getValue ("autowidth");
+	var autoH = getValue ("autoheight");
 
 	// jpeg()/png() need at least one of width/height. For jpeg()/png() the width/height parameter (in pixels)
 	// is calculated using width/height (in inches) times the resolution. For postscript()/pdf() $resolution is set to 1.
-	if (jpegpng && autoW && autoH) options += ", width=par(\"din\")[1]*" + resolution;
-	elseif (jpegpng) {
+	if (jpegpng && autoW && autoH) {
+		options += ", width=par(\"din\")[1]*" + resolution;
+	} else if (jpegpng) {
 		if (!autoW) options += ", width=" + round(getValue ("width")*resolution);
 		if (!autoH) options += ", height=" + round(getValue ("height")*resolution);
-	}
-	else {
+	} else {
 		if (!autoW) options += ", width=" + getValue ("width");
 		if (!autoH) options += ", height=" + getValue ("height");
 	}
 
 	// pointsize, resolution and quality parameters:
 	if (!getValue ("autopointsize")) options += ", pointsize=" + getValue ("pointsize");
-	if ((jpegpng && !autores)	|| (type == "gs"))  options += ", res=" + resolution;
+	if ((jpegpng && !autores) || (type == "gs")) options += ", res=" + resolution;
 	if ((type == "jpeg") && (!getValue ("autoquality"))) options += ", quality=" + getValue ("quality");
 
 	// For ps/pdf: page, pagecentre, horizontal, family, encoding and title parameters:
 	if (!jpegpng) {
+		var paper = "";
 		if (!(eps)) paper = getValue ("paper");
 		else paper = "special";
-		if (!empty (paper)) options += ", paper=" + "\"" + paper + "\"";
+		if (paper != "") options += ", paper=" + "\"" + paper + "\"";
 
-		pagecentre = getValue ("pagecentre");
+		var pagecentre = getValue ("pagecentre");
 		if (!pagecentre) options += ", pagecentre=FALSE";
 
+		var pshoriz = "";
 		if (!eps) pshoriz = getValue ("ps_horiz");
 		else pshoriz = false;
 		if (!pshoriz) options += ", horizontal=FALSE";
 
-		family = getValue ("family");
-		if (!empty(family)) options += ", family=" + "\"" + family + "\"";
+		var family = getValue ("family");
+		if (family != "") options += ", family=" + "\"" + family + "\"";
 
-		enc = getValue ("encoding");
-		if (!empty(enc)) options += ", encoding=" + "\"" + enc + "\"";
+		var enc = getValue ("encoding");
+		if (enc != "") options += ", encoding=" + "\"" + enc + "\"";
 
 		if (!getValue("autotitle")) options += ", title=" + "\"" + getValue("title") + "\"";
 	}

Deleted: trunk/rkward/rkward/plugins/x11device/export.php
===================================================================
--- trunk/rkward/rkward/plugins/x11device/export.php	2010-02-25 21:04:32 UTC (rev 2754)
+++ trunk/rkward/rkward/plugins/x11device/export.php	2010-02-25 21:29:09 UTC (rev 2755)
@@ -1,95 +0,0 @@
-<?php
-function preprocess () {
-}
-
-function calculate () {
-	$type = getRK_val ("format");
-	$file = getRK_val ("file");
-
-	if ($type == "gs" ) {
-		$gstype = getRK_val ("gsformat");
-		if ($gstype == "other") $gstype = getRK_val ("gs_specifiedformat");
-	} else {
-		$jpegpng = (($type == "jpeg") | ($type == "png"));
-		$eps = ($type == "postscript") && (getRK_val ("formateps"));
-
-		// Does the filename end with .ps/.eps or .pdf or .png or .jpeg/.jpg?
-		// If not, add the appropriate extension.
-		if (getRK_val ("autoextension")) {
-			if ($type == "jpeg") {
-				if (!( ereg("\.jpeg$",$file)|ereg("\.jpg$",$file) )) $file .= ".jpg";
-			} elseif ($type == "postscript") {
-				if ($eps) {
-					if (!( ereg("\.ps$",$file)|ereg("\.eps$",$file) )) $file .= ".eps";
-				} else {
-					if (!( ereg("\.ps$",$file)|ereg("\.eps$",$file) )) $file .= ".ps";
-				}
-			} else {
-				$ext = "." . $type;
-				if (!ereg($ext."$",$file)) $file .= $ext;
-			}
-		}
-	}
-	$options = "";
-	if (($type == "postscript") && $eps) $options .= ", onefile=FALSE";
-
-	// set $resolution appropriately:
-	if ($jpegpng || ($type == "gs")) {
-		$autores = getRK_val ("autores");
-		if ($autores) {
-			if ($jpegpng) $resolution = 96;
-			else $resolution = 72;
-		}	else $resolution = getRK_val ("resolution");
-	}
-
-	$autoW = getRK_val ("autowidth");	$autoH = getRK_val ("autoheight");
-
-	// jpeg()/png() need at least one of width/height. For jpeg()/png() the width/height parameter (in pixels)
-	// is calculated using width/height (in inches) times the resolution. For postscript()/pdf() $resolution is set to 1.
-	if ($jpegpng && $autoW && $autoH) $options .= ", width=par(\"din\")[1]*" . $resolution;
-	elseif ($jpegpng) {
-		if(!$autoW) $options .= ", width=" . round(getRK_val ("width")*$resolution);
-		if(!$autoH) $options .= ", height=" . round(getRK_val ("height")*$resolution);
-	}	else {
-		if(!$autoW) $options .= ", width=" . getRK_val ("width");
-		if(!$autoH) $options .= ", height=" . getRK_val ("height");
-	}
-
-	// pointsize, resolution and quality parameters:
-	if (!getRK_val ("autopointsize")) $options .= ", pointsize=" . getRK_val ("pointsize");
-	if (($jpegpng && !$autores)	|| ($type == "gs"))  $options .= ", res=" . $resolution;
-	if (($type == "jpeg") && (!getRK_val ("autoquality"))) $options .= ", quality=" . getRK_val ("quality");
-
-	// For ps/pdf: page, pagecentre, horizontal, family, encoding and title parameters:
-	if (!$jpegpng) {
-		if (!($eps)) $paper = getRK_val ("paper");
-		else $paper = "special";
-		if (!empty ($paper)) $options .= ", paper=" . "\"" . $paper . "\"";
-
-		$pagecentre = getRK_val ("pagecentre");
-		if (!$pagecentre) $options .= ", pagecentre=FALSE";
-
-		if (!$eps) $pshoriz = getRK_val ("ps_horiz");
-		else $pshoriz = false;
-		if (!$pshoriz) $options .= ", horizontal=FALSE";
-
-		$family = getRK_val ("family");
-		if (!empty($family)) $options .= ", family=" . "\"" . $family . "\"";
-
-		$enc = getRK_val ("encoding");
-		if (!empty($enc)) $options .= ", encoding=" . "\"" . $enc . "\"";
-
-		if (!getRK_val("autotitle")) $options .= ", title=" . "\"" . getRK_val("title") . "\"";
-	}
-?>
-dev.set (<? getRK ("devnum"); ?>)
-<? if ($type == "gs") {?>
-dev2bitmap ("<? echo($file); ?>", type="<? echo ($gstype); ?>"<? echo ($options); ?>);
-<? } else {?>
-dev.print (device=<? echo ($type); ?>, file="<? echo ($file); ?>"<? echo ($options); ?>);
-<? }
-}
-
-function printout () {
-}
-?>
\ No newline at end of file

Modified: trunk/rkward/rkward/plugins/x11device/export.xml
===================================================================
--- trunk/rkward/rkward/plugins/x11device/export.xml	2010-02-25 21:04:32 UTC (rev 2754)
+++ trunk/rkward/rkward/plugins/x11device/export.xml	2010-02-25 21:29:09 UTC (rev 2755)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-	<code file="export.php" />
+	<code file="export.js" />
 	<help file="export.rkh" />
 	<logic>
 		<external id="devnum"/>

Modified: trunk/rkward/rkward/plugins/x11device/grid.js
===================================================================
--- trunk/rkward/rkward/plugins/x11device/grid.js	2010-02-25 21:04:32 UTC (rev 2754)
+++ trunk/rkward/rkward/plugins/x11device/grid.js	2010-02-25 21:29:09 UTC (rev 2755)
@@ -1,34 +1,17 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Warning: '$' inside '"'-delimited string. This might be a variable name. Please check by hand!
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
-// globals
-var undefined;
-
 function preprocess () {
 	if (getValue ("is_embed")) {
 		echo ('dev.set (' + getValue ("devnum") + ')\n');
 	}
 }
 
-
 function printout () {
-	var nx = "";
 	var gridoptions = "";
-	var ny = "";
-	var lty = "";
-	nx = getValue ("nx");
+
+	var nx = getValue ("nx");
 	if (nx == "other") gridoptions = 'nx=' + getValue ("nx_cells");
 	else gridoptions = 'nx=' + nx;
 
-	ny = getValue ("ny");
+	var ny = getValue ("ny");
 	if (ny == "other") gridoptions += ', ny=' + getValue ("ny_cells");
 	else gridoptions += ', ny=' + ny;
 
@@ -36,8 +19,8 @@
 
 	if (getValue("custlwd")) gridoptions += ', lwd=' + round(getValue ("lwd"),1);
 
-	lty = getValue("linetype");
-	if (lty != "") gridoptions += ", lty=\"{$lty}\"";
+	var lty = getValue("linetype");
+	if (lty != "") gridoptions += ", lty=\"" + lty + "\"";
 
 	if (!getValue("equilogs")) gridoptions += ', equilogs=FALSE';
 

Deleted: trunk/rkward/rkward/plugins/x11device/grid.php
===================================================================
--- trunk/rkward/rkward/plugins/x11device/grid.php	2010-02-25 21:04:32 UTC (rev 2754)
+++ trunk/rkward/rkward/plugins/x11device/grid.php	2010-02-25 21:29:09 UTC (rev 2755)
@@ -1,32 +0,0 @@
-<?php
-function preprocess () {
-	if (getRK_val ("is_embed")) { ?>
-dev.set (<? getRK ("devnum"); ?>)
-<?	}
-}
-
-function calculate () {
-}
-
-function printout () {
-	$nx = getRK_val ("nx");
-	if ($nx == "other") $gridoptions = 'nx=' . getRK_val ("nx_cells");
-	else $gridoptions = 'nx=' . $nx;
-
-	$ny = getRK_val ("ny");
-	if ($ny == "other") $gridoptions .= ', ny=' . getRK_val ("ny_cells");
-	else $gridoptions .= ', ny=' . $ny;
-
-	$gridoptions .= getRK_val ("col.code.printout");
-
-	if (getRK_val("custlwd")) $gridoptions .= ', lwd=' . round(getRK_val ("lwd"),1);
-
-	$lty = getRK_val("linetype");
-	if ($lty != "") $gridoptions .= ", lty=\"{$lty}\"";
-
-	if (!getRK_val("equilogs")) $gridoptions .= ', equilogs=FALSE';
-?>
-grid(<? echo ($gridoptions); ?>);
-<?
-}
-?>
\ No newline at end of file

Modified: trunk/rkward/rkward/plugins/x11device/grid.xml
===================================================================
--- trunk/rkward/rkward/plugins/x11device/grid.xml	2010-02-25 21:04:32 UTC (rev 2754)
+++ trunk/rkward/rkward/plugins/x11device/grid.xml	2010-02-25 21:29:09 UTC (rev 2755)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-	<code file="grid.php" />
+	<code file="grid.js" />
 	<help file="grid.rkh" />
 	<logic>
 		<external id="devnum"/>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list