[Seaside] Pretty print Javascript
Bart Veenstra
bart.veenstra at gmail.com
Sat Jun 5 07:41:34 UTC 2010
Hi,
I am currently working on some elaborate jquery plugin projects with a lot
of custom javascript generation. But i find it very difficult to check if
the generated javascript is correct in firebug, because it appears all on
one line.
Is there a special javascript stream which does all the formatting?
For instance, i am currnetly porting the squak jqgrid plugin to visual works
and I am adding the editing functionality to it.
I end up with strings like this:
/*<![CDATA[*/function
onLoad(){$("#grid").jqGrid({datatype:"json",url:"/jqgrid?_s=djvP-IcmhCV41XX9&_k=F3dJxyNWd7_KXQ8C&1",editurl:"/jqgrid?_s=djvP-IcmhCV41XX9&_k=F3dJxyNWd7_KXQ8C&2",viewrecords:true,height:"100%",onSelectRow:function(id){if(id
&& id!==lastsel){ $("#grid").jqGrid("restoreRow",lastsel);
$("#grid").jqGrid("editRow",id,true); lastsel=id;} },colNames:["Inv
No.","Date","Client","Amount","Tax","Total","Notes"],colModel:[{index:"id",name:"id",width:70},{index:"invdate",name:"invdate",editable:true,width:110},{index:"name",name:"name",editable:true,width:100},{index:"amount",name:"amount",align:"right",editable:true,width:100},{index:"tax",name:"tax",align:"right",editable:true,width:80},{index:"total",name:"total",align:"right",editable:true,width:80},{index:"note",name:"note",editable:true,sortable:false,width:150}],altRows:true,rowNum:10,rowList:[10,20,40,100],pager:"pager",sortname:"id",caption:"JSON
Example"})}/*]]>*/
</script>
</body>
But I would like to end up with something like this (generated by
http://jsbeautifier.org/)
function onLoad() {
$("#grid").jqGrid({
datatype: "json",
url: "/jqgrid?_s=djvP-IcmhCV41XX9&_k=F3dJxyNWd7_KXQ8C&1",
editurl: "/jqgrid?_s=djvP-IcmhCV41XX9&_k=F3dJxyNWd7_KXQ8C&2",
viewrecords: true,
height: "100%",
onSelectRow: function (id) {
if (id && id !== lastsel) {
$("#grid").jqGrid("restoreRow", lastsel);
$("#grid").jqGrid("editRow", id, true);
lastsel = id;
}
},
colNames: ["Inv No.", "Date", "Client", "Amount", "Tax", "Total",
"Notes"],
colModel: [{
index: "id",
name: "id",
width: 70
},
{
index: "invdate",
name: "invdate",
editable: true,
width: 110
},
{
index: "name",
name: "name",
editable: true,
width: 100
},
{
index: "amount",
name: "amount",
align: "right",
editable: true,
width: 100
},
{
index: "tax",
name: "tax",
align: "right",
editable: true,
width: 80
},
{
index: "total",
name: "total",
align: "right",
editable: true,
width: 80
},
{
index: "note",
name: "note",
editable: true,
sortable: false,
width: 150
}],
altRows: true,
rowNum: 10,
rowList: [10, 20, 40, 100],
pager: "pager",
sortname: "id",
caption: "JSON Example"
})
}
Is that possible?
I could add the extra tab's and linefeeds to the stream functions in the
JSStream but I am hoping that there might already be an implementation that
beautifies javascript (Like the WAPrettyPrintDocument used by the Halo's
(would be great if that could be the default writer as well ;-) )).
Regards,
Bart Veenstra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100605/d66a4cf6/attachment.htm
More information about the seaside
mailing list