README.md 5.36 KB
Newer Older
CupCakeArmy's avatar
CupCakeArmy committed
1
2
# Admintool
### Software:
CupCakeArmy's avatar
CupCakeArmy committed
3
4
5
6
* ```ubuntu /14.04.1```
* ```nginx /1.4.6```

### Dependecies:
CupCakeArmy's avatar
CupCakeArmy committed
7
8
9
* ```jQuery /2.2.2```
* ```bootstrap /3.3.6```
* ```amivaccess /1.0```
CupCakeArmy's avatar
CupCakeArmy committed
10

CupCakeArmy's avatar
CupCakeArmy committed
11
### File Structure:
CupCakeArmy's avatar
CupCakeArmy committed
12
* admin (Admintool)
Oliver Schneider's avatar
Oliver Schneider committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  * lib (Libraries)
    * bootstrap
    * jquery
    * amiv (amivcore)
    * cust (custom files)
      * main.js (our js file)
      * main.css (our css file)
  * res (Resources)
    * bg (big pictures and backgrounds)
    * favicon
    * fonts
    * logo
  * tools (tools)
    * main.tool
    * users.tool
    * ...
CupCakeArmy's avatar
CupCakeArmy committed
29
* public (Website)
CupCakeArmy's avatar
CupCakeArmy committed
30

CupCakeArmy's avatar
CupCakeArmy committed
31
32
## Library ```tools```:
The JS library ```tools``` is the backbone of the single tools. It enables the tool itself to take actions, such as store data, customize the menu, spawn alert boxes, load new tools and more.
CupCakeArmy's avatar
CupCakeArmy committed
33

CupCakeArmy's avatar
CupCakeArmy committed
34
### log(msg, type, timeout)
CupCakeArmy's avatar
CupCakeArmy committed
35
###### Displays an alert box to the user.
CupCakeArmy's avatar
CupCakeArmy committed
36
37
* ```msg /text,HTML``` The message or html to be displayed in the alert box
* ```type /('s', 'i', 'w', 'e')``` Specifies the type of message. Displays different colors for each type.
Oliver Schneider's avatar
Oliver Schneider committed
38
39
40
41
  * s: success
  * i: information
  * w: warning
  * e: error
CupCakeArmy's avatar
CupCakeArmy committed
42
* ```timeout /int (optional)``` Number of milliseconds that the message will be displayed. If not specified the default time is 5s, or 5000ms.
CupCakeArmy's avatar
CupCakeArmy committed
43

CupCakeArmy's avatar
CupCakeArmy committed
44
##### Example:
CupCakeArmy's avatar
CupCakeArmy committed
45
46
47
* ``` tools.log('User updated!', 's'); ``` Creates a green alert box with the message specified that will disappear after 5000ms.
* ``` tools.log('Error!', 'e', 10000); ``` Creates a gred alert box with the message specified that will disappear after 10s.

CupCakeArmy's avatar
CupCakeArmy committed
48
### modal(data)
Oliver Schneider's avatar
Oliver Schneider committed
49
###### Spawns a BS modal. To close a modal without a button just call ```tools.modalClose()```
CupCakeArmy's avatar
CupCakeArmy committed
50
* ```data /js object``` Object containning the infos
Oliver Schneider's avatar
Oliver Schneider committed
51
52
53
54
55
56
57
58
59
60
61
62
63
  * ```head /text, HTML (optional)``` Sets the modal title.
  * ```body /text, HTML (optional)``` Sets the modal body.
  * ```button /object (optional)``` Buttons in the footer. (Multiple allowed!! :D)
    * ```type /string (optional)``` Type of boostrap button
      * primary
      * success
      * info
      * warning
      * danger
      * link
    * ```close /bool (optional)``` Close modal on click 
    * ```callback /function (optional)``` Callback for the button
  * ```cancel /function (optional)``` Function called on cancel or modal is closed.
CupCakeArmy's avatar
CupCakeArmy committed
64
65
66
67
68
69
70
71
72

##### Example:
```javascript
tools.modal(); 
//Creates an empty modal.

tools.modal({
	head: 'Download Flash Player!!',
	body: 'Your browser needs this super important plugin',
CupCakeArmy's avatar
CupCakeArmy committed
73
74
75
76
77
78
79
80
81
	button: {
		'DOWNLOAD!':{
			type: 'success',
			close: true,
			callback: function(){
				some.nasty.virusdownload.now();
			}
		},
	},	
CupCakeArmy's avatar
CupCakeArmy committed
82
83
84
85
86
87
	cancel: function(){
		console.log('No Virus for you -.-');
	}
});
// Makes a modal to download stuff
```
CupCakeArmy's avatar
CupCakeArmy committed
88
### getTool(tool)
CupCakeArmy's avatar
CupCakeArmy committed
89
90
###### Loads the specified tool. If no tool is specified the tool in the navigaton bar (hashtag) will be chosen.
* ```tool /text (optional)``` Specifies the tool.
CupCakeArmy's avatar
CupCakeArmy committed
91

