/**
* Share an image to all players when you have an image URL
* Author: @Krishmero#1792
*/
let imagePopup = (imageUrl) => {
// Display the image popout and share it.
const ip = new ImagePopout(imageUrl);
ip.render(true);
ip.shareImage();
};
let chatDialog = (imageUrl) => {
ChatMessage.create({
user: game.user._id,
content: `<img src="${imageUrl}" />`,
type: CONST.CHAT_MESSAGE_TYPES.OOC
});
};
let selectOptions = game.user.isGM ? `
<div inline-block; width: 100%; margin-bottom: 10px">
<label for="output-options" 10px">Output Options:</label>
<select id="output-options" />
<option value="popup">Popup</option>
<option value="chat">Chat</option>
<option value="both">Both</option>
</select>
</div>
<br />
` : '';
new Dialog({
title: `Share Image via URL`,
content: `
<form>
${selectOptions}
<div flex; width: 100%; margin-bottom: 10px">
<label for="image-url" nowrap; margin-right: 10px; padding-top:4px">Image URL:</label>
<input type="text" id="image-url" name="image-url" />
</div>
</form>
`,
buttons: {
yes: {
icon: "<i class='fas fa-check'></i>",
label: `Share`,
callback: (html) => {
let imageUrl = html.find('#image-url').val();
let permission = html.find('select#output-options')[0]?.value || null;
if (!imageUrl) {
return ui.notifications.info("You did not provide a valid image.");
}
if (game.user.isGM && ['popup', 'both'].includes(permission)) {
imagePopup(imageUrl);
}
if (!game.user.isGM || ['chat', 'both'].includes(permission)) {
chatDialog(imageUrl);
}
}
},
no: {
icon: "<i class='fas fa-times'></i>",
label: `Cancel`
},
},
default: "yes"
}).render(true)
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}