jslint4java external jslint options are ignored - drupal-7

I'm using phing-drupal-template and have problem with jslinting. When using an external jslint with the --jslint option neither --browser option nor inline options are recognized like
/*jslint browser: true */
Any help would be much appreciated.
thx.
java -jar tools/jslint4java/jslint4java-2.0.5/jslint4java-2.0.5.jar
--browser
--predef "jQuery,$,Modernizr"
../sites/all/modules/custom/zendigital/js/frontpage.js
java -jar tools/jslint4java/jslint4java-2.0.5/jslint4java-2.0.5.jar
--jslint tools/jslint/fulljslint.js
--browser
--predef "jQuery,$,Modernizr"
../sites/all/modules/custom/zendigital/js/frontpage.js
jslint:...frontpage.js:59:40:'window' is not defined.
jslint:...frontpage.js:84:23:'window' is not defined.
jslint:...frontpage.js:104:36:'window' is not defined.
jslint:...frontpage.js:105:23:'window' is not defined.
jslint:...frontpage.js:180:25:'Modernizr' is not defined.
jslint:...frontpage.js:250:65:'window' is not defined.
jslint:...frontpage.js:250:86:'window' is not defined.
jslint:...frontpage.js:278:4:'jQuery' is not defined.

Does the behavior exist if you use the canonical jslint file? The one you linked branched over four years ago, hasn't been updated, and doesn't seem to respect window.
Compare this section in the canonical, current JSLint file, which does contain window:
https://github.com/douglascrockford/JSLint/blob/master/jslint.js#L343
// browser contains a set of global names that are commonly provided by a
// web browser environment.
browser = array_to_object([
'clearInterval', 'clearTimeout', 'document', 'event', 'FormData',
'frames', 'history', 'Image', 'localStorage', 'location', 'name',
'navigator', 'Option', 'parent', 'screen', 'sessionStorage',
'setInterval', 'setTimeout', 'Storage', 'window', 'XMLHttpRequest'
], false),
... with this from your version without any updates since Nov 2010, which doesn't contain window.
https://github.com/mikewest/JSLint/blob/master/fulljslint.js#L340
// browser contains a set of global names which are commonly provided by a
// web browser environment.
browser = {
addEventListener: false,
blur : false,
clearInterval : false,
clearTimeout : false,
close : false,
closed : false,
defaultStatus : false,
document : false,
event : false,
focus : false,
frames : false,
getComputedStyle: false,
history : false,
Image : false,
length : false,
location : false,
moveBy : false,
moveTo : false,
name : false,
navigator : false,
onbeforeunload : true,
onblur : true,
onerror : true,
onfocus : true,
onload : true,
onresize : true,
onunload : true,
open : false,
opener : false,
Option : false,
parent : false,
print : false,
removeEventListener: false,
resizeBy : false,
resizeTo : false,
screen : false,
scroll : false,
scrollBy : false,
scrollTo : false,
setInterval : false,
setTimeout : false,
status : false,
top : false,
XMLHttpRequest : false
},
I haven't looked into --predef "jQuery,$,Modernizr" at all.
I wouldn't suggest using a relatively anonymously branched JSLint file in general, much less one that's been sitting for four years. Which of its changes are you utilizing? It might be easier to add that to a more current JSLint version that respects window -- or use JSHint to get the same changes, if they're useful and there. (Or, as I'll usually argue, you can always just take JSLint's advice. ;^D)
Good luck. Let us know if the canonical version works.
EDIT: You might try the widget setting for your out-of-date version. That appears to have window in it:
// widget contains the global names which are provided to a Yahoo //
(fna Konfabulator) widget.
widget = {
alert : true,
animator : true,
appleScript : true,
beep : true,
//...
Window : true,
XMLDOM : true,
XMLHttpRequest : true,
yahooCheckLogin : true,
yahooLogin : true,
yahooLogout : true
},
That said, you're so non-standard at this point (widget is not a current JSLint directive and contains a lot of Konfabulator-related cruft), you really should ditch this fork and update to the current, canonical version. This is more a "for fun experiment" than a recommended fix.
You might also be able to just insert window: true, into the browser array, but, again, you're better off making the edits you need from that branch in a current version of JSLint, using JSHint if it has them, or simply following the current version of JSLint's advice.
That said, I can't replicate the issue you're seeing with a minimal JSLint wrapper with the old, branched version; it's letting tons of stuff through. Sorry, wish I could be more helpful.

