Last active
December 15, 2015 07:39
-
-
Save lacostej/a837f47479df0e94f7dd to your computer and use it in GitHub Desktop.
Unity3d Perf Filter improvement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Unity3d Perf Filter improvement | |
// @namespace http://wewanttoknow.com/ | |
// @version 0.2 | |
// @description make the filtering function in perf a little bit more useful | |
// @author Jerome Lacoste | |
// @match https://developer.cloud.unity3d.com/gameperf/* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
// Your code here... | |
Pagination.prototype.filterDataBy = function(argos) { | |
var options = {}; | |
argos.split(' ').forEach(function(val) { | |
var array = val.split(':'); | |
var key, value; | |
if (array.length == 2) { | |
key = array[0]; | |
value = array[1]; | |
} else { | |
key = 'text'; | |
value = array[0]; | |
} | |
options[key] = value; | |
}); | |
var text = options['text']; | |
var version = options['v']; | |
var message = options['m']; | |
var stacktrace = options['s']; | |
console.log("Filtering by: version [" + version + "] message:[" + message + "] stack:[" + stacktrace + "] text:[" + text + "]"); | |
this.originalData || (this.originalData = _.map(this.data, _.clone)), "" === text ? (this.data = _.map(this.originalData, _.clone), this.sortDataBy({ | |
sortField: this.sortField, | |
sortOrder: this.sortOrder | |
})) : (this.data = _.filter(this.originalData, function(crash) { | |
var match = true; | |
if (version) | |
match = match && crash.version.toLowerCase().indexOf(version.toLowerCase()) > -1; | |
if (stacktrace) | |
match = match && crash.stack_trace.toLowerCase().indexOf(stacktrace.toLowerCase()) > -1; | |
if (message) | |
match = match && crash.message.toLowerCase().indexOf(message.toLowerCase()) > -1; | |
if (text) | |
match = match && (crash.message.toLowerCase().indexOf(text.toLowerCase()) > -1 || crash.stack_trace.toLowerCase().indexOf(text.toLowerCase()) > -1); | |
return match; | |
}), this.sortDataBy({ | |
sortField: this.sortField, | |
sortOrder: this.sortOrder | |
})) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment