mirror of https://gitee.com/bigwinds/arangodb
added dolphin test suite (incl. jslint) for webinterface
This commit is contained in:
parent
a10c802c07
commit
771b6873e5
|
@ -1,3 +1,7 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, arangoCollection, $, arangoHelper, data */
|
||||
/*global arrayContainer:true, SliderInstance:true, DomObjects:true */
|
||||
|
||||
arangoHelper = {
|
||||
CollectionTypes: {},
|
||||
systemAttributes: function () {
|
||||
|
@ -5,8 +9,6 @@ arangoHelper = {
|
|||
'_id' : true,
|
||||
'_rev' : true,
|
||||
'_key' : true,
|
||||
'_from' : true,
|
||||
'_to' : true,
|
||||
'_bidirectional' : true,
|
||||
'_vertices' : true,
|
||||
'_from' : true,
|
||||
|
@ -43,25 +45,26 @@ arangoHelper = {
|
|||
},
|
||||
|
||||
collectionApiType: function (identifier) {
|
||||
if (this.CollectionTypes[identifier] == undefined) {
|
||||
this.CollectionTypes[identifier] = window.arangoDocumentStore.getCollectionInfo(identifier).type;
|
||||
if (this.CollectionTypes[identifier] === undefined) {
|
||||
this.CollectionTypes[identifier] = window.arangoDocumentStore
|
||||
.getCollectionInfo(identifier).type;
|
||||
}
|
||||
|
||||
if (this.CollectionTypes[identifier] == 3) {
|
||||
if (this.CollectionTypes[identifier] === 3) {
|
||||
return "edge";
|
||||
}
|
||||
return "document";
|
||||
},
|
||||
|
||||
collectionType: function (val) {
|
||||
if (! val || val.name == '') {
|
||||
if (! val || val.name === '') {
|
||||
return "-";
|
||||
}
|
||||
var type;
|
||||
if (val.type == 2) {
|
||||
if (val.type === 2) {
|
||||
type = "document";
|
||||
}
|
||||
else if (val.type == 3) {
|
||||
else if (val.type === 3) {
|
||||
type = "edge";
|
||||
}
|
||||
else {
|
||||
|
@ -73,6 +76,104 @@ arangoHelper = {
|
|||
}
|
||||
|
||||
return type;
|
||||
},
|
||||
|
||||
FormatJSON: function (oData, sIndent) {
|
||||
var self = this;
|
||||
var sHTML, iCount;
|
||||
if (sIndent === undefined) {
|
||||
sIndent = "";
|
||||
}
|
||||
var sIndentStyle = " ";
|
||||
var sDataType = arangoHelper.RealTypeOf(oData);
|
||||
|
||||
if (sDataType === "array") {
|
||||
if (oData.length === 0) {
|
||||
return "[]";
|
||||
}
|
||||
sHTML = "[";
|
||||
} else {
|
||||
iCount = 0;
|
||||
$.each(oData, function() {
|
||||
iCount++;
|
||||
return;
|
||||
});
|
||||
if (iCount === 0) { // object is empty
|
||||
return "{}";
|
||||
}
|
||||
sHTML = "{";
|
||||
}
|
||||
|
||||
iCount = 0;
|
||||
$.each(oData, function(sKey, vValue) {
|
||||
if (iCount > 0) {
|
||||
sHTML += ",";
|
||||
}
|
||||
if (sDataType === "array") {
|
||||
sHTML += ("\n" + sIndent + sIndentStyle);
|
||||
} else {
|
||||
sHTML += ("\n" + sIndent + sIndentStyle + JSON.stringify(sKey) + ": ");
|
||||
}
|
||||
|
||||
// display relevant data type
|
||||
switch (arangoHelper.RealTypeOf(vValue)) {
|
||||
case "array":
|
||||
case "object":
|
||||
sHTML += self.FormatJSON(vValue, (sIndent + sIndentStyle));
|
||||
break;
|
||||
case "boolean":
|
||||
case "number":
|
||||
sHTML += vValue.toString();
|
||||
break;
|
||||
case "null":
|
||||
sHTML += "null";
|
||||
break;
|
||||
case "string":
|
||||
sHTML += "\"" + vValue.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"";
|
||||
break;
|
||||
default:
|
||||
sHTML += ("TYPEOF: " + typeof vValue);
|
||||
}
|
||||
// loop
|
||||
iCount++;
|
||||
});
|
||||
|
||||
// close object
|
||||
if (sDataType === "array") {
|
||||
sHTML += ("\n" + sIndent + "]");
|
||||
} else {
|
||||
sHTML += ("\n" + sIndent + "}");
|
||||
}
|
||||
|
||||
// return
|
||||
return sHTML;
|
||||
},
|
||||
|
||||
RealTypeOf: function (v) {
|
||||
if (typeof v === "object") {
|
||||
if (v === null) {
|
||||
return "null";
|
||||
}
|
||||
var array = [];
|
||||
if (v.constructor === array.constructor) {
|
||||
return "array";
|
||||
}
|
||||
var date = new Date();
|
||||
if (v.constructor === date.constructor) {
|
||||
return "date";
|
||||
}
|
||||
var regexp = new RegExp();
|
||||
if (v.constructor === regexp.constructor) {
|
||||
return "regex";
|
||||
}
|
||||
return "object";
|
||||
}
|
||||
return typeof v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports */
|
||||
/*global require, exports, Backbone, window, arangoCollection, $, arangoHelper, data */
|
||||
|
||||
window.arangoCollections = Backbone.Collection.extend({
|
||||
url: '/_api/collection',
|
||||
|
||||
|
@ -17,38 +18,42 @@ window.arangoCollections = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
translateStatus : function (status) {
|
||||
if (status == 0) {
|
||||
return 'corrupted';
|
||||
var returnString;
|
||||
if (status === 0) {
|
||||
returnString = 'corrupted';
|
||||
}
|
||||
if (status == 1) {
|
||||
return 'new born collection';
|
||||
if (status === 1) {
|
||||
returnString = 'new born collection';
|
||||
}
|
||||
else if (status == 2) {
|
||||
return 'unloaded';
|
||||
else if (status === 2) {
|
||||
returnString = 'unloaded';
|
||||
}
|
||||
else if (status == 3) {
|
||||
return 'loaded';
|
||||
else if (status === 3) {
|
||||
returnString = 'loaded';
|
||||
}
|
||||
else if (status == 4) {
|
||||
return 'in the process of being unloaded';
|
||||
else if (status === 4) {
|
||||
returnString = 'in the process of being unloaded';
|
||||
}
|
||||
else if (status == 5) {
|
||||
return 'deleted';
|
||||
else if (status === 5) {
|
||||
returnString = 'deleted';
|
||||
}
|
||||
return returnString;
|
||||
},
|
||||
translateTypePicture : function (type) {
|
||||
var returnString;
|
||||
if (type === 'document') {
|
||||
return "img/icon_document.png";
|
||||
returnString = "img/icon_document.png";
|
||||
}
|
||||
else if (type === 'edge') {
|
||||
return "img/icon_node.png";
|
||||
returnString = "img/icon_node.png";
|
||||
}
|
||||
else if (type === 'unknown') {
|
||||
return "img/icon_unknown.png";
|
||||
returnString = "img/icon_unknown.png";
|
||||
}
|
||||
else {
|
||||
return "img/icon_arango.png";
|
||||
returnString = "img/icon_arango.png";
|
||||
}
|
||||
return returnString;
|
||||
},
|
||||
parse: function(response) {
|
||||
var that = this;
|
||||
|
@ -137,7 +142,7 @@ window.arangoCollections = Backbone.Collection.extend({
|
|||
lValue = l.get('name').toLowerCase();
|
||||
rValue = r.get('name').toLowerCase();
|
||||
}
|
||||
if (lValue != rValue) {
|
||||
if (lValue !== rValue) {
|
||||
return options.sortOrder * (lValue < rValue ? -1 : 1);
|
||||
}
|
||||
return 0;
|
||||
|
@ -173,7 +178,14 @@ window.arangoCollections = Backbone.Collection.extend({
|
|||
cache: false,
|
||||
type: "POST",
|
||||
url: "/_api/collection",
|
||||
data: '{"name":' + JSON.stringify(collName) + ',"waitForSync":' + JSON.stringify(wfs) + ',"isSystem":' + JSON.stringify(isSystem) + journalSizeString + ',"type":' + collType + '}',
|
||||
data:
|
||||
'{"name":' + JSON.stringify(collName) +
|
||||
',"waitForSync":'+
|
||||
JSON.stringify(wfs)+
|
||||
',"isSystem":'+
|
||||
JSON.stringify(isSystem)+
|
||||
',"type":'+
|
||||
collType + '}',
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
async: false,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, arangoDocument, $, arangoHelper */
|
||||
window.arangoDocument = Backbone.Collection.extend({
|
||||
url: '/_api/document/',
|
||||
model: arangoDocument,
|
||||
|
@ -139,8 +141,6 @@ window.arangoDocument = Backbone.Collection.extend({
|
|||
processData: false,
|
||||
success: function(data) {
|
||||
window.arangoDocumentStore.add(data);
|
||||
//TODO: move this to view!
|
||||
//window.documentSourceView.fillSourceBox();
|
||||
result = true;
|
||||
},
|
||||
error: function(data) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, window */
|
||||
/*global require, exports, window, Backbone, arangoDocument, $*/
|
||||
|
||||
window.arangoDocuments = Backbone.Collection.extend({
|
||||
currentPage: 1,
|
||||
|
@ -12,28 +12,28 @@ window.arangoDocuments = Backbone.Collection.extend({
|
|||
url: '/_api/documents',
|
||||
model: arangoDocument,
|
||||
getFirstDocuments: function () {
|
||||
if (this.currentPage != 1) {
|
||||
if (this.currentPage !== 1) {
|
||||
var link = window.location.hash.split("/");
|
||||
window.location.hash = link[0]+"/"+link[1]+"/"+link[2]+"/1";
|
||||
}
|
||||
},
|
||||
getLastDocuments: function () {
|
||||
if (this.currentPage != this.totalPages) {
|
||||
if (this.currentPage !== this.totalPages) {
|
||||
var link = window.location.hash.split("/");
|
||||
window.location.hash = link[0]+"/"+link[1]+"/"+link[2]+"/"+this.totalPages;
|
||||
}
|
||||
},
|
||||
getPrevDocuments: function () {
|
||||
if (this.currentPage != 1) {
|
||||
if (this.currentPage !== 1) {
|
||||
var link = window.location.hash.split("/");
|
||||
var page = parseInt(this.currentPage) - 1;
|
||||
var page = parseInt(this.currentPage, null) - 1;
|
||||
window.location.hash = link[0]+"/"+link[1]+"/"+link[2]+"/"+page;
|
||||
}
|
||||
},
|
||||
getNextDocuments: function () {
|
||||
if (this.currentPage != this.totalPages) {
|
||||
if (this.currentPage !== this.totalPages) {
|
||||
var link = window.location.hash.split("/");
|
||||
var page = parseInt(this.currentPage) + 1;
|
||||
var page = parseInt(this.currentPage, null) + 1;
|
||||
window.location.hash = link[0]+"/"+link[1]+"/"+link[2]+"/"+page;
|
||||
}
|
||||
},
|
||||
|
@ -58,11 +58,10 @@ window.arangoDocuments = Backbone.Collection.extend({
|
|||
});
|
||||
|
||||
|
||||
if (isNaN(this.currentPage) || this.currentPage == undefined || this.currentPage < 1) {
|
||||
if (isNaN(this.currentPage) || this.currentPage === undefined || this.currentPage < 1) {
|
||||
this.currentPage = 1;
|
||||
}
|
||||
|
||||
if (this.totalPages == 0) {
|
||||
if (this.totalPages === 0) {
|
||||
this.totalPages = 1;
|
||||
}
|
||||
|
||||
|
@ -73,11 +72,13 @@ window.arangoDocuments = Backbone.Collection.extend({
|
|||
type: 'PUT',
|
||||
async: false,
|
||||
url: '/_api/simple/all/',
|
||||
data: '{"collection":"' + this.collectionID + '","skip":' + this.offset + ',"limit":' + String(this.documentsPerPage) + '}',
|
||||
data:
|
||||
'{"collection":"' + this.collectionID + '","skip":'+
|
||||
this.offset + ',"limit":' + String(this.documentsPerPage) + '}',
|
||||
contentType: "application/json",
|
||||
success: function(data) {
|
||||
self.clearDocuments();
|
||||
if (self.documentsCount != 0) {
|
||||
if (self.documentsCount !== 0) {
|
||||
$.each(data.result, function(k, v) {
|
||||
window.arangoDocumentsStore.add({
|
||||
"id": v._id,
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog*/
|
||||
|
||||
window.arangoLogs = Backbone.Collection.extend({
|
||||
url: '/_admin/log?upto=4&size=10&offset=0',
|
||||
parse: function(response) {
|
||||
|
@ -9,7 +12,7 @@ window.arangoLogs = Backbone.Collection.extend({
|
|||
"lid":response.lid[i],
|
||||
"text":response.text[i],
|
||||
"timestamp":response.timestamp[i],
|
||||
"totalAmount":response.totalAmount,
|
||||
"totalAmount":response.totalAmount
|
||||
});
|
||||
i++;
|
||||
});
|
||||
|
@ -35,9 +38,9 @@ window.arangoLogs = Backbone.Collection.extend({
|
|||
offset = 0;
|
||||
}
|
||||
|
||||
loglevel = this.showLogLevel(table);
|
||||
var loglevel = this.showLogLevel(table);
|
||||
var url = "";
|
||||
if (loglevel == 5) {
|
||||
if (loglevel === 5) {
|
||||
url = "/_admin/log?upto=4&size="+size+"&offset="+offset;
|
||||
}
|
||||
else {
|
||||
|
@ -61,10 +64,22 @@ window.arangoLogs = Backbone.Collection.extend({
|
|||
},
|
||||
showLogLevel: function (tableid) {
|
||||
tableid = '#'+tableid;
|
||||
if (tableid == "#critTableID") { return 1 ;}
|
||||
else if (tableid == "#warnTableID") { return 2 ;}
|
||||
else if (tableid == "#infoTableID") { return 3 ;}
|
||||
else if (tableid == "#debugTableID") { return 4 ;}
|
||||
else if (tableid == "#logTableID") { return 5 ;}
|
||||
var returnVal = 0;
|
||||
if (tableid === "#critTableID") {
|
||||
returnVal = 1;
|
||||
}
|
||||
else if (tableid === "#warnTableID") {
|
||||
returnVal = 2;
|
||||
}
|
||||
else if (tableid === "#infoTableID") {
|
||||
returnVal = 3;
|
||||
}
|
||||
else if (tableid === "#debugTableID") {
|
||||
returnVal = 4;
|
||||
}
|
||||
else if (tableid === "#logTableID") {
|
||||
returnVal = 5;
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window */
|
||||
window.StatisticsCollection = Backbone.Collection.extend({
|
||||
model: window.Statistics,
|
||||
url: "../statistics"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window */
|
||||
window.StatisticsDescription = Backbone.Collection.extend({
|
||||
model: window.StatisticsDescription,
|
||||
url: "../statistics-description",
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone*/
|
||||
|
||||
window.arangoCollection = Backbone.Model.extend({
|
||||
initialize: function () {
|
||||
},
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone*/
|
||||
|
||||
window.arangoDocument = Backbone.Model.extend({
|
||||
initialize: function () {
|
||||
},
|
||||
urlRoot: "/_api/document",
|
||||
defaults: {
|
||||
_id: "",
|
||||
_rev: "",
|
||||
_rev: ""
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone*/
|
||||
|
||||
window.arangoLog = Backbone.Model.extend({
|
||||
initialize: function () {
|
||||
},
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone*/
|
||||
|
||||
window.Statistics = Backbone.Model.extend({
|
||||
defaults: {
|
||||
},
|
||||
|
||||
url: function() {
|
||||
return "../statistics";
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone*/
|
||||
|
||||
window.StatisticsDescription = Backbone.Model.extend({
|
||||
defaults: {
|
||||
"figures" : "",
|
||||
"groups" : ""
|
||||
},
|
||||
|
||||
url: function() {
|
||||
return "../statistics-description";
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, newcap: true */
|
||||
/*global window, $, Backbone, document, arangoCollection, arangoHelper, dashboardView */
|
||||
/*global FoxxInstalledListView, FoxxActiveListView*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
window.Router = Backbone.Router.extend({
|
||||
|
@ -37,20 +41,18 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
window.documentsView = new window.documentsView({
|
||||
collection: window.arangoDocuments,
|
||||
collection: window.arangoDocuments
|
||||
});
|
||||
window.documentView = new window.documentView({
|
||||
collection: window.arangoDocument,
|
||||
collection: window.arangoDocument
|
||||
});
|
||||
window.documentSourceView = new window.documentSourceView({
|
||||
collection: window.arangoDocument,
|
||||
collection: window.arangoDocument
|
||||
});
|
||||
|
||||
window.arangoLogsStore = new window.arangoLogs();
|
||||
window.arangoLogsStore.fetch({
|
||||
success: function () {
|
||||
if (!window.logsView) {
|
||||
}
|
||||
window.logsView = new window.logsView({
|
||||
collection: window.arangoLogsStore
|
||||
});
|
||||
|
@ -156,13 +158,13 @@ $(document).ready(function() {
|
|||
});
|
||||
*/
|
||||
if (this.statisticsDescription === undefined) {
|
||||
this.statisticsDescription = new window.StatisticsDescription;
|
||||
this.statisticsDescription = new window.StatisticsDescription();
|
||||
this.statisticsDescription.fetch({
|
||||
async:false
|
||||
});
|
||||
}
|
||||
if (this.statistics === undefined) {
|
||||
this.statisticsCollection = new window.StatisticsCollection;
|
||||
this.statisticsCollection = new window.StatisticsCollection();
|
||||
//this.statisticsCollection.fetch();
|
||||
}
|
||||
if (this.dashboardView === undefined) {
|
||||
|
@ -171,15 +173,14 @@ $(document).ready(function() {
|
|||
description: this.statisticsDescription
|
||||
});
|
||||
}
|
||||
|
||||
this.dashboardView.render();
|
||||
},
|
||||
|
||||
|
||||
graph: function() {
|
||||
this.graphView.render();
|
||||
this.naviView.selectMenuItem('graph-menu');
|
||||
},
|
||||
|
||||
|
||||
applicationsAvailable: function() {
|
||||
if (this.foxxList === undefined) {
|
||||
this.foxxList = new window.FoxxCollection();
|
||||
|
@ -212,7 +213,9 @@ $(document).ready(function() {
|
|||
this.foxxList = new window.FoxxCollection();
|
||||
this.foxxList.fetch({
|
||||
success: function() {
|
||||
var editAppView = new window.foxxEditView({model: self.foxxList.findWhere({_key: appkey})});
|
||||
var editAppView = new window.foxxEditView({
|
||||
model: self.foxxList.findWhere({_key: appkey})
|
||||
});
|
||||
editAppView.render();
|
||||
}
|
||||
});
|
||||
|
@ -228,12 +231,16 @@ $(document).ready(function() {
|
|||
this.foxxList = new window.FoxxCollection();
|
||||
this.foxxList.fetch({
|
||||
success: function() {
|
||||
var installAppView = new window.foxxMountView({model: self.foxxList.findWhere({_key: appkey})});
|
||||
var installAppView = new window.foxxMountView({
|
||||
model: self.foxxList.findWhere({_key: appkey})
|
||||
});
|
||||
installAppView.render();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var installAppView = new window.foxxMountView({model: this.foxxList.findWhere({_key: appkey})});
|
||||
var installAppView = new window.foxxMountView({
|
||||
model: this.foxxList.findWhere({_key: appkey})
|
||||
});
|
||||
installAppView.render();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $*/
|
||||
|
||||
var aboutView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
init: function () {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $*/
|
||||
|
||||
window.AppDocumentationView = Backbone.View.extend({
|
||||
|
||||
el: '#content',
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, stupid: true, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, window, exports, Backbone, EJS, $, arangoHelper */
|
||||
|
||||
var collectionView = Backbone.View.extend({
|
||||
el: '#modalPlaceholder',
|
||||
initialize: function () {
|
||||
|
@ -30,7 +33,7 @@ var collectionView = Backbone.View.extend({
|
|||
"keydown #change-collection-size" : "listenKey"
|
||||
},
|
||||
listenKey: function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
if (e.keyCode === 13) {
|
||||
this.saveModifiedCollection();
|
||||
}
|
||||
},
|
||||
|
@ -52,13 +55,18 @@ var collectionView = Backbone.View.extend({
|
|||
$('#change-collection-type').text(this.myCollection.type);
|
||||
$('#change-collection-status').text(this.myCollection.status);
|
||||
|
||||
if (this.myCollection.status == 'unloaded') {
|
||||
$('#colFooter').append('<button id="load-modified-collection" class="btn" style="margin-right: 10px">Load</button>');
|
||||
if (this.myCollection.status === 'unloaded') {
|
||||
$('#colFooter').append(
|
||||
'<button id="load-modified-collection" class="btn" style="margin-right: 10px">Load</button>'
|
||||
);
|
||||
$('#collectionSizeBox').hide();
|
||||
$('#collectionSyncBox').hide();
|
||||
}
|
||||
else if (this.myCollection.status == 'loaded') {
|
||||
$('#colFooter').append('<button id="unload-modified-collection" class="btn" style="margin-right: 10px">Unload</button>');
|
||||
else if (this.myCollection.status === 'loaded') {
|
||||
$('#colFooter').append(
|
||||
'<button id="unload-modified-collection"'+
|
||||
'class="btn" style="margin-right: 10px">Unload</button>'
|
||||
);
|
||||
var data = window.arangoCollectionsStore.getProperties(this.options.colId, true);
|
||||
this.fillLoadedModal(data);
|
||||
}
|
||||
|
@ -66,7 +74,7 @@ var collectionView = Backbone.View.extend({
|
|||
fillLoadedModal: function (data) {
|
||||
$('#collectionSizeBox').show();
|
||||
$('#collectionSyncBox').show();
|
||||
if (data.waitForSync == false) {
|
||||
if (data.waitForSync === false) {
|
||||
$('#change-collection-sync').val('false');
|
||||
}
|
||||
else {
|
||||
|
@ -74,7 +82,7 @@ var collectionView = Backbone.View.extend({
|
|||
}
|
||||
var calculatedSize = data.journalSize / 1024 / 1024;
|
||||
$('#change-collection-size').val(calculatedSize);
|
||||
$('#change-collection').modal('show')
|
||||
$('#change-collection').modal('show');
|
||||
},
|
||||
saveModifiedCollection: function() {
|
||||
var newname = $('#change-collection-name').val();
|
||||
|
@ -87,8 +95,9 @@ var collectionView = Backbone.View.extend({
|
|||
var status = this.getCollectionStatus();
|
||||
|
||||
if (status === 'loaded') {
|
||||
var result;
|
||||
if (this.myCollection.name !== newname) {
|
||||
var result = window.arangoCollectionsStore.renameCollection(collid, newname);
|
||||
result = window.arangoCollectionsStore.renameCollection(collid, newname);
|
||||
}
|
||||
|
||||
var wfs = $('#change-collection-sync').val();
|
||||
|
@ -107,9 +116,7 @@ var collectionView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
if (result !== true) {
|
||||
if (result === undefined) {
|
||||
}
|
||||
else {
|
||||
if (result !== undefined) {
|
||||
arangoHelper.arangoError("Collection error: " + result);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, window, exports, Backbone, EJS, $*/
|
||||
|
||||
window.CollectionListItemView = Backbone.View.extend({
|
||||
|
||||
tagName: "li",
|
||||
|
@ -24,7 +27,9 @@ window.CollectionListItemView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
selectCollection: function() {
|
||||
window.App.navigate("collection/" + encodeURIComponent(this.model.get("name")) + "/documents/1", {trigger: true});
|
||||
window.App.navigate(
|
||||
"collection/" + encodeURIComponent(this.model.get("name")) + "/documents/1", {trigger: true}
|
||||
);
|
||||
},
|
||||
|
||||
noop: function(event) {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, window, setTimeout, clearTimeout, $*/
|
||||
|
||||
var collectionsView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
el2: '.thumbnails',
|
||||
|
@ -15,9 +18,14 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
var searchOptions = this.collection.searchOptions;
|
||||
|
||||
$('.thumbnails', this.el).append('<li class="span3"><a href="#new" class="add"><img id="newCollection" src="img/plus_icon.png" class="pull-left" />Add Collection</a></li>');
|
||||
$('.thumbnails', this.el).append(
|
||||
'<li class="span3"><a href="#new" class="add"><img id="newCollection"'+
|
||||
'src="img/plus_icon.png" class="pull-left" />Add Collection</a></li>'
|
||||
);
|
||||
this.collection.getFiltered(searchOptions).forEach(function (arango_collection) {
|
||||
$('.thumbnails', this.el).append(new window.CollectionListItemView({model: arango_collection}).render().el);
|
||||
$('.thumbnails', this.el).append(new window.CollectionListItemView({
|
||||
model: arango_collection
|
||||
}).render().el);
|
||||
}, this);
|
||||
|
||||
|
||||
|
@ -49,7 +57,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.includeSystem = ($('#checkSystem').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeSystem) {
|
||||
if (oldValue !== searchOptions.includeSystem) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
@ -59,7 +67,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.includeEdge = ($('#checkEdge').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeEdge) {
|
||||
if (oldValue !== searchOptions.includeEdge) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
@ -69,7 +77,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.includeDocument = ($('#checkDocument').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeDocument) {
|
||||
if (oldValue !== searchOptions.includeDocument) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
@ -79,7 +87,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.includeLoaded = ($('#checkLoaded').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeLoaded) {
|
||||
if (oldValue !== searchOptions.includeLoaded) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
@ -89,7 +97,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.includeUnloaded = ($('#checkUnloaded').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeUnloaded) {
|
||||
if (oldValue !== searchOptions.includeUnloaded) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
@ -99,7 +107,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.sortBy = (($('#sortName').is(":checked") === true) ? 'name' : 'type');
|
||||
|
||||
if (oldValue != searchOptions.sortBy) {
|
||||
if (oldValue !== searchOptions.sortBy) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
@ -109,7 +117,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.sortBy = (($('#sortType').is(":checked") === true) ? 'type' : 'name');
|
||||
|
||||
if (oldValue != searchOptions.sortBy) {
|
||||
if (oldValue !== searchOptions.sortBy) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
@ -119,7 +127,7 @@ var collectionsView = Backbone.View.extend({
|
|||
|
||||
searchOptions.sortOrder = (($('#sortOrder').is(":checked") === true) ? -1 : 1);
|
||||
|
||||
if (oldValue != searchOptions.sortOrder) {
|
||||
if (oldValue !== searchOptions.sortOrder) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $, flush, window, arangoHelper, nv, d3*/
|
||||
|
||||
var dashboardView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
updateInterval: 500, // 0.5 second, constant
|
||||
|
@ -164,7 +167,7 @@ var dashboardView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
if (addGroup == true) {
|
||||
if (addGroup === true) {
|
||||
self.options.description.models[0].attributes.groups.push({
|
||||
"description" : "custom",
|
||||
"group" : "custom",
|
||||
|
@ -201,7 +204,6 @@ var dashboardView = Backbone.View.extend({
|
|||
var scale = 0.0001;
|
||||
|
||||
for (i = 0; i < 12; ++i) {
|
||||
this.units.push(scale * 1);
|
||||
this.units.push(scale * 2);
|
||||
this.units.push(scale * 2.5);
|
||||
this.units.push(scale * 4);
|
||||
|
@ -216,13 +218,12 @@ var dashboardView = Backbone.View.extend({
|
|||
var i = 0, n = this.units.length;
|
||||
while (i < n) {
|
||||
var unit = this.units[i++];
|
||||
if (max > unit) {
|
||||
continue;
|
||||
}
|
||||
if (max == unit) {
|
||||
if (max === unit) {
|
||||
break;
|
||||
}
|
||||
return unit;
|
||||
if (max < unit) {
|
||||
return unit;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
|
@ -285,8 +286,8 @@ var dashboardView = Backbone.View.extend({
|
|||
var self = this;
|
||||
nv.addGraph(function() {
|
||||
var chart = nv.models.pieChart()
|
||||
.x(function(d) { return d.label })
|
||||
.y(function(d) { return d.value })
|
||||
.x(function(d) { return d.label; })
|
||||
.y(function(d) { return d.value; })
|
||||
.showLabels(true);
|
||||
|
||||
d3.select("#detailCollectionsChart svg")
|
||||
|
@ -305,7 +306,7 @@ var dashboardView = Backbone.View.extend({
|
|||
$.each(self.collectionsStats, function(k,v) {
|
||||
collValues.push({
|
||||
"label" : k,
|
||||
"value" : v,
|
||||
"value" : v
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -368,14 +369,15 @@ var dashboardView = Backbone.View.extend({
|
|||
if (self.detailGraph === identifier) {
|
||||
d3.select("#detailGraphChart svg")
|
||||
.call(chart)
|
||||
.datum([ { values: self.seriesData[identifier].values, key: identifier, color: "#8AA051" } ])
|
||||
.datum([{
|
||||
values: self.seriesData[identifier].values,
|
||||
key: identifier,
|
||||
color: "#8AA051"
|
||||
}])
|
||||
.transition().duration(500);
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
//disable ticks for small charts
|
||||
//disable label for small charts
|
||||
//disable ticks/label for small charts
|
||||
|
||||
d3.select("#" + identifier + "Chart svg")
|
||||
.call(chart)
|
||||
|
@ -466,7 +468,8 @@ var dashboardView = Backbone.View.extend({
|
|||
'<div class="boxHeader"><h6 class="dashboardH6">' + figure.name +
|
||||
'</h6>'+
|
||||
'<i class="icon-remove icon-white db-hide" value="'+figure.identifier+'"></i>' +
|
||||
'<i class="icon-info-sign icon-white db-info" value="'+figure.identifier+'" title="'+figure.description+'"></i>' +
|
||||
'<i class="icon-info-sign icon-white db-info" value="'+figure.identifier+
|
||||
'" title="'+figure.description+'"></i>' +
|
||||
'<i class="icon-zoom-in icon-white db-zoom" value="'+figure.identifier+'"></i>' +
|
||||
'</div>' +
|
||||
'<div class="statChart" id="' + figure.identifier + 'Chart"><svg class="svgClass"/></div>' +
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $, window, arangoHelper, ace, arangoDocumentStore */
|
||||
|
||||
var documentSourceView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
init: function () {
|
||||
},
|
||||
events: {
|
||||
"click #tableView" : "tableView",
|
||||
"click #saveSourceDoc" : "saveSourceDoc",
|
||||
"click #saveSourceDoc" : "saveSourceDoc"
|
||||
},
|
||||
|
||||
template: new EJS({url: 'js/templates/documentSourceView.ejs'}),
|
||||
|
@ -46,10 +49,11 @@ var documentSourceView = Backbone.View.extend({
|
|||
);
|
||||
},
|
||||
saveSourceDoc: function() {
|
||||
var editor, model, result;
|
||||
if (this.type === 'document') {
|
||||
var editor = ace.edit("sourceEditor");
|
||||
var model = editor.getValue();
|
||||
var result = window.arangoDocumentStore.saveDocument(this.colid, this.docid, model);
|
||||
editor = ace.edit("sourceEditor");
|
||||
model = editor.getValue();
|
||||
result = window.arangoDocumentStore.saveDocument(this.colid, this.docid, model);
|
||||
if (result === true) {
|
||||
arangoHelper.arangoNotification('Document saved');
|
||||
}
|
||||
|
@ -58,9 +62,9 @@ var documentSourceView = Backbone.View.extend({
|
|||
}
|
||||
}
|
||||
else if (this.type === 'edge') {
|
||||
var editor = ace.edit("sourceEditor");
|
||||
var model = editor.getValue();
|
||||
var result = window.arangoDocumentStore.saveEdge(this.colid, this.docid, model);
|
||||
editor = ace.edit("sourceEditor");
|
||||
model = editor.getValue();
|
||||
result = window.arangoDocumentStore.saveEdge(this.colid, this.docid, model);
|
||||
if (result === true) {
|
||||
arangoHelper.arangoNotification('Edge saved');
|
||||
}
|
||||
|
@ -82,7 +86,7 @@ var documentSourceView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
var editor = ace.edit("sourceEditor");
|
||||
editor.setValue(this.FormatJSON(data));
|
||||
editor.setValue(arangoHelper.FormatJSON(data));
|
||||
},
|
||||
stateReplace: function (value) {
|
||||
var inString = false;
|
||||
|
@ -154,86 +158,5 @@ var documentSourceView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
FormatJSON: function (oData, sIndent) {
|
||||
var self = this;
|
||||
if (arguments.length < 2) {
|
||||
var sIndent = "";
|
||||
}
|
||||
var sIndentStyle = " ";
|
||||
var sDataType = self.RealTypeOf(oData);
|
||||
|
||||
if (sDataType == "array") {
|
||||
if (oData.length == 0) {
|
||||
return "[]";
|
||||
}
|
||||
var sHTML = "[";
|
||||
} else {
|
||||
var iCount = 0;
|
||||
$.each(oData, function() {
|
||||
iCount++;
|
||||
return;
|
||||
});
|
||||
if (iCount == 0) { // object is empty
|
||||
return "{}";
|
||||
}
|
||||
var sHTML = "{";
|
||||
}
|
||||
|
||||
var iCount = 0;
|
||||
$.each(oData, function(sKey, vValue) {
|
||||
if (iCount > 0) {
|
||||
sHTML += ",";
|
||||
}
|
||||
if (sDataType == "array") {
|
||||
sHTML += ("\n" + sIndent + sIndentStyle);
|
||||
} else {
|
||||
sHTML += ("\n" + sIndent + sIndentStyle + JSON.stringify(sKey) + ": ");
|
||||
}
|
||||
|
||||
// display relevant data type
|
||||
switch (self.RealTypeOf(vValue)) {
|
||||
case "array":
|
||||
case "object":
|
||||
sHTML += self.FormatJSON(vValue, (sIndent + sIndentStyle));
|
||||
break;
|
||||
case "boolean":
|
||||
case "number":
|
||||
sHTML += vValue.toString();
|
||||
break;
|
||||
case "null":
|
||||
sHTML += "null";
|
||||
break;
|
||||
case "string":
|
||||
sHTML += "\"" + vValue.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"";
|
||||
break;
|
||||
default:
|
||||
sHTML += ("TYPEOF: " + typeof(vValue));
|
||||
}
|
||||
|
||||
// loop
|
||||
iCount++;
|
||||
});
|
||||
|
||||
// close object
|
||||
if (sDataType == "array") {
|
||||
sHTML += ("\n" + sIndent + "]");
|
||||
} else {
|
||||
sHTML += ("\n" + sIndent + "}");
|
||||
}
|
||||
|
||||
// return
|
||||
return sHTML;
|
||||
},
|
||||
RealTypeOf: function (v) {
|
||||
if (typeof(v) == "object") {
|
||||
if (v === null) return "null";
|
||||
if (v.constructor == (new Array).constructor) return "array";
|
||||
if (v.constructor == (new Date).constructor) return "date";
|
||||
if (v.constructor == (new RegExp).constructor) return "regex";
|
||||
return "object";
|
||||
}
|
||||
return typeof(v);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, forin: true */
|
||||
/*global require, exports, Backbone, EJS, $, window, arangoHelper, value2html */
|
||||
|
||||
var documentView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
table: '#documentTableID',
|
||||
|
@ -19,7 +22,7 @@ var documentView = Backbone.View.extend({
|
|||
"click #editSecondRow" : "editSecond",
|
||||
"keydown .sorting_1" : "listenKey",
|
||||
"keydown" : "listenGlobalKey",
|
||||
"blur textarea" : "checkFocus",
|
||||
"blur textarea" : "checkFocus"
|
||||
},
|
||||
|
||||
checkFocus: function(e) {
|
||||
|
@ -52,23 +55,20 @@ var documentView = Backbone.View.extend({
|
|||
template: new EJS({url: 'js/templates/documentView.ejs'}),
|
||||
|
||||
typeCheck: function (type) {
|
||||
var result;
|
||||
if (type === 'edge') {
|
||||
var result = window.arangoDocumentStore.getEdge(this.colid, this.docid);
|
||||
result = window.arangoDocumentStore.getEdge(this.colid, this.docid);
|
||||
if (result === true) {
|
||||
this.initTable();
|
||||
this.drawTable();
|
||||
}
|
||||
else if (result === false) {
|
||||
}
|
||||
}
|
||||
else if (type === 'document') {
|
||||
var result = window.arangoDocumentStore.getDocument(this.colid, this.docid);
|
||||
result = window.arangoDocumentStore.getDocument(this.colid, this.docid);
|
||||
if (result === true) {
|
||||
this.initTable();
|
||||
this.drawTable();
|
||||
}
|
||||
else if (result === false) {
|
||||
}
|
||||
}
|
||||
},
|
||||
clicked: function (a) {
|
||||
|
@ -103,10 +103,11 @@ var documentView = Backbone.View.extend({
|
|||
window.location.hash = window.location.hash + "/source";
|
||||
},
|
||||
saveDocument: function () {
|
||||
var model, result;
|
||||
if (this.type === 'document') {
|
||||
var model = window.arangoDocumentStore.models[0].attributes;
|
||||
model = window.arangoDocumentStore.models[0].attributes;
|
||||
model = JSON.stringify(model);
|
||||
var result = window.arangoDocumentStore.saveDocument(this.colid, this.docid, model);
|
||||
result = window.arangoDocumentStore.saveDocument(this.colid, this.docid, model);
|
||||
if (result === true) {
|
||||
arangoHelper.arangoNotification('Document saved');
|
||||
$('#addRow').removeClass('disabledBtn');
|
||||
|
@ -117,9 +118,9 @@ var documentView = Backbone.View.extend({
|
|||
}
|
||||
}
|
||||
else if (this.type === 'edge') {
|
||||
var model = window.arangoDocumentStore.models[0].attributes;
|
||||
model = window.arangoDocumentStore.models[0].attributes;
|
||||
model = JSON.stringify(model);
|
||||
var result = window.arangoDocumentStore.saveEdge(this.colid, this.docid, model);
|
||||
result = window.arangoDocumentStore.saveEdge(this.colid, this.docid, model);
|
||||
if (result === true) {
|
||||
arangoHelper.arangoNotification('Edge saved');
|
||||
$('#addRow').removeClass('disabledBtn');
|
||||
|
@ -150,7 +151,8 @@ var documentView = Backbone.View.extend({
|
|||
'<a class="add" class="notwriteable" id="addDocumentLine"> </a>',
|
||||
'<div class="notwriteable"></div>',
|
||||
'<div class="notwriteable"></div>',
|
||||
'<button class="enabled" id="addRow"><img id="addDocumentLine" class="plusIcon" src="img/plus_icon.png"></button>'
|
||||
'<button class="enabled" id="addRow"><img id="addDocumentLine"'+
|
||||
'class="plusIcon" src="img/plus_icon.png"></button>'
|
||||
]);
|
||||
$.each(window.arangoDocumentStore.models[0].attributes, function(key, value) {
|
||||
if (arangoHelper.isSystemAttribute(key)) {
|
||||
|
@ -171,7 +173,8 @@ var documentView = Backbone.View.extend({
|
|||
self.value2html(value),
|
||||
JSON.stringify(value),
|
||||
'<i class="icon-edit" id="editSecondRow"></i>',
|
||||
'<button class="enabled" id="deleteRow"><img src="img/icon_delete.png" width="16" height="16"></button>'
|
||||
'<button class="enabled" id="deleteRow"><img src="img/icon_delete.png"'+
|
||||
'width="16" height="16"></button>'
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
@ -196,7 +199,8 @@ var documentView = Backbone.View.extend({
|
|||
this.value2html("editme"),
|
||||
JSON.stringify("editme"),
|
||||
'<i class="icon-edit" id="editSecondRow"></i>',
|
||||
'<button class="enabled" id="deleteRow"><img src="img/icon_delete.png" width="16" height="16"></button>'
|
||||
'<button class="enabled" id="deleteRow"><img src="img/icon_delete.png"'+
|
||||
'width="16" height="16"></button>'
|
||||
]
|
||||
);
|
||||
this.makeEditable();
|
||||
|
@ -241,7 +245,7 @@ var documentView = Backbone.View.extend({
|
|||
value2html: function (value, isReadOnly) {
|
||||
var self = this;
|
||||
var typify = function (value) {
|
||||
var checked = typeof(value);
|
||||
var checked = typeof value;
|
||||
switch(checked) {
|
||||
case 'number':
|
||||
return ("<a class=\"sh_number\">" + value + "</a>");
|
||||
|
@ -253,21 +257,21 @@ var documentView = Backbone.View.extend({
|
|||
if (value instanceof Array) {
|
||||
return ("<a class=\"sh_array\">" + self.escaped(JSON.stringify(value)) + "</a>");
|
||||
}
|
||||
else {
|
||||
return ("<a class=\"sh_object\">"+ self.escaped(JSON.stringify(value)) + "</a>");
|
||||
}
|
||||
return ("<a class=\"sh_object\">"+ self.escaped(JSON.stringify(value)) + "</a>");
|
||||
}
|
||||
};
|
||||
return (isReadOnly ? "(read-only) " : "") + typify(value);
|
||||
},
|
||||
|
||||
escaped: function (value) {
|
||||
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
||||
.replace(/"/g, """).replace(/'/g, "'");
|
||||
},
|
||||
|
||||
updateLocalDocumentStorage: function () {
|
||||
var data = $(this.table).dataTable().fnGetData();
|
||||
var result = {};
|
||||
var row;
|
||||
|
||||
for (row in data) {
|
||||
//Exclude "add-collection" row
|
||||
|
@ -303,47 +307,43 @@ var documentView = Backbone.View.extend({
|
|||
});
|
||||
$('.writeable', documentEditTable.fnGetNodes()).editable(function(value, settings) {
|
||||
var aPos = documentEditTable.fnGetPosition(this);
|
||||
if (aPos[1] == 0) {
|
||||
documentEditTable.fnUpdate(self.escaped(value), aPos[0], aPos[1]);
|
||||
self.updateLocalDocumentStorage();
|
||||
return value;
|
||||
if (aPos[1] === 0) {
|
||||
documentEditTable.fnUpdate(self.escaped(value), aPos[0], aPos[1]);
|
||||
self.updateLocalDocumentStorage();
|
||||
return value;
|
||||
}
|
||||
if (aPos[1] == 2) {
|
||||
if (aPos[1] === 2) {
|
||||
var oldContent = JSON.parse(documentEditTable.fnGetData(aPos[0], aPos[1] + 1));
|
||||
var test = self.getTypedValue(value);
|
||||
if (String(value) == String(oldContent)) {
|
||||
if (String(value) === String(oldContent)) {
|
||||
// no change
|
||||
return self.value2html(oldContent);
|
||||
}
|
||||
else {
|
||||
// change update hidden row
|
||||
documentEditTable.fnUpdate(JSON.stringify(test), aPos[0], aPos[1] + 1);
|
||||
self.updateLocalDocumentStorage();
|
||||
// return visible row
|
||||
return self.value2html(test);
|
||||
}
|
||||
// change update hidden row
|
||||
documentEditTable.fnUpdate(JSON.stringify(test), aPos[0], aPos[1] + 1);
|
||||
self.updateLocalDocumentStorage();
|
||||
// return visible row
|
||||
return self.value2html(test);
|
||||
}
|
||||
},{
|
||||
data: function() {
|
||||
$(".btn-success").click()
|
||||
$(".btn-success").click();
|
||||
var aPos = documentEditTable.fnGetPosition(this);
|
||||
var value = documentEditTable.fnGetData(aPos[0], aPos[1]);
|
||||
if (aPos[1] == 0) {
|
||||
if (aPos[1] === 0) {
|
||||
//check if this row was newly created
|
||||
if (value === self.currentKey) {
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if (aPos[1] == 2) {
|
||||
if (aPos[1] === 2) {
|
||||
var oldContent = documentEditTable.fnGetData(aPos[0], aPos[1] + 1);
|
||||
if (typeof(oldContent) == 'object') {
|
||||
if (typeof oldContent === 'object') {
|
||||
//grep hidden row and paste in visible row
|
||||
return value2html(oldContent);
|
||||
}
|
||||
else {
|
||||
return oldContent;
|
||||
}
|
||||
return oldContent;
|
||||
}
|
||||
},
|
||||
width: "none", // if not set, each row will get bigger & bigger (Safari & Firefox)
|
||||
|
@ -364,7 +364,7 @@ var documentView = Backbone.View.extend({
|
|||
var currentKey2 = window.documentView.currentKey;
|
||||
var data = $('#documentTableID').dataTable().fnGetData();
|
||||
$.each(data, function(key, val) {
|
||||
if (val[0] == currentKey2) {
|
||||
if (val[0] === currentKey2) {
|
||||
$('#documentTableID').dataTable().fnDeleteRow(key);
|
||||
$('#addRow').removeClass('disabledBtn');
|
||||
}
|
||||
|
@ -381,10 +381,10 @@ var documentView = Backbone.View.extend({
|
|||
var data = $('#documentTableID').dataTable().fnGetData();
|
||||
|
||||
if (toCheck === '') {
|
||||
$(td).addClass('validateError');
|
||||
arangoHelper.arangoNotification("Key is empty!");
|
||||
returnval = false;
|
||||
return returnval;
|
||||
$(td).addClass('validateError');
|
||||
arangoHelper.arangoNotification("Key is empty!");
|
||||
returnval = false;
|
||||
return returnval;
|
||||
}
|
||||
|
||||
$.each(data, function(key, val) {
|
||||
|
@ -395,23 +395,21 @@ var documentView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
}
|
||||
else if ($(td).hasClass('rightCell') === true) {
|
||||
}
|
||||
return returnval;
|
||||
},
|
||||
getTypedValue: function (value) {
|
||||
value = value.replace(/(^\s+|\s+$)/g, '');
|
||||
if (value == 'true') {
|
||||
if (value === 'true') {
|
||||
return true;
|
||||
}
|
||||
if (value == 'false') {
|
||||
if (value === 'false') {
|
||||
return false;
|
||||
}
|
||||
if (value == 'null') {
|
||||
if (value === 'null') {
|
||||
return null;
|
||||
}
|
||||
if (value.match(/^-?((\d+)?\.)?\d+$/)) {
|
||||
// TODO: support exp notation
|
||||
//support exp notation
|
||||
return parseFloat(value);
|
||||
}
|
||||
|
||||
|
@ -422,8 +420,8 @@ var documentView = Backbone.View.extend({
|
|||
// value is an array
|
||||
return test;
|
||||
}
|
||||
if (typeof(test) == 'object') {
|
||||
// value is an object
|
||||
if (typeof test === 'object') {
|
||||
// value is an object
|
||||
return test;
|
||||
}
|
||||
}
|
||||
|
@ -431,10 +429,12 @@ var documentView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
// fallback: value is a string
|
||||
value = value + '';
|
||||
value = String(value);
|
||||
|
||||
if (value !== '' && (value.substr(0, 1) != '"' || value.substr(-1) != '"')) {
|
||||
arangoHelper.arangoNotification('You have entered an invalid string value. Please review and adjust it.');
|
||||
if (value !== '' && (value.substr(0, 1) !== '"' || value.substr(-1) !== '"')) {
|
||||
arangoHelper.arangoNotification(
|
||||
'You have entered an invalid string value. Please review and adjust it.'
|
||||
);
|
||||
throw "error";
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,9 @@ var documentView = Backbone.View.extend({
|
|||
value = JSON.parse(value);
|
||||
}
|
||||
catch (e) {
|
||||
arangoHelper.arangoNotification('You have entered an invalid string value. Please review and adjust it.');
|
||||
arangoHelper.arangoNotification(
|
||||
'You have entered an invalid string value. Please review and adjust it.'
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
return value;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $, window, arangoHelper */
|
||||
|
||||
var documentsView = Backbone.View.extend({
|
||||
collectionID: 0,
|
||||
currentPage: 1,
|
||||
|
@ -140,8 +143,9 @@ var documentsView = Backbone.View.extend({
|
|||
var deleted = false;
|
||||
this.docid = $(self.idelement).next().text();
|
||||
|
||||
var result;
|
||||
if (this.type === 'document') {
|
||||
var result = window.arangoDocumentStore.deleteDocument(this.colid, this.docid);
|
||||
result = window.arangoDocumentStore.deleteDocument(this.colid, this.docid);
|
||||
if (result === true) {
|
||||
//on success
|
||||
arangoHelper.arangoNotification('Document deleted');
|
||||
|
@ -152,7 +156,7 @@ var documentsView = Backbone.View.extend({
|
|||
}
|
||||
}
|
||||
else if (this.type === 'edge') {
|
||||
var result = window.arangoDocumentStore.deleteEdge(this.colid, this.docid);
|
||||
result = window.arangoDocumentStore.deleteEdge(this.colid, this.docid);
|
||||
if (result === true) {
|
||||
//on success
|
||||
arangoHelper.arangoNotification('Edge deleted');
|
||||
|
@ -164,7 +168,9 @@ var documentsView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
if (deleted === true) {
|
||||
$('#documentsTableID').dataTable().fnDeleteRow($('#documentsTableID').dataTable().fnGetPosition(row));
|
||||
$('#documentsTableID').dataTable().fnDeleteRow(
|
||||
$('#documentsTableID').dataTable().fnGetPosition(row)
|
||||
);
|
||||
$('#documentsTableID').dataTable().fnClearTable();
|
||||
window.arangoDocumentsStore.getDocuments(this.colid, page);
|
||||
$('#docDeleteModal').modal('hide');
|
||||
|
@ -172,7 +178,7 @@ var documentsView = Backbone.View.extend({
|
|||
|
||||
},
|
||||
clicked: function (event) {
|
||||
if (this.alreadyClicked == true) {
|
||||
if (this.alreadyClicked === true) {
|
||||
this.alreadyClicked = false;
|
||||
return 0;
|
||||
}
|
||||
|
@ -231,9 +237,7 @@ var documentsView = Backbone.View.extend({
|
|||
|
||||
var tempObj = {};
|
||||
$.each(value.attributes.content, function(k, v) {
|
||||
if (k === '_id' || k === '_rev' || k === '_key') {
|
||||
}
|
||||
else {
|
||||
if (k !== '_id' || k !== '_rev' || k !== '_key') {
|
||||
tempObj[k] = v;
|
||||
}
|
||||
});
|
||||
|
@ -254,17 +258,17 @@ var documentsView = Backbone.View.extend({
|
|||
+ '<img src="img/icon_delete.png" width="16" height="16"></button>'
|
||||
]);
|
||||
});
|
||||
$(".prettify").snippet("javascript", {style: "nedit", menu: false, startText: false, transparent: true, showNum: false});
|
||||
/* $(".prettify").tooltip({
|
||||
html: true,
|
||||
placement: "top"
|
||||
});*/
|
||||
$(".prettify").snippet("javascript", {
|
||||
style: "nedit",
|
||||
menu: false,
|
||||
startText: false,
|
||||
transparent: true,
|
||||
showNum: false
|
||||
});
|
||||
this.totalPages = window.arangoDocumentsStore.totalPages;
|
||||
this.currentPage = window.arangoDocumentsStore.currentPage;
|
||||
this.documentsCount = window.arangoDocumentsStore.documentsCount;
|
||||
if (this.documentsCount === 0) {
|
||||
}
|
||||
else {
|
||||
if (this.documentsCount !== 0) {
|
||||
$('#documentsStatus').html(
|
||||
'Showing Page '+this.currentPage+' of '+this.totalPages+
|
||||
', '+this.documentsCount+' entries'
|
||||
|
@ -305,13 +309,19 @@ var documentsView = Backbone.View.extend({
|
|||
}
|
||||
};
|
||||
target.pagination(options);
|
||||
$('#documentsToolbarF').prepend('<ul class="prePagi"><li><a id="documents_first"><i class="icon icon-step-backward"></i></a></li></ul>');
|
||||
$('#documentsToolbarF').append('<ul class="lasPagi"><li><a id="documents_last"><i class="icon icon-step-forward"></i></a></li></ul>');
|
||||
$('#documentsToolbarF').prepend(
|
||||
'<ul class="prePagi"><li><a id="documents_first">'+
|
||||
'<i class="icon icon-step-backward"></i></a></li></ul>');
|
||||
$('#documentsToolbarF').append(
|
||||
'<ul class="lasPagi"><li><a id="documents_last">'+
|
||||
'<i class="icon icon-step-forward"></i></a></li></ul>');
|
||||
var total = $('#totalDocuments');
|
||||
if (total.length > 0) {
|
||||
total.html("Total: " + this.documentsCount + " documents");
|
||||
} else {
|
||||
$('#documentsToolbarFL').append('<a id="totalDocuments">Total: ' + this.documentsCount + ' document(s) </a>');
|
||||
$('#documentsToolbarFL').append(
|
||||
'<a id="totalDocuments">Total: ' + this.documentsCount + ' document(s) </a>'
|
||||
);
|
||||
}
|
||||
},
|
||||
breadcrumb: function () {
|
||||
|
@ -331,7 +341,8 @@ var documentsView = Backbone.View.extend({
|
|||
return this.escaped(string);
|
||||
},
|
||||
escaped: function (value) {
|
||||
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
||||
.replace(/"/g, """).replace(/'/g, "'");
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $*/
|
||||
|
||||
var footerView = Backbone.View.extend({
|
||||
el: '.footer',
|
||||
init: function () {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $, window*/
|
||||
|
||||
var logsView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
offset: 0,
|
||||
|
@ -21,12 +24,10 @@ var logsView = Backbone.View.extend({
|
|||
"click #logTableID_first" : "firstTable",
|
||||
"click #logTableID_last" : "lastTable",
|
||||
"click #logTableID_prev" : "prevTable",
|
||||
"click #logTableID_next" : "nextTable",
|
||||
"click #logTableID_next" : "nextTable"
|
||||
},
|
||||
firstTable: function () {
|
||||
if (this.offset == 0) {
|
||||
}
|
||||
else {
|
||||
if (this.offset !== 0) {
|
||||
this.offset = 0;
|
||||
this.page = 1;
|
||||
this.clearTable();
|
||||
|
@ -34,9 +35,7 @@ var logsView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
lastTable: function () {
|
||||
if (this.page == this.totalPages) {
|
||||
}
|
||||
else {
|
||||
if (this.page !== this.totalPages) {
|
||||
this.totalPages = Math.ceil(this.totalAmount / this.size);
|
||||
this.page = this.totalPages;
|
||||
this.offset = (this.totalPages * this.size) - this.size;
|
||||
|
@ -45,9 +44,7 @@ var logsView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
prevTable: function () {
|
||||
if (this.offset == 0) {
|
||||
}
|
||||
else {
|
||||
if (this.offset !== 0) {
|
||||
this.offset = this.offset - this.size;
|
||||
this.page = this.page - 1;
|
||||
this.clearTable();
|
||||
|
@ -55,9 +52,7 @@ var logsView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
nextTable: function () {
|
||||
if (this.page == this.totalPages) {
|
||||
}
|
||||
else {
|
||||
if (this.page !== this.totalPages) {
|
||||
this.page = this.page + 1;
|
||||
this.offset = this.offset + this.size;
|
||||
this.clearTable();
|
||||
|
@ -160,15 +155,21 @@ var logsView = Backbone.View.extend({
|
|||
}
|
||||
};
|
||||
target.pagination(options);
|
||||
$('#logtestdiv').prepend('<ul class="prePagi"><li><a id="logTableID_first"><i class="icon icon-step-backward"></i></a></li></ul>');
|
||||
$('#logtestdiv').append('<ul class="lasPagi"><li><a id="logTableID_last"><i class="icon icon-step-forward"></i></a></li></ul>');
|
||||
$('#logtestdiv').prepend(
|
||||
'<ul class="prePagi"><li><a id="logTableID_first">'+
|
||||
'<i class="icon icon-step-backward"></i></a></li></ul>'
|
||||
);
|
||||
$('#logtestdiv').append(
|
||||
'<ul class="lasPagi"><li><a id="logTableID_last">'+
|
||||
'<i class="icon icon-step-forward"></i></a></li></ul>'
|
||||
);
|
||||
},
|
||||
drawTable: function () {
|
||||
var self = this;
|
||||
|
||||
function format (dt) {
|
||||
var pad = function (n) {
|
||||
return n < 10 ? '0' + n : n
|
||||
return n < 10 ? '0' + n : n;
|
||||
};
|
||||
|
||||
return dt.getUTCFullYear() + '-'
|
||||
|
@ -197,10 +198,22 @@ var logsView = Backbone.View.extend({
|
|||
$('#'+this.table).dataTable().fnClearTable();
|
||||
},
|
||||
convertLogStatus: function (status) {
|
||||
if (status === 1) { return "Error" ;}
|
||||
else if (status === 2) { return "Warning" ;}
|
||||
else if (status === 3) { return "Info" ;}
|
||||
else if (status === 4) { return "Debug" ;}
|
||||
else { return "Unknown";}
|
||||
var returnString;
|
||||
if (status === 1) {
|
||||
returnString = "Error";
|
||||
}
|
||||
else if (status === 2) {
|
||||
returnString = "Warning";
|
||||
}
|
||||
else if (status === 3) {
|
||||
returnString = "Info";
|
||||
}
|
||||
else if (status === 4) {
|
||||
returnString = "Debug";
|
||||
}
|
||||
else {
|
||||
returnString = "Unknown";
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $*/
|
||||
|
||||
var navigationView = Backbone.View.extend({
|
||||
el: '.header',
|
||||
init: function () {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $, window, arangoHelper*/
|
||||
|
||||
var newCollectionView = Backbone.View.extend({
|
||||
el: '#modalPlaceholder',
|
||||
initialize: function () {
|
||||
|
@ -32,7 +35,7 @@ var newCollectionView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
listenKey: function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
if (e.keyCode === 13) {
|
||||
this.saveNewCollection();
|
||||
}
|
||||
},
|
||||
|
@ -41,7 +44,6 @@ var newCollectionView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
saveNewCollection: function(a) {
|
||||
//TODO: other solution
|
||||
if (window.location.hash !== '#new') {
|
||||
return;
|
||||
}
|
||||
|
@ -53,9 +55,10 @@ var newCollectionView = Backbone.View.extend({
|
|||
var collType = $('#new-collection-type').val();
|
||||
var collSync = $('#new-collection-sync').val();
|
||||
var isSystem = (collName.substr(0, 1) === '_');
|
||||
var wfs = (collSync == "true");
|
||||
var wfs = (collSync === "true");
|
||||
var journalSizeString;
|
||||
|
||||
if (collSize == '') {
|
||||
if (collSize === '') {
|
||||
journalSizeString = '';
|
||||
}
|
||||
else {
|
||||
|
@ -68,12 +71,14 @@ var newCollectionView = Backbone.View.extend({
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
if (collName == '') {
|
||||
if (collName === '') {
|
||||
arangoHelper.arangoError('No collection name entered!');
|
||||
return 0;
|
||||
}
|
||||
|
||||
var returnobj = window.arangoCollectionsStore.newCollection(collName, wfs, isSystem, journalSizeString, collType);
|
||||
var returnobj = window.arangoCollectionsStore.newCollection(
|
||||
collName, wfs, isSystem, journalSizeString, collType
|
||||
);
|
||||
if (returnobj.status === true) {
|
||||
self.hidden();
|
||||
$("#add-collection").modal('hide');
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, EJS, $, localStorage, ace, Storage, window, arangoHelper*/
|
||||
|
||||
var queryView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
initialize: function () {
|
||||
|
@ -7,7 +10,7 @@ var queryView = Backbone.View.extend({
|
|||
events: {
|
||||
'click #submitQueryIcon' : 'submitQuery',
|
||||
'click #submitQueryButton' : 'submitQuery',
|
||||
'click .clearicon': 'clearOutput',
|
||||
'click .clearicon': 'clearOutput'
|
||||
},
|
||||
clearOutput: function() {
|
||||
$('#queryOutput').empty();
|
||||
|
@ -50,7 +53,7 @@ var queryView = Backbone.View.extend({
|
|||
$('#aqlEditor .ace_text-input').focus();
|
||||
$.gritter.removeAll();
|
||||
|
||||
if(typeof(Storage)!=="undefined") {
|
||||
if(typeof Storage) {
|
||||
var queryContent = localStorage.getItem("queryContent");
|
||||
var queryOutput = localStorage.getItem("queryOutput");
|
||||
editor.setValue(queryContent);
|
||||
|
@ -80,8 +83,8 @@ var queryView = Backbone.View.extend({
|
|||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
editor2.setValue(self.FormatJSON(data.result));
|
||||
if(typeof(Storage) !== "undefined") {
|
||||
editor2.setValue(arangoHelper.FormatJSON(data.result));
|
||||
if(typeof Storage) {
|
||||
localStorage.setItem("queryContent", editor.getValue());
|
||||
localStorage.setItem("queryOutput", editor2.getValue());
|
||||
}
|
||||
|
@ -91,7 +94,7 @@ var queryView = Backbone.View.extend({
|
|||
var temp = JSON.parse(data.responseText);
|
||||
editor2.setValue('[' + temp.errorNum + '] ' + temp.errorMessage);
|
||||
|
||||
if(typeof(Storage) !== "undefined") {
|
||||
if(typeof Storage) {
|
||||
localStorage.setItem("queryContent", editor.getValue());
|
||||
localStorage.setItem("queryOutput", editor2.getValue());
|
||||
}
|
||||
|
@ -103,87 +106,6 @@ var queryView = Backbone.View.extend({
|
|||
});
|
||||
editor2.resize();
|
||||
|
||||
},
|
||||
FormatJSON: function(oData, sIndent) {
|
||||
var self = this;
|
||||
if (arguments.length < 2) {
|
||||
var sIndent = "";
|
||||
}
|
||||
var sIndentStyle = " ";
|
||||
var sDataType = self.RealTypeOf(oData);
|
||||
|
||||
if (sDataType == "array") {
|
||||
if (oData.length == 0) {
|
||||
return "[]";
|
||||
}
|
||||
var sHTML = "[";
|
||||
} else {
|
||||
var iCount = 0;
|
||||
$.each(oData, function() {
|
||||
iCount++;
|
||||
return;
|
||||
});
|
||||
if (iCount == 0) { // object is empty
|
||||
return "{}";
|
||||
}
|
||||
var sHTML = "{";
|
||||
}
|
||||
|
||||
// loop through items
|
||||
var iCount = 0;
|
||||
$.each(oData, function(sKey, vValue) {
|
||||
if (iCount > 0) {
|
||||
sHTML += ",";
|
||||
}
|
||||
if (sDataType == "array") {
|
||||
sHTML += ("\n" + sIndent + sIndentStyle);
|
||||
} else {
|
||||
sHTML += ("\n" + sIndent + sIndentStyle + JSON.stringify(sKey) + ": ");
|
||||
}
|
||||
|
||||
// display relevant data type
|
||||
switch (self.RealTypeOf(vValue)) {
|
||||
case "array":
|
||||
case "object":
|
||||
sHTML += self.FormatJSON(vValue, (sIndent + sIndentStyle));
|
||||
break;
|
||||
case "boolean":
|
||||
case "number":
|
||||
sHTML += vValue.toString();
|
||||
break;
|
||||
case "null":
|
||||
sHTML += "null";
|
||||
break;
|
||||
case "string":
|
||||
sHTML += "\"" + vValue.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"";
|
||||
break;
|
||||
default:
|
||||
sHTML += ("TYPEOF: " + typeof(vValue));
|
||||
}
|
||||
|
||||
// loop
|
||||
iCount++;
|
||||
});
|
||||
|
||||
// close object
|
||||
if (sDataType == "array") {
|
||||
sHTML += ("\n" + sIndent + "]");
|
||||
} else {
|
||||
sHTML += ("\n" + sIndent + "}");
|
||||
}
|
||||
|
||||
// return
|
||||
return sHTML;
|
||||
},
|
||||
RealTypeOf: function(v) {
|
||||
if (typeof(v) == "object") {
|
||||
if (v === null) return "null";
|
||||
if (v.constructor == (new Array).constructor) return "array";
|
||||
if (v.constructor == (new Date).constructor) return "date";
|
||||
if (v.constructor == (new RegExp).constructor) return "regex";
|
||||
return "object";
|
||||
}
|
||||
return typeof(v);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, evil: true, es5:true */
|
||||
/*global require, exports, Backbone, EJS, $, window, ace, jqconsole, handler, help, location*/
|
||||
|
||||
var shellView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
events: {
|
||||
|
@ -28,7 +31,7 @@ var shellView = Backbone.View.extend({
|
|||
},
|
||||
renderEditor: function () {
|
||||
var editor = ace.edit("editor");
|
||||
editor.resize()
|
||||
editor.resize();
|
||||
},
|
||||
editor: function () {
|
||||
var editor = ace.edit("editor");
|
||||
|
@ -93,13 +96,13 @@ var shellView = Backbone.View.extend({
|
|||
jqconsole.Prompt(true, handler, function(command) {
|
||||
// Continue line if can't compile the command.
|
||||
try {
|
||||
Function(command);
|
||||
} catch (e) {
|
||||
var test = new Function(command);
|
||||
}
|
||||
catch (e) {
|
||||
if (/[\[\{\(]$/.test(command)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test JSLint</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
|
||||
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="lib/underscore.js"></script>
|
||||
<script type="text/javascript" src="lib/jslint.js"></script>
|
||||
|
||||
|
||||
|
||||
<!-- include scripts to check here -->
|
||||
<script type="text/javascript" src="../js/views/aboutView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/collectionView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/collectionsItemView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/collectionsView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/dashboardView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/documentSourceView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/documentView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/documentsView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/footerView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/logsView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/navigationView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/newCollectionView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/queryView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/shellView.js"></script>
|
||||
|
||||
<!-- models --!>
|
||||
<script type="text/javascript" src="../js/views/aboutView.js"></script>
|
||||
<!-- collections --!>
|
||||
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="specJSLint/jsLintSpec.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
jasmineEnv.execute();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2008-2011 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,681 @@
|
|||
jasmine.HtmlReporterHelpers = {};
|
||||
|
||||
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
||||
var results = child.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
||||
var parentDiv = this.dom.summary;
|
||||
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
||||
var parent = child[parentSuite];
|
||||
|
||||
if (parent) {
|
||||
if (typeof this.views.suites[parent.id] == 'undefined') {
|
||||
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
||||
}
|
||||
parentDiv = this.views.suites[parent.id].element;
|
||||
}
|
||||
|
||||
parentDiv.appendChild(childElement);
|
||||
};
|
||||
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
||||
for(var fn in jasmine.HtmlReporterHelpers) {
|
||||
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter = function(_doc) {
|
||||
var self = this;
|
||||
var doc = _doc || window.document;
|
||||
|
||||
var reporterView;
|
||||
|
||||
var dom = {};
|
||||
|
||||
// Jasmine Reporter Public Interface
|
||||
self.logRunningSpecs = false;
|
||||
|
||||
self.reportRunnerStarting = function(runner) {
|
||||
var specs = runner.specs() || [];
|
||||
|
||||
if (specs.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
createReporterDom(runner.env.versionString());
|
||||
doc.body.appendChild(dom.reporter);
|
||||
setExceptionHandling();
|
||||
|
||||
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
||||
reporterView.addSpecs(specs, self.specFilter);
|
||||
};
|
||||
|
||||
self.reportRunnerResults = function(runner) {
|
||||
reporterView && reporterView.complete();
|
||||
};
|
||||
|
||||
self.reportSuiteResults = function(suite) {
|
||||
reporterView.suiteComplete(suite);
|
||||
};
|
||||
|
||||
self.reportSpecStarting = function(spec) {
|
||||
if (self.logRunningSpecs) {
|
||||
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
self.reportSpecResults = function(spec) {
|
||||
reporterView.specComplete(spec);
|
||||
};
|
||||
|
||||
self.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.specFilter = function(spec) {
|
||||
if (!focusedSpecName()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return spec.getFullName().indexOf(focusedSpecName()) === 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function focusedSpecName() {
|
||||
var specName;
|
||||
|
||||
(function memoizeFocusedSpec() {
|
||||
if (specName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var paramMap = [];
|
||||
var params = jasmine.HtmlReporter.parameters(doc);
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
specName = paramMap.spec;
|
||||
})();
|
||||
|
||||
return specName;
|
||||
}
|
||||
|
||||
function createReporterDom(version) {
|
||||
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
||||
dom.banner = self.createDom('div', { className: 'banner' },
|
||||
self.createDom('span', { className: 'title' }, "Jasmine "),
|
||||
self.createDom('span', { className: 'version' }, version)),
|
||||
|
||||
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
||||
dom.alert = self.createDom('div', {className: 'alert'},
|
||||
self.createDom('span', { className: 'exceptions' },
|
||||
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
|
||||
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
|
||||
dom.results = self.createDom('div', {className: 'results'},
|
||||
dom.summary = self.createDom('div', { className: 'summary' }),
|
||||
dom.details = self.createDom('div', { id: 'details' }))
|
||||
);
|
||||
}
|
||||
|
||||
function noTryCatch() {
|
||||
return window.location.search.match(/catch=false/);
|
||||
}
|
||||
|
||||
function searchWithCatch() {
|
||||
var params = jasmine.HtmlReporter.parameters(window.document);
|
||||
var removed = false;
|
||||
var i = 0;
|
||||
|
||||
while (!removed && i < params.length) {
|
||||
if (params[i].match(/catch=/)) {
|
||||
params.splice(i, 1);
|
||||
removed = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
|
||||
return params.join("&");
|
||||
}
|
||||
|
||||
function setExceptionHandling() {
|
||||
var chxCatch = document.getElementById('no_try_catch');
|
||||
|
||||
if (noTryCatch()) {
|
||||
chxCatch.setAttribute('checked', true);
|
||||
jasmine.CATCH_EXCEPTIONS = false;
|
||||
}
|
||||
chxCatch.onclick = function() {
|
||||
window.location.search = searchWithCatch();
|
||||
};
|
||||
}
|
||||
};
|
||||
jasmine.HtmlReporter.parameters = function(doc) {
|
||||
var paramStr = doc.location.search.substring(1);
|
||||
var params = [];
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
}
|
||||
return params;
|
||||
}
|
||||
jasmine.HtmlReporter.sectionLink = function(sectionName) {
|
||||
var link = '?';
|
||||
var params = [];
|
||||
|
||||
if (sectionName) {
|
||||
params.push('spec=' + encodeURIComponent(sectionName));
|
||||
}
|
||||
if (!jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
if (params.length > 0) {
|
||||
link += params.join("&");
|
||||
}
|
||||
|
||||
return link;
|
||||
};
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
||||
jasmine.HtmlReporter.ReporterView = function(dom) {
|
||||
this.startedAt = new Date();
|
||||
this.runningSpecCount = 0;
|
||||
this.completeSpecCount = 0;
|
||||
this.passedCount = 0;
|
||||
this.failedCount = 0;
|
||||
this.skippedCount = 0;
|
||||
|
||||
this.createResultsMenu = function() {
|
||||
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
||||
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
||||
' | ',
|
||||
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
||||
|
||||
this.summaryMenuItem.onclick = function() {
|
||||
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
||||
};
|
||||
|
||||
this.detailsMenuItem.onclick = function() {
|
||||
showDetails();
|
||||
};
|
||||
};
|
||||
|
||||
this.addSpecs = function(specs, specFilter) {
|
||||
this.totalSpecCount = specs.length;
|
||||
|
||||
this.views = {
|
||||
specs: {},
|
||||
suites: {}
|
||||
};
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
var spec = specs[i];
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
|
||||
if (specFilter(spec)) {
|
||||
this.runningSpecCount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.specComplete = function(spec) {
|
||||
this.completeSpecCount++;
|
||||
|
||||
if (isUndefined(this.views.specs[spec.id])) {
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
||||
}
|
||||
|
||||
var specView = this.views.specs[spec.id];
|
||||
|
||||
switch (specView.status()) {
|
||||
case 'passed':
|
||||
this.passedCount++;
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.failedCount++;
|
||||
break;
|
||||
|
||||
case 'skipped':
|
||||
this.skippedCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
specView.refresh();
|
||||
this.refresh();
|
||||
};
|
||||
|
||||
this.suiteComplete = function(suite) {
|
||||
var suiteView = this.views.suites[suite.id];
|
||||
if (isUndefined(suiteView)) {
|
||||
return;
|
||||
}
|
||||
suiteView.refresh();
|
||||
};
|
||||
|
||||
this.refresh = function() {
|
||||
|
||||
if (isUndefined(this.resultsMenu)) {
|
||||
this.createResultsMenu();
|
||||
}
|
||||
|
||||
// currently running UI
|
||||
if (isUndefined(this.runningAlert)) {
|
||||
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
|
||||
dom.alert.appendChild(this.runningAlert);
|
||||
}
|
||||
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
||||
|
||||
// skipped specs UI
|
||||
if (isUndefined(this.skippedAlert)) {
|
||||
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
|
||||
}
|
||||
|
||||
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.skippedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.skippedAlert);
|
||||
}
|
||||
|
||||
// passing specs UI
|
||||
if (isUndefined(this.passedAlert)) {
|
||||
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
|
||||
}
|
||||
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
||||
|
||||
// failing specs UI
|
||||
if (isUndefined(this.failedAlert)) {
|
||||
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
|
||||
}
|
||||
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
|
||||
|
||||
if (this.failedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.failedAlert);
|
||||
dom.alert.appendChild(this.resultsMenu);
|
||||
}
|
||||
|
||||
// summary info
|
||||
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
|
||||
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
||||
};
|
||||
|
||||
this.complete = function() {
|
||||
dom.alert.removeChild(this.runningAlert);
|
||||
|
||||
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.failedCount === 0) {
|
||||
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
||||
} else {
|
||||
showDetails();
|
||||
}
|
||||
|
||||
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function showDetails() {
|
||||
if (dom.reporter.className.search(/showDetails/) === -1) {
|
||||
dom.reporter.className += " showDetails";
|
||||
}
|
||||
}
|
||||
|
||||
function isUndefined(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
}
|
||||
|
||||
function isDefined(obj) {
|
||||
return !isUndefined(obj);
|
||||
}
|
||||
|
||||
function specPluralizedFor(count) {
|
||||
var str = count + " spec";
|
||||
if (count > 1) {
|
||||
str += "s"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
|
||||
|
||||
|
||||
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
||||
this.spec = spec;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.symbol = this.createDom('li', { className: 'pending' });
|
||||
this.dom.symbolSummary.appendChild(this.symbol);
|
||||
|
||||
this.summary = this.createDom('div', { className: 'specSummary' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.description)
|
||||
);
|
||||
|
||||
this.detail = this.createDom('div', { className: 'specDetail' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.getFullName())
|
||||
);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.spec);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
||||
this.symbol.className = this.status();
|
||||
|
||||
switch (this.status()) {
|
||||
case 'skipped':
|
||||
break;
|
||||
|
||||
case 'passed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
this.appendFailureDetail();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
||||
this.summary.className += ' ' + this.status();
|
||||
this.appendToSummary(this.spec, this.summary);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
this.detail.className += ' ' + this.status();
|
||||
|
||||
var resultItems = this.spec.results().getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
this.detail.appendChild(messagesDiv);
|
||||
this.dom.details.appendChild(this.detail);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
this.suite = suite;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.element = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
|
||||
);
|
||||
|
||||
this.appendToSummary(this.suite, this.element);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.suite);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
||||
this.element.className += " " + this.status();
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
||||
|
||||
/* @deprecated Use jasmine.HtmlReporter instead
|
||||
*/
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('span', { className: 'title' }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap.spec) {
|
||||
return true;
|
||||
}
|
||||
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||
};
|
|
@ -0,0 +1,82 @@
|
|||
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
||||
|
||||
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
|
||||
#HTMLReporter a { text-decoration: none; }
|
||||
#HTMLReporter a:hover { text-decoration: underline; }
|
||||
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
|
||||
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
|
||||
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#HTMLReporter .version { color: #aaaaaa; }
|
||||
#HTMLReporter .banner { margin-top: 14px; }
|
||||
#HTMLReporter .duration { color: #aaaaaa; float: right; }
|
||||
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
|
||||
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
|
||||
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
|
||||
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
|
||||
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
|
||||
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
|
||||
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||
#HTMLReporter .runningAlert { background-color: #666666; }
|
||||
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
|
||||
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
|
||||
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
|
||||
#HTMLReporter .passingAlert { background-color: #a6b779; }
|
||||
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
|
||||
#HTMLReporter .failingAlert { background-color: #cf867e; }
|
||||
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
|
||||
#HTMLReporter .results { margin-top: 14px; }
|
||||
#HTMLReporter #details { display: none; }
|
||||
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .summary { display: none; }
|
||||
#HTMLReporter.showDetails #details { display: block; }
|
||||
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter .summary { margin-top: 14px; }
|
||||
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
|
||||
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
|
||||
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
|
||||
#HTMLReporter .description + .suite { margin-top: 0; }
|
||||
#HTMLReporter .suite { margin-top: 14px; }
|
||||
#HTMLReporter .suite a { color: #333333; }
|
||||
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
|
||||
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
|
||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
||||
#HTMLReporter .resultMessage span.result { display: block; }
|
||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||
|
||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
||||
#TrivialReporter .runner.running { background-color: yellow; }
|
||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
||||
#TrivialReporter .suite .suite { margin: 5px; }
|
||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
||||
#TrivialReporter .failed { background-color: #fbb; }
|
||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,86 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test JSLint</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
|
||||
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="lib/underscore.js"></script>
|
||||
<script type="text/javascript" src="lib/jslint.js"></script>
|
||||
|
||||
|
||||
|
||||
<!-- views -->
|
||||
<script type="text/javascript" src="../js/views/aboutView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/collectionView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/collectionsItemView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/collectionsView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/dashboardView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/documentSourceView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/documentView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/documentsView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/footerView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/logsView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/navigationView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/newCollectionView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/queryView.js"></script>
|
||||
<script type="text/javascript" src="../js/views/shellView.js"></script>
|
||||
|
||||
<!-- helper: checked @ 31.05.2013 --!>
|
||||
<!--<script type="text/javascript" src="../js/arango/arango.js"></script> --!>
|
||||
<!-- routers --!>
|
||||
<script type="text/javascript" src="../js/routers/router.js"></script>
|
||||
<!-- models --!>
|
||||
<script type="text/javascript" src="../js/models/arangoCollection.js"></script>
|
||||
<script type="text/javascript" src="../js/models/arangoDocument.js"></script>
|
||||
<script type="text/javascript" src="../js/models/arangoLog.js"></script>
|
||||
<script type="text/javascript" src="../js/models/arangoStatistics.js"></script>
|
||||
<script type="text/javascript" src="../js/models/arangoStatisticsDescription.js"></script>
|
||||
<!-- collections --!>
|
||||
<script type="text/javascript" src="../js/collections/arangoCollections.js"></script>
|
||||
<script type="text/javascript" src="../js/collections/arangoDocument.js"></script>
|
||||
<script type="text/javascript" src="../js/collections/arangoDocuments.js"></script>
|
||||
<script type="text/javascript" src="../js/collections/arangoDocuments.js"></script>
|
||||
<script type="text/javascript" src="../js/collections/arangoLogs.js"></script>
|
||||
<script type="text/javascript" src="../js/collections/arangoStatisticsCollection.js"></script>
|
||||
<script type="text/javascript" src="../js/collections/arangoStatisticsDescriptionCollection.js"></script>
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="specJSLint/jsLintSpec.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
jasmineEnv.execute();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,68 @@
|
|||
describe('JSLint', function () {
|
||||
var options = {},
|
||||
lint = /^\/specJSLint|.jsLintSpec\.js$/;
|
||||
|
||||
function get(path) {
|
||||
path = path + "?" + new Date().getTime();
|
||||
|
||||
var xhr;
|
||||
try {
|
||||
xhr = new jasmine.XmlHttpRequest();
|
||||
xhr.open("GET", path, false);
|
||||
xhr.send(null);
|
||||
} catch (e) {
|
||||
throw new Error("couldn't fetch " + path + ": " + e);
|
||||
}
|
||||
if (xhr.status < 200 || xhr.status > 299) {
|
||||
throw new Error("Could not load '" + path + "'.");
|
||||
}
|
||||
|
||||
return xhr.responseText;
|
||||
}
|
||||
|
||||
describe('checking codeFiles', function() {
|
||||
var files = /^(.*lib\/.*)|(.*Spec\.js)$/;
|
||||
|
||||
_.each(document.getElementsByTagName('script'), function (element) {
|
||||
var script = element.getAttribute('src');
|
||||
if (files.test(script)) {
|
||||
return;
|
||||
}
|
||||
it(script, function () {
|
||||
var self = this;
|
||||
var source = get(script);
|
||||
var result = JSLINT(source, options);
|
||||
_.each(JSLINT.errors, function (error) {
|
||||
self.addMatcherResult(new jasmine.ExpectationResult({
|
||||
passed: false,
|
||||
message: "line " + error.line + ' - ' + error.reason + ' - ' + error.evidence
|
||||
}));
|
||||
});
|
||||
expect(true).toBe(true); // force spec to show up if there are no errors
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checking specFiles', function() {
|
||||
var files = /^\/spec*|.*Spec\.js$/;
|
||||
|
||||
_.each(document.getElementsByTagName('script'), function (element) {
|
||||
var script = element.getAttribute('src');
|
||||
if (!files.test(script) || lint.test(script)) {
|
||||
return;
|
||||
}
|
||||
it(script, function () {
|
||||
var self = this;
|
||||
var source = get(script);
|
||||
var result = JSLINT(source, options);
|
||||
_.each(JSLINT.errors, function (error) {
|
||||
self.addMatcherResult(new jasmine.ExpectationResult({
|
||||
passed: false,
|
||||
message: "line " + error.line + ' - ' + error.reason + ' - ' + error.evidence
|
||||
}));
|
||||
});
|
||||
expect(true).toBe(true); // force spec to show up if there are no errors
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue