-
Notifications
You must be signed in to change notification settings - Fork 7
/
inject.js
89 lines (87 loc) · 5.14 KB
/
inject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// This script runs in the website context.
(function(){
function join(array) {
var str = '';
for (var i = 0; i < array.length; i++) {
if (i !== 0) str += ',';
str += array[i];
}
return str;
}
var frameworks = {
'ActiveJS': { abbr: 'AJS', version: ['ActiveSupport'] },
'AngularJS': { abbr: 'ng', version: ['angular', 'version', 'full'] },
'Backbone.js': { abbr: 'BB', version: ['Backbone', 'VERSION'] },
'Base2': { abbr: 'Base', version: ['base2', 'version'] },
'Clientcide Libraries': { abbr: 'Moo', version: ['Clientcide', 'version'] },
'Crafty': { abbr: 'Crf', version: ['Crafty', 'init'] },
'Cufon': { abbr: 'Cuf', version: ['Cufon'] },
'D3': { abbr: 'D3', version: ['d3', 'version'] },
'DHTMLX': { abbr: 'DHT', version: ['dhtmlx'] },
'Dojo': { abbr: 'Dojo', version: function() {
return window.dojo.version.toString();
} },
'Ember': { abbr: 'Emb', version: ['Ember', 'VERSION'] },
'Ext JS': { abbr: 'Ext', version: ['Ext', 'version'] },
'Glow': { abbr: 'Glw', version: ['glow', 'VERSION'] },
'JavaScriptMVC': { abbr: 'MVC', version: ['steal', 'fn'] },
'jQuery': { abbr: 'jQ', version: ['jQuery', 'fn', 'jquery'] },
'jQuery UI': { abbr: 'jQUI', version: ['$', 'ui', 'version'] },
'Knockout.js': { abbr: 'ko', version: ['ko', 'version'] },
'Midori': { abbr: 'Mid', version: ['midori', 'domReady'] },
'Modernizr': { abbr: 'Mzr', version: ['Modernizr', '_version'] },
'MochiKit': { abbr: 'MK', version: ['MochiKit', 'MochiKit', 'VERSION'] },
'MooTools A.R.T.': { abbr: 'Moo', version: ['ART', 'version'] },
'MooTools Core': { abbr: 'Moo', version: ['MooTools', 'version'] },
'MooTools More': { abbr: 'Moo', version: ['MooTools', 'More', 'version'] },
'Processing.js': { abbr: 'Prc', version: ['Processing', 'version'] },
'Prototype': { abbr: 'Pro', version: ['Prototype', 'Version'] },
'Qooxdoo': { abbr: 'Qxd', version: ['qx', '$$libraries', 'qx', 'version'] },
'Raphaël': { abbr: 'Rël', version: ['Raphael', 'version'] },
'RequireJS': { abbr: 'rjs', version: ['requirejs', 'version'] },
'Rico': { abbr: 'Ric', version: ['Rico', 'Version'] },
'RightJS': { abbr: 'Rig', version: ['RightJS', 'version'] },
'Sammy.js': { abbr: 'Sam', version: ['Sammy', 'VERSION'] },
'Script.aculo.us': { abbr: 'Scr', version: ['Scriptaculous', 'Version'] },
'Scripty2': { abbr: 'Sc2', version: ['S2', 'Version'] },
'Snack': { abbr: 'Snc', version: ['snack', 'v'] },
'Spine': { abbr: 'Spi', version: ['Spine', 'version'] },
'SproutCore': { abbr: 'SpC', version: ['SC', 'isReady'] },
'Spry': { abbr: 'Spr', version: ['Spry', '$'] },
'Underscore.js': { abbr: '_', version: ['_', 'VERSION'] },
'YUI 2': { abbr: 'YUI', version: ['YAHOO', 'VERSION'] },
'YUI 3': { abbr: 'YUI', version: ['YUI', 'version'] },
'Zepto': { abbr: 'Zept', version: ['Zepto'] },
'ZK': { abbr: 'ZK', version: ['zk', 'version'] }
};
var data = [];
for (var name in frameworks) {
if (frameworks.hasOwnProperty(name)) {
var framework = frameworks[name];
var version = null;
if (typeof framework.version == 'function') {
try {
version = framework.version();
} catch (e) { }
} else {
version = window;
for (var i = 0; i < framework.version.length; i++) {
version = version && version[framework.version[i]];
}
}
if (version) {
var info = '{"name":"' + name + '"';
info += ',"abbr":"' + framework.abbr + '"';
if (typeof version == 'string' && version != '%build%') {
info += ',"version":"' + version + '"';
}
info += '}';
data[data.length] = info;
}
}
}
var messageElement = document.createElement('div');
messageElement.textContent = '[' + join(data) + ']';
messageElement.id = 'frameworks-data';
document.body.appendChild(messageElement);
})();