Related

Backbone fetching a model: Parsing format in array of objects

My model in the server-side has an attribute which is an array of objects. In the client-side I'm trying to fetch that model in a backbone's model.
After fetching the model from my server I get this object:
{
round: 17,
username: bob,
football_bets: [
0: { one: true, x: false, two: false },
1: { one: false, x: false, two: true },
2: { one: true, x: true, two: false },
]
}
However, I was expecting something like this:
{
round: 17,
username: bob,
football_bets: [
{ one: true, x: false, two: false },
{ one: false, x: false, two: true },
{ one: true, x: true, two: false },
]
}
I understand that this is something related with how backbone parses the result of a fetch action, but I don't know how I should deal with.
Should I override the parse method of the model to get the result as I expect?
Should I use collections instead of trying to model everything inside of a single model?
Should I use some third-party library to deal with nested objects?
I really appreciate any kind of suggestions!
The format google-chrome console adopts for arrays is like the first array I've posted in the question. I was thinking that the numbers appears before the object itself was something that backbone it was adding when you perform a fetch action ... I was thinking this because when I debugged my code I had an error that said me it was not possible to access to an attribute.
After more debugging I realize that there was an indexation problem trying to access to an undefined element ... So the conclusion of all this mess is how the google-chrome console formats arrays! Hope this helps somebody ...

Disable File upload field in Extjs 3.0