CupCakeArmy's avatar
CupCakeArmy committed
92
93
94
##### Example:
* ``` tools.getTool('home'); ``` Will get the /res/tools/```home```.tool and loads it into the site.

CupCakeArmy's avatar
CupCakeArmy committed
95
### ui
CupCakeArmy's avatar
CupCakeArmy committed
96
###### The ```ui``` element allows you to access ui components (menu) and take actions (login, logout, toggleSideMenu).
CupCakeArmy's avatar
CupCakeArmy committed
97

CupCakeArmy's avatar
CupCakeArmy committed
98
99
#### toggleSideMenu()
##### Example:
CupCakeArmy's avatar
CupCakeArmy committed
100
* ```tools.ui.toggleSideMenu();``` Toggles the sidebar.
CupCakeArmy's avatar
CupCakeArmy committed
101
102

#### menu(object)
CupCakeArmy's avatar
CupCakeArmy committed
103
104
###### Allows a tool to access the top menu and have custom links and callbacks.
* ```object /js object``` Menu structured element from which the menu is generated.
Oliver Schneider's avatar
Oliver Schneider committed
105
106
  * ```link /link (optional)``` HTTP link or hash. If left empty the link is disabled.
  * ```callback /function (optional)``` The function that is called if the link is pressed.
CupCakeArmy's avatar
CupCakeArmy committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

##### Example:
```javascript
tools.ui.menu({
	'Foo':{}
});
// Creates a single link element named 'Foo' without a href or callback

tools.ui.menu({
	'Foo':{
		link:'google.com'
	}
});
// Creates a link named 'Foo' without a callback, but is linked to google.com

tools.ui.menu({
	'Foo':{
		callback: function (){
			console.log('I was pressed!!');
		}
	}
});
// Creates a link 'Foo' and calles the function once the link is called

tools.ui.menu({
	'Foo':{
		link: '#trololo',
		callback: function (){
			console.log('I was pressed!!');
		}
	}
});
// Creates a link 'Foo' and calles the function once the link is called and the user gets redirected to #trololo.
```

CupCakeArmy's avatar
CupCakeArmy committed
142

CupCakeArmy's avatar
CupCakeArmy committed
143
### mem.local & mem.session
CupCakeArmy's avatar
CupCakeArmy committed
144
###### The mem element can store data for the tools, used for multiple cases. There are 2 tyoes of storage: ```local``` hast no expiration and ```session``` is stored until you close the window or tab. Every tool has separated storage, so you don't need to worry about conflicting with other tools. The subfunctions are the same, a so only ```session``` wil be demonstraded here. local works identically.
CupCakeArmy's avatar
CupCakeArmy committed
145

CupCakeArmy's avatar
CupCakeArmy committed
146
#### set(name, value)
CupCakeArmy's avatar
CupCakeArmy committed
147
###### Sets and stores a value. If the value already exists it will be overwritten!
CupCakeArmy's avatar
CupCakeArmy committed
148
* ```name /text``` Name of the 'variable'.
Oliver Schneider's avatar
Oliver Schneider committed
149
* ```value /any``` The data to be stored. Can be any valid JS data, object, etc.
CupCakeArmy's avatar
CupCakeArmy committed
150

CupCakeArmy's avatar
CupCakeArmy committed
151
##### Example:
CupCakeArmy's avatar
CupCakeArmy committed
152
153
154
* ```tools.mem.session.set('currentUser', 'Sir Anon');``` Stores 'Sir Anon' in 'currentUser'.
* ```tools.mem.session.set('someData', {'car':'tesla'});``` Stores the object in 'someData'.

CupCakeArmy's avatar
CupCakeArmy committed
155
#### get(name)
CupCakeArmy's avatar
CupCakeArmy committed
156
157
158
###### Returnes the assosiated value. If there is no data it will return ```null```.
* ```name /text``` Name of the 'variable'.

CupCakeArmy's avatar
CupCakeArmy committed
159
##### Example:
CupCakeArmy's avatar
CupCakeArmy committed
160
161
162
163
164
165
* ```tools.mem.session.get('currentUser'); > 'Sir Anon'``` Retrieves 'currentUser'.
* ```tools.mem.session.set('someData'); > {'car':'tesla'}``` Retrieves 'someData'.
* ```tools.mem.session.set('nopeFoo'); > null``` No data stored unter 'nopeFoo', so returns ```null```.


# Website