Skip to content

Commit 70facc1

Browse files
author
Lionel Laské
committed
Standardize indentation in sugar-web activity.js
1 parent 924c807 commit 70facc1

File tree

34 files changed

+99
-1147
lines changed

34 files changed

+99
-1147
lines changed

activities/Abecedarium.activity/lib/sugar-web/activity/activity.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ define(["sugar-web/activity/shortcut",
22
"sugar-web/bus",
33
"sugar-web/env",
44
"sugar-web/datastore",
5-
"sugar-web/presence",
5+
"sugar-web/presence",
66
"sugar-web/graphics/icon",
7-
"sugar-web/graphics/activitypalette"],
8-
function (shortcut, bus, env, datastore, presence, icon, activitypalette) {
9-
7+
"sugar-web/graphics/activitypalette"], function (
8+
shortcut, bus, env, datastore, presence, icon, activitypalette) {
109

1110
'use strict';
1211

@@ -22,8 +21,6 @@ define(["sugar-web/activity/shortcut",
2221
activity.setup = function () {
2322
bus.listen();
2423

25-
26-
2724
function sendPauseEvent() {
2825
var pauseEvent = document.createEvent("CustomEvent");
2926
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/Blockrain.activity/lib/sugar-web/activity/activity.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ define(["sugar-web/activity/shortcut",
2121
activity.setup = function () {
2222
bus.listen();
2323

24-
2524
function sendPauseEvent() {
2625
var pauseEvent = document.createEvent("CustomEvent");
2726
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/Calligra.activity/lib/sugar-web/activity/activity.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
define([
2-
"sugar-web/activity/shortcut",
1+
define(["sugar-web/activity/shortcut",
32
"sugar-web/bus",
43
"sugar-web/env",
54
"sugar-web/datastore",
@@ -22,7 +21,6 @@ define([
2221
activity.setup = function () {
2322
bus.listen();
2423

25-
2624
function sendPauseEvent() {
2725
var pauseEvent = document.createEvent("CustomEvent");
2826
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/Chat.activity/lib/sugar-web/activity/activity.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ define(["sugar-web/activity/shortcut",
44
"sugar-web/datastore",
55
"sugar-web/presence",
66
"sugar-web/graphics/icon",
7-
"sugar-web/graphics/activitypalette"], function (shortcut, bus, env, datastore, presence, icon, activitypalette) {
7+
"sugar-web/graphics/activitypalette"], function (
8+
shortcut, bus, env, datastore, presence, icon, activitypalette) {
89

910
'use strict';
1011

@@ -20,8 +21,6 @@ define(["sugar-web/activity/shortcut",
2021
activity.setup = function () {
2122
bus.listen();
2223

23-
24-
2524
function sendPauseEvent() {
2625
var pauseEvent = document.createEvent("CustomEvent");
2726
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/Chess.activity/lib/sugar-web/activity/activity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ define(["sugar-web/activity/shortcut",
55
"sugar-web/presence",
66
"sugar-web/graphics/icon",
77
"sugar-web/graphics/activitypalette"], function (
8-
shortcut, bus, env, datastore, presence, icon, activitypalette) {
8+
shortcut, bus, env, datastore, presence, icon, activitypalette) {
99

1010
'use strict';
1111

activities/Clock.activity/lib/sugar-web/activity/activity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ define(["sugar-web/activity/shortcut",
44
"sugar-web/datastore",
55
"sugar-web/presence",
66
"sugar-web/graphics/icon",
7-
"sugar-web/graphics/activitypalette"], function (shortcut, bus, env, datastore, presence, icon, activitypalette) {
7+
"sugar-web/graphics/activitypalette"], function (
8+
shortcut, bus, env, datastore, presence, icon, activitypalette) {
89

910
'use strict';
1011

@@ -20,7 +21,6 @@ define(["sugar-web/activity/shortcut",
2021
activity.setup = function () {
2122
bus.listen();
2223

23-
2424
function sendPauseEvent() {
2525
var pauseEvent = document.createEvent("CustomEvent");
2626
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/Constellation.activity/lib/sugar-web/activity/activity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ define(["sugar-web/activity/shortcut",
44
"sugar-web/datastore",
55
"sugar-web/presence",
66
"sugar-web/graphics/icon",
7-
"sugar-web/graphics/activitypalette"], function (shortcut, bus, env, datastore, presence, icon, activitypalette) {
7+
"sugar-web/graphics/activitypalette"], function (
8+
shortcut, bus, env, datastore, presence, icon, activitypalette) {
89

910
'use strict';
1011

@@ -20,7 +21,6 @@ define(["sugar-web/activity/shortcut",
2021
activity.setup = function () {
2122
bus.listen();
2223

23-
2424
function sendPauseEvent() {
2525
var pauseEvent = document.createEvent("CustomEvent");
2626
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/EbookReader.activity/lib/sugar-web/activity/activity.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
define([
2-
"sugar-web/activity/shortcut",
1+
define(["sugar-web/activity/shortcut",
32
"sugar-web/bus",
43
"sugar-web/env",
54
"sugar-web/datastore",
@@ -22,7 +21,6 @@ define([
2221
activity.setup = function () {
2322
bus.listen();
2423

25-
2624
function sendPauseEvent() {
2725
var pauseEvent = document.createEvent("CustomEvent");
2826
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/Falabracman.activity/lib/sugar-web/activity/activity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ define(["sugar-web/activity/shortcut",
44
"sugar-web/datastore",
55
"sugar-web/presence",
66
"sugar-web/graphics/icon",
7-
"sugar-web/graphics/activitypalette"], function (shortcut, bus, env, datastore, presence, icon, activitypalette) {
7+
"sugar-web/graphics/activitypalette"], function (
8+
shortcut, bus, env, datastore, presence, icon, activitypalette) {
89

910
'use strict';
1011

@@ -20,7 +21,6 @@ define(["sugar-web/activity/shortcut",
2021
activity.setup = function () {
2122
bus.listen();
2223

23-
2424
function sendPauseEvent() {
2525
var pauseEvent = document.createEvent("CustomEvent");
2626
pauseEvent.initCustomEvent('activityPause', false, false, {

activities/FoodChain.activity/lib/sugar-web/activity/activity.js

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
define([
2-
"sugar-web/activity/shortcut",
3-
"sugar-web/bus",
4-
"sugar-web/env",
5-
"sugar-web/datastore",
6-
"sugar-web/presence",
7-
"sugar-web/graphics/icon",
8-
"sugar-web/graphics/activitypalette"], function (
9-
shortcut, bus, env, datastore, presence, icon, activitypalette) {
1+
define(["sugar-web/activity/shortcut",
2+
"sugar-web/bus",
3+
"sugar-web/env",
4+
"sugar-web/datastore",
5+
"sugar-web/presence",
6+
"sugar-web/graphics/icon",
7+
"sugar-web/graphics/activitypalette"], function (
8+
shortcut, bus, env, datastore, presence, icon, activitypalette) {
109

1110
'use strict';
1211

1312
var datastoreObject = null;
1413

15-
var presenceCallback = null;
16-
var presenceResponse = null;
14+
var presenceCallback = null;
15+
var presenceResponse = null;
1716

1817
var activity = {};
1918

@@ -22,12 +21,11 @@ define([
2221
activity.setup = function () {
2322
bus.listen();
2423

25-
2624
function sendPauseEvent() {
27-
var pauseEvent = document.createEvent("CustomEvent");
28-
pauseEvent.initCustomEvent('activityPause', false, false, {
29-
'cancelable': true
30-
});
25+
var pauseEvent = document.createEvent("CustomEvent");
26+
pauseEvent.initCustomEvent('activityPause', false, false, {
27+
'cancelable': true
28+
});
3129
window.dispatchEvent(pauseEvent);
3230
}
3331
bus.onNotification("activity.pause", sendPauseEvent);
@@ -37,14 +35,14 @@ define([
3735
// call activity.close() after storing.
3836

3937
function sendStopEvent() {
40-
var stopEvent = document.createEvent("CustomEvent");
41-
stopEvent.initCustomEvent('activityStop', false, false, {
42-
'cancelable': true
43-
});
38+
var stopEvent = document.createEvent("CustomEvent");
39+
stopEvent.initCustomEvent('activityStop', false, false, {
40+
'cancelable': true
41+
});
4442
var result = window.dispatchEvent(stopEvent);
4543
if (result) {
46-
datastoreObject.save(function () {
47-
datastore.waitPendingSave(function () {
44+
datastoreObject.save(function() {
45+
datastore.waitPendingSave(function() {
4846
activity.close();
4947
});
5048
});
@@ -65,21 +63,21 @@ define([
6563
var invokerElem =
6664
document.querySelector("#activity-palette .palette-invoker");
6765
icon.colorize(invokerElem, colors);
68-
var buddyIcon = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\
66+
var buddyIcon='<?xml version="1.0" encoding="UTF-8" standalone="no"?>\
6967
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="16" height="16" version="1.0" >\
7068
<g transform="translate(37.943468,-309.4636)">\
7169
<g transform="matrix(0.05011994,0,0,0.05012004,-41.76673,299.66011)" style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-opacity:1">\
7270
<circle transform="matrix(0.969697,0,0,0.969697,-90.879133,125.06999)" style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:20.62502098;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" cx="331.38321" cy="134.2677" r="51.220825" />\
7371
<path d="m 290.55846,302.47333 -58.81513,59.20058 -59.39461,-59.40024 c -25.19828,-24.48771 -62.7038,13.33148 -38.1941,37.98719 l 60.04451,58.9817 -59.73639,59.42563 c -24.83976,24.97559 12.91592,63.26505 37.66786,37.75282 l 59.95799,-59.28294 58.75912,59.21065 c 24.50656,25.09065 62.43116,-13.00322 37.87956,-37.85772 l -59.24184,-59.02842 58.87574,-59.14782 c 25.1689,-25.18348 -13.0489,-62.75154 -37.80271,-37.84143 z" style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:20.00002098;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />\
7472
</g></g></svg>';
75-
var newicon = buddyIcon.replace(new RegExp("&fill_color;", "g"), colors.fill).replace(new RegExp("&stroke_color;", "g"), colors.stroke);
73+
var newicon = buddyIcon.replace(new RegExp("&fill_color;","g"),colors.fill).replace(new RegExp("&stroke_color;","g"),colors.stroke);
7674
var svg_xml = (new XMLSerializer()).serializeToString((new DOMParser()).parseFromString(newicon, "text/xml"));
7775
var canvas = document.createElement('canvas');
7876
canvas.width = canvas.height = 16;
7977
var ctx = canvas.getContext('2d');
8078
var img = new Image();
8179
img.src = "data:image/svg+xml;base64," + btoa(svg_xml);
82-
img.onload = function () {
80+
img.onload = function() {
8381
ctx.drawImage(img, 0, 0);
8482
var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
8583
link.type = 'image/x-icon';
@@ -99,64 +97,64 @@ define([
9997

10098
env.getEnvironment(function (error, environment) {
10199
user = environment.user;
102-
var l10n = { "en": "{{name}} Activity", "fr": "Activité {{name}}", "es": "Actividad {{name}}", "pt": "{{name}} Atividade", "de": "Aktivität {{name}}" };
100+
var l10n ={"en":"{{name}} Activity","fr":"Activité {{name}}","es":"Actividad {{name}}","pt":"{{name}} Atividade","de":"Aktivität {{name}}"};
103101
var activityName = "";
104-
for (var i = 0; i < environment.user.activities.length; i++) {
102+
for (var i = 0 ; i < environment.user.activities.length ; i++) {
105103
if (environment.user.activities[i].id == environment.bundleId) {
106104
activityName = environment.user.activities[i].name;
107105
break;
108106
}
109107
}
110-
document.title = (l10n[environment.user.language] || l10n["en"]).replace("{{name}}", activityName) + " - Sugarizer";
108+
document.title = (l10n[environment.user.language]||l10n["en"]).replace("{{name}}", activityName)+" - Sugarizer";
111109
if (!environment.objectId) {
112110
datastoreObject.setMetadata({
113-
"title": (l10n[environment.user.language] || l10n["en"]).replace("{{name}}", environment.activityName),
111+
"title": (l10n[environment.user.language]||l10n["en"]).replace("{{name}}", environment.activityName),
114112
"title_set_by_user": "0",
115113
"activity": environment.bundleId,
116114
"activity_id": environment.activityId
117115
});
118116
}
119-
if (env.isSugarizer()) {
120-
presence.joinNetwork(function (error, presence) {
121-
if (environment.sharedId) {
122-
presence.joinSharedActivity(environment.sharedId, function () {
123-
var group_color = presence.getSharedInfo().colorvalue;
124-
icon.colorize(activityButton, group_color);
125-
datastoreObject.setMetadata({ "buddy_color": group_color });
126-
datastoreObject.save(function () { });
127-
});
128-
}
129-
if (presenceCallback) {
130-
presenceCallback(error, presence);
131-
} else {
132-
presenceResponse = { error: error, presence: presence };
133-
}
134-
});
135-
}
117+
if (env.isSugarizer()) {
118+
presence.joinNetwork(function(error, presence) {
119+
if (environment.sharedId) {
120+
presence.joinSharedActivity(environment.sharedId, function() {
121+
var group_color = presence.getSharedInfo().colorvalue;
122+
icon.colorize(activityButton, group_color);
123+
datastoreObject.setMetadata({"buddy_color":group_color});
124+
datastoreObject.save(function() {});
125+
});
126+
}
127+
if (presenceCallback) {
128+
presenceCallback(error, presence);
129+
} else {
130+
presenceResponse = {error: error, presence: presence};
131+
}
132+
});
133+
}
136134
datastoreObject.save(function () {
137135
datastoreObject.getMetadata(function (error, metadata) {
138136
activityPalette.setTitleDescription(metadata);
139137
});
140138
});
141-
if (environment.standAlone) {
142-
document.getElementById("stop-button").style.visibility = "hidden";
143-
};
139+
if (environment.standAlone) {
140+
document.getElementById("stop-button").style.visibility = "hidden";
141+
};
144142
});
145143
};
146144

147145
activity.getDatastoreObject = function () {
148146
return datastoreObject;
149147
};
150148

151-
activity.getPresenceObject = function (connectionCallback) {
152-
if (presenceResponse == null) {
153-
presenceCallback = connectionCallback;
154-
} else {
155-
connectionCallback(presenceResponse.error, presenceResponse.presence);
156-
presenceResponse = null;
157-
}
158-
return presence;
159-
};
149+
activity.getPresenceObject = function(connectionCallback) {
150+
if (presenceResponse == null) {
151+
presenceCallback = connectionCallback;
152+
} else {
153+
connectionCallback(presenceResponse.error, presenceResponse.presence);
154+
presenceResponse = null;
155+
}
156+
return presence;
157+
};
160158

161159
activity.getXOColor = function (callback) {
162160
function onResponseReceived(error, result) {
@@ -185,7 +183,7 @@ define([
185183
}
186184
}
187185

188-
activity.traceStats("activity", "stop", window.top.sugar.environment.objectId, null);
186+
activity.traceStats("activity","stop",window.top.sugar.environment.objectId,null);
189187
bus.sendMessage("activity.close", [], onResponseReceived);
190188
};
191189

@@ -201,14 +199,14 @@ define([
201199
stat.user_id = user.networkId;
202200
stat.user_agent = navigator.userAgent;
203201
stat.timestamp = new Date().getTime();
204-
stat.client_type = (document.location.protocol.substr(0, 4) == "http" ? "Web App" : "App");
202+
stat.client_type = (document.location.protocol.substr(0,4) == "http" ? "Web App" : "App");
205203
stat.event_source = window.top.sugar.environment.bundleId;
206204
stat.event_object = object;
207205
stat.event_action = action;
208206
stat.event_label = label;
209207
stat.event_value = value;
210208
statslist.push(stat);
211-
datastore.localStorage.setValue('sugar_stats', statslist);
209+
datastore.localStorage.setValue('sugar_stats', statslist);
212210
};
213211

214212
activity.showObjectChooser = function (callback) {

0 commit comments

Comments
 (0)