Skip to content

Instantly share code, notes, and snippets.

@pardo-bsso
Created February 10, 2014 16:18
Show Gist options
  • Select an option

  • Save pardo-bsso/8918822 to your computer and use it in GitHub Desktop.

Select an option

Save pardo-bsso/8918822 to your computer and use it in GitHub Desktop.
some data to try the ui of Mosto Messages.
var dummies = [
{
"status": "one-shot",
"code": 202,
"end": 1392744477305,
"description": "OUT OF SYNC",
"reference": "",
"sticky": false,
"start": 1392733593763,
"message": "Melted was out of sync",
"_id": "877403b5-a055-4c93-b70f-5acc28196aad"
},
{
"status": "failing",
"code": 502,
"end": 1392295549827,
"description": "FILE NOT FOUND",
"reference": "",
"sticky": true,
"start": 1392251018238,
"message": "Requested media file cannot be found",
"_id": "2ad9db53-be20-4949-9331-5dfae998cef2"
},
{
"status": "one-shot",
"code": 203,
"end": 1392242111749,
"description": "STARTED PLAYING",
"reference": "",
"sticky": false,
"start": 1392068945541,
"message": "Melted was stopped and was started",
"_id": "bc53fba2-1d64-4556-a646-69465fc3e34d"
},
{
"status": "failing",
"code": 502,
"end": 1392703938722,
"description": "FILE NOT FOUND",
"reference": "",
"sticky": true,
"start": 1392475722624,
"message": "Requested media file cannot be found",
"_id": "eebd4703-f2ee-48d3-b5d9-b5cb112027b0"
},
{
"status": "one-shot",
"code": 202,
"end": 1392748759695,
"description": "OUT OF SYNC",
"reference": "",
"sticky": false,
"start": 1392114625603,
"message": "Melted was out of sync",
"_id": "555e3400-335b-4c09-8f97-9600fb9a216a"
},
{
"status": "one-shot",
"code": 203,
"end": 1392185046553,
"description": "STARTED PLAYING",
"reference": "",
"sticky": false,
"start": 1392011081903,
"message": "Melted was stopped and was started",
"_id": "08066773-3849-4c02-9447-cb337851ac77"
},
{
"status": "one-shot",
"code": 202,
"end": 1392508453594,
"description": "OUT OF SYNC",
"reference": "",
"sticky": false,
"start": 1392320702342,
"message": "Melted was out of sync",
"_id": "ba994fa9-208c-4455-b83f-8996fd4c2bdd"
},
{
"status": "one-shot",
"code": 201,
"end": 1392566042145,
"description": "BLANK PLAYING",
"reference": "",
"sticky": false,
"start": 1392300321195,
"message": "Blank clip playing",
"_id": "519cc6c1-4015-44d9-9e44-34033e21761f"
},
{
"status": "one-shot",
"code": 201,
"end": 1392775542743,
"description": "BLANK PLAYING",
"reference": "",
"sticky": false,
"start": 1392569202962,
"message": "Blank clip playing",
"_id": "d0b09181-85fa-4cab-babe-664902da661d"
},
{
"status": "one-shot",
"code": 203,
"end": 1392515962589,
"description": "STARTED PLAYING",
"reference": "",
"sticky": false,
"start": 1392073453946,
"message": "Melted was stopped and was started",
"_id": "54f60fb0-7464-4593-a7ab-88284f3aba83"
},
{
"status": "one-shot",
"code": 203,
"end": 1392770285000,
"description": "STARTED PLAYING",
"reference": "",
"sticky": false,
"start": 1391996745226,
"message": "Melted was stopped and was started",
"_id": "3c51c882-438e-41f6-b75a-9f3f38ca004a"
},
{
"status": "failing",
"code": 501,
"end": 1392329368076,
"description": "MELTED CONNECTION ERROR",
"reference": "",
"sticky": true,
"start": 1392211220972,
"message": "Cannot connect to melted",
"_id": "4cd62a0d-5ade-4e72-9a0b-92115ccdf53c"
},
{
"status": "failing",
"code": 501,
"end": 1392404820396,
"description": "MELTED CONNECTION ERROR",
"reference": "",
"sticky": true,
"start": 1391931151835,
"message": "Cannot connect to melted",
"_id": "8f1f10af-f679-40ea-9ad1-8752b5f8b391"
},
{
"status": "failing",
"code": 500,
"end": 1392686072584,
"description": "MOSTO DEAD",
"reference": "",
"sticky": true,
"start": 1392654034926,
"message": "Mosto is silent",
"_id": "6e7bdd76-860c-4db6-b25d-9f8e0a6c351d"
},
{
"status": "one-shot",
"code": 201,
"end": 1392350922941,
"description": "BLANK PLAYING",
"reference": "",
"sticky": false,
"start": 1392293684534,
"message": "Blank clip playing",
"_id": "5b58a57d-8499-4db7-8b55-184db093098b"
},
{
"status": "failing",
"code": 500,
"end": 1392767332830,
"description": "MOSTO DEAD",
"reference": "",
"sticky": true,
"start": 1392711839332,
"message": "Mosto is silent",
"_id": "12c99103-fd7e-4529-bf21-a615b8fe3207"
},
{
"status": "failing",
"code": 502,
"end": 1392725967903,
"description": "FILE NOT FOUND",
"reference": "",
"sticky": true,
"start": 1392681923839,
"message": "Requested media file cannot be found",
"_id": "277aca7c-3912-4c22-a354-d77def6faa94"
},
{
"status": "failing",
"code": 500,
"end": 1392593470888,
"description": "MOSTO DEAD",
"reference": "",
"sticky": true,
"start": 1392538037929,
"message": "Mosto is silent",
"_id": "23e90d5c-7c10-4f16-b5cb-2dc6b4ebaca7"
},
{
"status": "one-shot",
"code": 203,
"end": 1392682866436,
"description": "STARTED PLAYING",
"reference": "",
"sticky": false,
"start": 1392388882946,
"message": "Melted was stopped and was started",
"_id": "2f8d23ce-f084-43f9-964a-303784246932"
},
{
"status": "one-shot",
"code": 202,
"end": 1392585337172,
"description": "OUT OF SYNC",
"reference": "",
"sticky": false,
"start": 1392270436114,
"message": "Melted was out of sync",
"_id": "dfce7f0e-6fff-4fbd-b778-d1820fdb3d68"
}
];
var MostoCodes = { // message code and their descriptions
// FORMAT: [description, default message[, is sticky (boolean)]]
// sticky: status = failing
// 1xx are info codes
// 2xx are warning codes
201: ["BLANK PLAYING", "Blank clip playing"],
202: ["OUT OF SYNC", "Melted was out of sync"],
203: ["STARTED PLAYING", "Melted was stopped and was started"],
// 4xx are "client error" codes. A problem in db content, for example
// 5xx are "server error" codes. Mosto couldn't find the requested file,
// connection problem with melted, etc
500: ["MOSTO DEAD", "Mosto is silent", true],
501: ["MELTED CONNECTION ERROR", "Cannot connect to melted", true],
502: ["FILE NOT FOUND", "Requested media file cannot be found", true],
};
var MostoMessage = Backbone.Model.extend({
urlRoot: 'message',
backend: 'messagesBackend',
idAttribute: '_id',
defaults: {
code: -1,
description: "INVALID",
message: "INVALID",
status: "one-shot", // "one-shot" , "failing"
reference: "",
sticky: false,
start: 0, // moment.valueOf() , something like 1392046763435
end: 0, // moment.valueOf() , something like 1392046763435
},
});
var MostoMessagesCollection = Backbone.Collection.extend({
url: 'message',
model: MostoMessage,
backend: 'messagebackend',
comparator: function(message) { return -message.get('start') },
});
var MessagesCollection = new MostoMessagesCollection(dummies);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment