aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/mod_settings.js
blob: d3392c7482192ae7d2772a8af6690fde54438be4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
 * JavaScript used by mod/settings
 */

$(document).ready(function() {
	$('#settings-form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] }); // Warn user about unsaved settings

	$('.token-mirror').html($('#id_token').val());
	$('#id_token').keyup( function() { $('.token-mirror').html($('#id_token').val()); });

	previewTheme($('#id_theme')[0]);

	$("#id_permissions_role").change(function() {
		var role = $("#id_permissions_role").val();
		if(role == 'custom')
			$('#advanced-perm').show();
		else
			$('#advanced-perm').hide();
	});

	$('#id_permcat_list').change(function() {
		$('.loading').toggleClass('invisible');
		var permName = $('#id_permcat').val();
		loadPermcat(permName);
	});




});


function setTheme(elm) {
	$('#settings-form').submit();
}


function previewTheme(elm) {
	theme = $(elm).val();
	var schema = $('#id_schema').val();
	$.getJSON('theme_info/' + theme,function(data) {
		$('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" style="max-width:100%; max-height:300px" alt="' + theme + '"></a>');
		$('#id_schema').empty();
		if(data.schemas.length) {
			$(data.schemas).each(function(index,item) {
				$('<option/>',{value:item['key'],text:item['val']}).appendTo('#id_schema');
			});
			$('#id_schema').val(schema ? schema : '---');
		}
		else {
			$('<option/>',{value:'',text:'No schemes available'}).appendTo('#id_schema');
		}
		$('#custom-settings-content .section-content-tools-wrapper').html(data.config);
	});
}



/**
 * 0 nobody
 * 1 perms_specific
 * 2 perms_contacts
 * 3 perms_pending
 * 4 perms_site
 * 5 perms_network
 * 6 perms_authed
 * 7 perms_public
 */


function channel_privacy_macro(n) {
	if(n == 0) {
		$('#id_view_stream option').eq(0).attr('selected','selected');
		$('#id_view_profile option').eq(0).attr('selected','selected');
		$('#id_view_contacts option').eq(0).attr('selected','selected');
		$('#id_view_storage option').eq(0).attr('selected','selected');
		$('#id_view_pages option').eq(0).attr('selected','selected');
		$('#id_send_stream option').eq(0).attr('selected','selected');
		$('#id_post_wall option').eq(0).attr('selected','selected');
		$('#id_post_comments option').eq(0).attr('selected','selected');
		$('#id_post_mail option').eq(0).attr('selected','selected');
		$('#id_tag_deliver option').eq(0).attr('selected','selected');
		$('#id_chat option').eq(0).attr('selected','selected');
		$('#id_write_storage option').eq(0).attr('selected','selected');
		$('#id_write_pages option').eq(0).attr('selected','selected');
		$('#id_delegate option').eq(0).attr('selected','selected');
		$('#id_republish option').eq(0).attr('selected','selected');
		$('#id_post_like option').eq(0).attr('selected','selected');
		$('#id_profile_in_directory_onoff .off').removeClass('hidden');
		$('#id_profile_in_directory_onoff .on').addClass('hidden');
		$('#id_profile_in_directory').val(0);
	}
	if(n == 1) {
		$('#id_view_stream option').eq(1).attr('selected','selected');
		$('#id_view_profile option').eq(1).attr('selected','selected');
		$('#id_view_contacts option').eq(1).attr('selected','selected');
		$('#id_view_storage option').eq(1).attr('selected','selected');
		$('#id_view_pages option').eq(1).attr('selected','selected');
		$('#id_send_stream option').eq(1).attr('selected','selected');
		$('#id_post_wall option').eq(1).attr('selected','selected');
		$('#id_post_comments option').eq(1).attr('selected','selected');
		$('#id_post_mail option').eq(1).attr('selected','selected');
		$('#id_tag_deliver option').eq(1).attr('selected','selected');
		$('#id_chat option').eq(1).attr('selected','selected');
		$('#id_write_storage option').eq(1).attr('selected','selected');
		$('#id_write_pages option').eq(1).attr('selected','selected');
		$('#id_delegate option').eq(0).attr('selected','selected');
		$('#id_republish option').eq(0).attr('selected','selected');
		$('#id_post_like option').eq(1).attr('selected','selected');
		$('#id_profile_in_directory_onoff .off').removeClass('hidden');
		$('#id_profile_in_directory_onoff .on').addClass('hidden');
		$('#id_profile_in_directory').val(0);
	}
	if(n == 2) {
		$('#id_view_stream option').eq(7).attr('selected','selected');
		$('#id_view_profile option').eq(7).attr('selected','selected');
		$('#id_view_contacts option').eq(7).attr('selected','selected');
		$('#id_view_storage option').eq(7).attr('selected','selected');
		$('#id_view_pages option').eq(7).attr('selected','selected');
		$('#id_send_stream option').eq(2).attr('selected','selected');
		$('#id_post_wall option').eq(1).attr('selected','selected');
		$('#id_post_comments option').eq(2).attr('selected','selected');
		$('#id_post_mail option').eq(1).attr('selected','selected');
		$('#id_tag_deliver option').eq(1).attr('selected','selected');
		$('#id_chat option').eq(1).attr('selected','selected');
		$('#id_write_storage option').eq(0).attr('selected','selected');
		$('#id_write_pages option').eq(0).attr('selected','selected');
		$('#id_delegate option').eq(0).attr('selected','selected');
		$('#id_republish option').eq(1).attr('selected','selected');
		$('#id_post_like option').eq(5).attr('selected','selected');
		$('#id_profile_in_directory_onoff .on').removeClass('hidden');
		$('#id_profile_in_directory_onoff .off').addClass('hidden');
		$('#id_profile_in_directory').val(1);
	}
	if(n == 3) {
		$('#id_view_stream option').eq(7).attr('selected','selected');
		$('#id_view_profile option').eq(7).attr('selected','selected');
		$('#id_view_contacts option').eq(7).attr('selected','selected');
		$('#id_view_storage option').eq(7).attr('selected','selected');
		$('#id_view_pages option').eq(7).attr('selected','selected');
		$('#id_send_stream option').eq(5).attr('selected','selected');
		$('#id_post_wall option').eq(5).attr('selected','selected');
		$('#id_post_comments option').eq(5).attr('selected','selected');
		$('#id_post_mail option').eq(5).attr('selected','selected');
		$('#id_tag_deliver option').eq(1).attr('selected','selected');
		$('#id_chat option').eq(5).attr('selected','selected');
		$('#id_write_storage option').eq(2).attr('selected','selected');
		$('#id_write_pages option').eq(2).attr('selected','selected');
		$('#id_delegate option').eq(0).attr('selected','selected');
		$('#id_republish option').eq(5).attr('selected','selected');
		$('#id_post_like option').eq(6).attr('selected','selected');
		$('#id_profile_in_directory_onoff .on').removeClass('hidden');
		$('#id_profile_in_directory_onoff .off').addClass('hidden');
		$('#id_profile_in_directory').val(1);
	}
}



function loadPermcat(name) {

	if(! name)
		name = 'default';

	$('.abook-edit-me').each(function() {
		if(! $(this).is(':disabled'))
			$(this).removeAttr('checked');
	});

	$.get('permcat/' + name, function(data) {
		$(data.perms).each(function() {
			if(this.value)
				$('#me_id_perms_' + this.name).attr('checked','checked');
		});
		$('.loading').toggleClass('invisible');
	});
}