mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-02-16 10:40:57 +00:00
Change script location.
Split js code. Added cache and changed loading mechanism for js sources.
This commit is contained in:
201
script/features/enum_vertices/EnumVertices.js
Normal file
201
script/features/enum_vertices/EnumVertices.js
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
Classes for creating text for vertices.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Base Enum Vertices.
|
||||
*
|
||||
*/
|
||||
function BaseEnumVertices(app, startNumber)
|
||||
{
|
||||
this.app = app;
|
||||
this.startNumber = startNumber;
|
||||
}
|
||||
|
||||
BaseEnumVertices.prototype.GetVertexText = function(id)
|
||||
{
|
||||
return this.startNumber + id;
|
||||
}
|
||||
|
||||
BaseEnumVertices.prototype.GetVertexTextAsync = function(callback)
|
||||
{
|
||||
callback (this);
|
||||
}
|
||||
|
||||
BaseEnumVertices.prototype.GetText = function()
|
||||
{
|
||||
return this.startNumber + ", " + (this.startNumber + 1) + ", " + (this.startNumber + 2) + "...";
|
||||
}
|
||||
|
||||
BaseEnumVertices.prototype.GetValue = function()
|
||||
{
|
||||
return "Numbers" + this.startNumber;
|
||||
}
|
||||
|
||||
function TextEnumTitle(app, title)
|
||||
{
|
||||
BaseEnumVertices.apply(this, arguments);
|
||||
this.pattern = "";
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
// inheritance.
|
||||
TextEnumTitle.prototype = Object.create(BaseEnumVertices.prototype);
|
||||
|
||||
TextEnumTitle.prototype.GetVertexText = function(id)
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Text Enum
|
||||
*
|
||||
*/
|
||||
function TextEnumVertices(app)
|
||||
{
|
||||
BaseEnumVertices.apply(this, arguments);
|
||||
this.pattern = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
}
|
||||
|
||||
|
||||
// inheritance.
|
||||
TextEnumVertices.prototype = Object.create(BaseEnumVertices.prototype);
|
||||
|
||||
TextEnumVertices.prototype.GetVertexText = function(id)
|
||||
{
|
||||
var res = "";
|
||||
|
||||
res = this.pattern[id % this.pattern.length] + res;
|
||||
|
||||
while (id >= this.pattern.length)
|
||||
{
|
||||
id = Math.floor(id / this.pattern.length) - 1;
|
||||
res = this.pattern[id % this.pattern.length] + res;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
TextEnumVertices.prototype.GetText = function()
|
||||
{
|
||||
return "A, B, ... Z";
|
||||
}
|
||||
|
||||
TextEnumVertices.prototype.GetValue = function()
|
||||
{
|
||||
return "Latin";
|
||||
}
|
||||
|
||||
/**
|
||||
* Text Enum
|
||||
*
|
||||
*/
|
||||
function TextEnumVerticesCyr(app)
|
||||
{
|
||||
TextEnumVertices.apply(this, arguments);
|
||||
this.pattern = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
|
||||
}
|
||||
|
||||
|
||||
// inheritance.
|
||||
TextEnumVerticesCyr.prototype = Object.create(TextEnumVertices.prototype);
|
||||
|
||||
TextEnumVerticesCyr.prototype.GetText = function()
|
||||
{
|
||||
return "А, Б, ... Я";
|
||||
}
|
||||
|
||||
TextEnumVerticesCyr.prototype.GetValue = function()
|
||||
{
|
||||
return "Cyrillic";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Text Enum
|
||||
*
|
||||
*/
|
||||
function TextEnumVerticesGreek(app)
|
||||
{
|
||||
TextEnumVertices.apply(this, arguments);
|
||||
this.pattern = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ";
|
||||
}
|
||||
|
||||
|
||||
// inheritance.
|
||||
TextEnumVerticesGreek.prototype = Object.create(TextEnumVertices.prototype);
|
||||
|
||||
TextEnumVerticesGreek.prototype.GetText = function()
|
||||
{
|
||||
return "Α, Β, ... Ω";
|
||||
}
|
||||
|
||||
TextEnumVerticesGreek.prototype.GetValue = function()
|
||||
{
|
||||
return "Greek";
|
||||
}
|
||||
|
||||
/**
|
||||
* Text Enum
|
||||
*
|
||||
*/
|
||||
function TextEnumVerticesCustom(app)
|
||||
{
|
||||
BaseEnumVertices.apply(this, arguments);
|
||||
this.pattern = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// inheritance.
|
||||
TextEnumVerticesCustom.prototype = Object.create(BaseEnumVertices.prototype);
|
||||
|
||||
TextEnumVerticesCustom.prototype.GetText = function()
|
||||
{
|
||||
return g_customEnumVertex;
|
||||
}
|
||||
|
||||
TextEnumVerticesCustom.prototype.GetValue = function()
|
||||
{
|
||||
return "Custom";
|
||||
}
|
||||
|
||||
TextEnumVerticesCustom.prototype.GetVertexTextAsync = function(callback)
|
||||
{
|
||||
this.ShowDialog(callback, g_addVertex, g_addVertex, "A");
|
||||
}
|
||||
|
||||
|
||||
TextEnumVerticesCustom.prototype.ShowDialog = function(callback, buttonText, titleTitle, title)
|
||||
{
|
||||
var dialogButtons = {};
|
||||
app = this.app;
|
||||
dialogButtons[buttonText] = function() {
|
||||
app.PushToStack("RenameVertex");
|
||||
|
||||
callback(new TextEnumTitle(app, $("#VertexTitle").val()));
|
||||
$( this ).dialog( "close" );
|
||||
};
|
||||
|
||||
$( "#addVertex" ).dialog({
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
width: "auto",
|
||||
modal: true,
|
||||
title: titleTitle,
|
||||
buttons: dialogButtons,
|
||||
dialogClass: 'EdgeDialog',
|
||||
open: function () {
|
||||
$(this).off('submit').on('submit', function () {
|
||||
return false;
|
||||
});
|
||||
$("#VertexTitle").val(title);
|
||||
$("#VertexTitle").focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user