I want to disable a file Upload field dynamically. Like I have a variable say isUploadAllowed. If this variable is true only then FileUpload field is enabled and user can click Browse button.. Else this button is disabled.. How to do it in ExtJs 3.0? I did find few examples but they were all of ExtJs 4.. I have tried:
FileUploadField.setDisabled(true);
but it's not working..
Here is my code, I want to disable it on reset button click!
var fileUploadField = new Ext.ux.form.FileUploadField({
id : 'fileUpload',
name : 'upLoadedFile',
fieldLabel : 'Supporting File(s)',
width : 410,
convertToUpperCase : false,
tabIndex : 9,
allowBlank : true
});
var requestForm = new Ext.form.FormPanel({
id : 'requestForm',
labelAlign : 'right',
labelWidth : 130,
buttonAlign : 'right',
frame : false,
split : false,
fileUpload : true,
autoHeight : true,
collapsible : false,
width : 635,
monitorValid : true,
border : false,
bodyStyle : 'text-align:left;padding:10 10 10 10',
// Layout the form fields here.
items : [{
layout : 'column',
border : false,
items : [{
layout : 'form',
bodyStyle : "text-align:left",
border : false,
items : [fileUploadField]
}],
buttons : [{
id : 'submitBtn',
text : 'Submit',
formBind : true,
handler : doSubmit,
type : 'submit',
scope : this
}, {
text : 'Reset',
formBind : false,
type : 'reset',
handler : function() {
// disable file upload field
}
}]
});
try this:
fileUploadField.disable();
sometimes it works better. Also check letter case
I made a hasty comment before which was deleted. I had the same issue with the upload functionality not being disabled, even though I disabled the field. I realized that was due to Plupload which was enabled on that field, so to disable the upload functionality of the uploader I disabled Plupload:
uploader.disableBrowse(true);
So check if don't have some similar plugin working as well...and disable that as well. Hope that this will help someone...it gave me some headaches.

Problems setting up Extensible calendar

I'm trying to set up an Extensible Calendar Pro in my ExtJs 4.1 application, but I still get a name is undefined error.
EDIT:
I solved the original problem, but directly went in another.
Updated code:
Ext.define('ZeuS.view.panels.ZeusMainPanel',{
extend: 'Ext.panel.Panel',
id : 'zeusMainPanel',
alias : 'widget.zeus',
requires : [
'Extensible.Extensible',
'Extensible.calendar.CalendarPanel',
'Extensible.calendar.data.MemoryEventStore',
'Extensible.calendar.data.EventModel',
'Extensible.calendar.view.*'
],
autoShow : true,
layout : 'border',
border : false,
initComponent : function(){
this.items = [{
/*
* Some other Ext Elements
*/
}, {
region : 'east',
xtype : 'extensible.calendarpanel',
name : 'zeus-calendar',
width : 500,
eventStore: Ext.create('Extensible.calendar.data.EventStore', {
data: Ext.create('Extensible.calendar.data.EventModel',{
StartDate: '2101-01-12 12:00:00',
EndDate: '2101-01-12 13:30:00',
Title: 'My cool event',
Notes: 'Some notes'
})
})
}
];
this.callParent(arguments);
}
});
Now it loads all classes correctly when the Extensible singleton is included, but nothing works. I just have a white screen and no functions in the controller or anywhere else are called. When I remove it from the requires list it comes up with this error: Extensible.log is not a function
Do I use the plugin at all right?
Any advice?
Extensible.log is defined on the Extensible singleton, so it should always be available if your dependencies and includes are set up correctly. You really should post in the Extensible forums with additonal details (Ext version, Extensible version, script include markup) as this is basically a product support question.
EDIT: By the way, there is no such thing as Extensible.Extensible, which might be part of your problem. Also you cannot use wildcard requires statements for non-Sencha classes. You might try getting a basic example working first before trying to create a complex layout with it.

Qooxdoo Access Dynamic Properties from another class?

I'm trying to access the selectedObs property of this class:
qx.Class.define("edd.view.ObsToggleContainer", {
extend : qx.ui.container.Composite,
type: "singleton",
properties : {
selectedObs : { check: "Array"}
},
construct : function() {...
from another class like this:
var ObsToggle = edd.view.ObsToggleContainer.getInstance();
console.log(ObsToggle.getSelectedObs());
But it seems to not know about what the values are presently set to. Am I doing something wrong or is there some logic that I'm not aware of?
Thanks for any help you can give!
I ended up just making a separate class as just a qx.core.Object and used that instead of a singleton Composite class and it seemed to do what I wanted to accomplish.
qx.Class.define("edd.data.DataStore", {
properties : {
checkedObs: {
init: [false, true, true, false, false, false, false, false, true, false, false, false],
check: "Array"
}
},
extend : qx.core.Object,
type: "singleton",
construct : function() {
var thisClass = this;
},
members :{
}
});
So now, this code properly works:
var dataStore = edd.data.DataStore.getInstance();
var init_checked = dataStore.getCheckedObs();
Uhm. There's something else here. Your initial class definition and the one from your own answer are not far apart, as far as the property is concerned. Maybe in the rest of your initial class, or in the code using it, was something awry?!
Have a look at this Playground sample, which uses your initial class definition. You have to open the "Log" pane, in order to see the output. Works like a charm.
It would be very interesting if you could change this sample, and tweak it until it reproduces your problem?!

How to replace some text with something in extJS?

Have question: I have in my database some filed with text (i submitted it through form).
Then I have extJS Panel where my data. I made, when i click on soem field, appears message Box with plain text only (But in my database this text is very beautiful with ul's, with /br/'s and so son) :( Its ok, but my eyes can't read this normally! How to avoid this? Maybe in extJS exists some replace params? replace('/n/', '//br/').. or?
my grid
var Grid = new Ext.grid.GridPanel({
id : 'grid',
store : store,
frame : true,
autoScroll :true,
columns : my_columns,
stripeRows : true,
title :'Answers',
iconCls : 'arrow',
listeners: {
celldblclick: function(Grid, rowIndex, cellIndex, e){
var rec = Grid.getStore().getAt(rowIndex);
var columnName = Grid.getColumnModel().getDataIndex(cellIndex);
Ext.Msg.show({
title : 'Message',
msg : rec.get(columnName),
modal : true,
autoWidth : true,
maxHeight : 500,
autoScroll : true,
closable : true,
resizable : false,
draggable : false,
maxWidth : 500,
buttons : Ext.Msg.OK
});
Ext.Msg.getDialog().dd.lock();
}
}
});
Hard to understand your problem - you talk about a panel, then you post an example with grid.
Anyway... maybe the problem is that the message dialog window has preventBodyReset: false by default, which means that the default browser styles for <ul> and many other elements are reset.
Unfortunately there is no easy way to set preventBodyReset: true for the message box window. If you want it for all message boxes, then maybe you can achieve something with code like that:
Ext.MessageBox.getDialog().getEl().addClass('x-panel-reset');
If you don't want to apply it globally, then you probably have to create your own message window.
try using the escape function.
So something like:
Ext.Msg.show({
title : 'Message',
msg : escape(rec.get(columnName)),
modal : true,
autoWidth : true,
maxHeight : 500,
autoScroll : true,
closable : true,
resizable : false,
draggable : false,
maxWidth : 500,
buttons : Ext.Msg.OK
});

Resources