mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Switch to UUID system.
This commit is contained in:
parent
4fd69061be
commit
70a0d50ede
2 changed files with 44 additions and 31 deletions
|
@ -62,7 +62,7 @@
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col
|
<v-col
|
||||||
v-for="item in items"
|
v-for="item in items"
|
||||||
v-bind:key="item.url"
|
v-bind:key="item.uuid"
|
||||||
cols="12"
|
cols="12"
|
||||||
sm="6"
|
sm="6"
|
||||||
md="4"
|
md="4"
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
<v-list-item
|
<v-list-item
|
||||||
@click="
|
@click="
|
||||||
editDialog.show = true;
|
editDialog.show = true;
|
||||||
editDialog.url = item.url;
|
editDialog.uuid = item.uuid;
|
||||||
editDialog.data.type = item.type;
|
editDialog.data.type = item.type;
|
||||||
editDialog.data.name = item.name;
|
editDialog.data.name = item.name;
|
||||||
editDialog.data.url = item.url;
|
editDialog.data.url = item.url;
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
</v-list-item-action>
|
</v-list-item-action>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
@click="shareDialog.show = true; shareDialog.data.url = item.url; sendAppMessage('web-to-script-request-nearby-users', '')"
|
@click="shareDialog.show = true; shareDialog.data.url = item.url; shareDialog.data.uuid = item.uuid; sendAppMessage('web-to-script-request-nearby-users', '')"
|
||||||
>
|
>
|
||||||
<v-list-item-title>Share</v-list-item-title>
|
<v-list-item-title>Share</v-list-item-title>
|
||||||
<v-list-item-action>
|
<v-list-item-action>
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
</v-list-item-action>
|
</v-list-item-action>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
@click="removeDialog.show = true; removeDialog.url = item.url;"
|
@click="removeDialog.show = true; removeDialog.uuid = item.uuid;"
|
||||||
color="red darken-1"
|
color="red darken-1"
|
||||||
>
|
>
|
||||||
<v-list-item-title>Remove</v-list-item-title>
|
<v-list-item-title>Remove</v-list-item-title>
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
<v-btn
|
<v-btn
|
||||||
color="red"
|
color="red"
|
||||||
class="px-3"
|
class="px-3"
|
||||||
@click="removeDialog.show = false; removeItem(removeDialog.url);"
|
@click="removeDialog.show = false; removeItem(removeDialog.uuid);"
|
||||||
>
|
>
|
||||||
Yes
|
Yes
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
color="blue"
|
color="blue"
|
||||||
class="px-3"
|
class="px-3"
|
||||||
:disabled="!editDialog.valid"
|
:disabled="!editDialog.valid"
|
||||||
@click="editDialog.show = false; editItem(editDialog.url);"
|
@click="editDialog.show = false; editItem(editDialog.uuid);"
|
||||||
>
|
>
|
||||||
Done
|
Done
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -447,7 +447,7 @@
|
||||||
color="blue"
|
color="blue"
|
||||||
class="px-3"
|
class="px-3"
|
||||||
:disabled="!shareDialog.valid"
|
:disabled="!shareDialog.valid"
|
||||||
@click="shareDialog.show = false; shareItem(shareDialog.data.url);"
|
@click="shareDialog.show = false; shareItem(shareDialog.data.uuid, shareDialog.data.url);"
|
||||||
>
|
>
|
||||||
Send
|
Send
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -558,7 +558,7 @@ new Vue({
|
||||||
// The URL is the key (to finding the item we want) so we want to keep track of that.
|
// The URL is the key (to finding the item we want) so we want to keep track of that.
|
||||||
removeDialog: {
|
removeDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
url: null,
|
uuid: null,
|
||||||
},
|
},
|
||||||
addDialog: {
|
addDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
|
@ -571,7 +571,7 @@ new Vue({
|
||||||
editDialog: {
|
editDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
valid: false,
|
valid: false,
|
||||||
url: null, // This is the key, the URL in data is what will overwrite this key.
|
uuid: null, //
|
||||||
data: {
|
data: {
|
||||||
"type": null,
|
"type": null,
|
||||||
"name": null,
|
"name": null,
|
||||||
|
@ -592,6 +592,7 @@ new Vue({
|
||||||
show: false,
|
show: false,
|
||||||
valid: false,
|
valid: false,
|
||||||
data: {
|
data: {
|
||||||
|
"uuid": null, // UUID of the item you want to share. THIS IS THE KEY.
|
||||||
"url": null, // The item you want to share.
|
"url": null, // The item you want to share.
|
||||||
"recipient": null,
|
"recipient": null,
|
||||||
}
|
}
|
||||||
|
@ -621,6 +622,31 @@ new Vue({
|
||||||
this.sendAppMessage("ready", "");
|
this.sendAppMessage("ready", "");
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
createUUID: function() {
|
||||||
|
// http://www.ietf.org/rfc/rfc4122.txt
|
||||||
|
var s = [];
|
||||||
|
var hexDigits = "0123456789abcdef";
|
||||||
|
for (var i = 0; i < 36; i++) {
|
||||||
|
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
||||||
|
}
|
||||||
|
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
|
||||||
|
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
||||||
|
s[8] = s[13] = s[18] = s[23] = "-";
|
||||||
|
|
||||||
|
var uuid = s.join("");
|
||||||
|
return uuid;
|
||||||
|
},
|
||||||
|
pushToItems: function(type, name, url) {
|
||||||
|
var itemToPush =
|
||||||
|
{
|
||||||
|
"type": type,
|
||||||
|
"name": name,
|
||||||
|
"url": url,
|
||||||
|
"uuid": this.createUUID(),
|
||||||
|
};
|
||||||
|
|
||||||
|
this.items.push(itemToPush);
|
||||||
|
},
|
||||||
checkFileType: function(fileType) {
|
checkFileType: function(fileType) {
|
||||||
var detectedItemType = null;
|
var detectedItemType = null;
|
||||||
|
|
||||||
|
@ -682,28 +708,21 @@ new Vue({
|
||||||
itemType = this.checkFileType(detectedFileType[0]);
|
itemType = this.checkFileType(detectedFileType[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemToPush =
|
this.pushToItems(itemType, name, url);
|
||||||
{
|
|
||||||
"type": itemType,
|
|
||||||
"name": name,
|
|
||||||
"url": url,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.items.push(itemToPush);
|
|
||||||
|
|
||||||
this.addDialog.data.name = null;
|
this.addDialog.data.name = null;
|
||||||
this.addDialog.data.url = null;
|
this.addDialog.data.url = null;
|
||||||
},
|
},
|
||||||
removeItem: function(url) {
|
removeItem: function(uuid) {
|
||||||
for (i = 0; i < this.items.length; i++) {
|
for (i = 0; i < this.items.length; i++) {
|
||||||
if (this.items[i].url == url) {
|
if (this.items[i].uuid == uuid) {
|
||||||
this.items.splice(i, 1);
|
this.items.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editItem: function(url) {
|
editItem: function(uuid) {
|
||||||
for (i = 0; i < this.items.length; i++) {
|
for (i = 0; i < this.items.length; i++) {
|
||||||
if (this.items[i].url == url) {
|
if (this.items[i].uuid == uuid) {
|
||||||
this.items[i].type = this.checkItemType(this.editDialog.data.type);
|
this.items[i].type = this.checkItemType(this.editDialog.data.type);
|
||||||
this.items[i].name = this.editDialog.data.name;
|
this.items[i].name = this.editDialog.data.name;
|
||||||
this.items[i].url = this.editDialog.data.url;
|
this.items[i].url = this.editDialog.data.url;
|
||||||
|
@ -721,12 +740,12 @@ new Vue({
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
shareItem: function(url) {
|
shareItem: function(uuid, url) {
|
||||||
var typeToShare;
|
var typeToShare;
|
||||||
var nameToShare;
|
var nameToShare;
|
||||||
|
|
||||||
for (i = 0; i < this.items.length; i++) {
|
for (i = 0; i < this.items.length; i++) {
|
||||||
if (this.items[i].url == url) {
|
if (this.items[i].uuid == uuid) {
|
||||||
typeToShare = this.items[i].type;
|
typeToShare = this.items[i].type;
|
||||||
nameToShare = this.items[i].name;
|
nameToShare = this.items[i].name;
|
||||||
}
|
}
|
||||||
|
@ -741,13 +760,7 @@ new Vue({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
acceptItem: function() {
|
acceptItem: function() {
|
||||||
var itemToPush =
|
this.pushToItems(this.checkItemType(this.receiveDialog.data.type), this.receiveDialog.data.name, this.receiveDialog.data.url);
|
||||||
{
|
|
||||||
"type": this.checkItemType(this.receiveDialog.data.type),
|
|
||||||
"name": this.receiveDialog.data.name,
|
|
||||||
"url": this.receiveDialog.data.url,
|
|
||||||
};
|
|
||||||
this.items.push(itemToPush);
|
|
||||||
},
|
},
|
||||||
useItem: function(type, url) {
|
useItem: function(type, url) {
|
||||||
this.sendAppMessage("use-item", {
|
this.sendAppMessage("use-item", {
|
||||||
|
|
|
@ -187,7 +187,7 @@ function startup() {
|
||||||
Messages.subscribe(inventoryMessagesChannel);
|
Messages.subscribe(inventoryMessagesChannel);
|
||||||
|
|
||||||
ui = new AppUi({
|
ui = new AppUi({
|
||||||
buttonName: "TOPSECRET",
|
buttonName: "INVENTORY",
|
||||||
home: Script.resolvePath("inventory.html"),
|
home: Script.resolvePath("inventory.html"),
|
||||||
graphicsDirectory: Script.resolvePath("./"), // Where your button icons are located
|
graphicsDirectory: Script.resolvePath("./"), // Where your button icons are located
|
||||||
onOpened: onOpened,
|
onOpened: onOpened,
|
||||||
|
|
Loading…
Reference in a new issue