updating the values for global settings, very near to completing the feature
This commit is contained in:
parent
6c9f1843f1
commit
8501ccde77
46
index.html
46
index.html
|
@ -109,20 +109,45 @@
|
|||
|
||||
<!--{{{ start global settings item template -->
|
||||
<script type="text/mustache" id="global_general_settings_template">
|
||||
{{#general}}
|
||||
{{#settings}}
|
||||
<fieldset>
|
||||
<legend>{{name}}</legend>
|
||||
<div class="control-group">
|
||||
{{#values}}
|
||||
<label class="control-label" for="input_settings_{{name}}">{{name}}</label>
|
||||
<div class="controls">
|
||||
{{^options}}
|
||||
<input typ="text" class="input-xlarge" id="input_settings_{{name}}"></input>
|
||||
{{#has_value}}
|
||||
<input typ="text" class="input-xlarge" id="input_settings_{{name}}" value="{{value}}"/>
|
||||
{{/has_value}}
|
||||
|
||||
{{^has_value}}
|
||||
<input typ="text" class="input-xlarge" placeholder="default" id="input_settings_{{name}}"/>
|
||||
{{/has_value}}
|
||||
{{/options}}
|
||||
|
||||
{{#option}}
|
||||
<select>
|
||||
{{#has_value}}
|
||||
<select id="input_settings_{{name}}">
|
||||
{{/has_value}}
|
||||
|
||||
{{^has_value}}
|
||||
<select id="input_settings_{{name}}">
|
||||
<option value=" ">Default</option>
|
||||
{{/has_value}}
|
||||
|
||||
{{/option}}
|
||||
|
||||
{{#options}}
|
||||
<option>{{.}}</option>
|
||||
|
||||
{{#has_value}}
|
||||
<option value="{{& val}}">{{disp}}</option>
|
||||
{{/has_value}}
|
||||
|
||||
{{^has_value}}
|
||||
<option value="{{& .}}">{{.}}</option>
|
||||
{{/has_value}}
|
||||
|
||||
{{/options}}
|
||||
|
||||
{{#option}}
|
||||
|
@ -132,8 +157,10 @@
|
|||
<p class="help-block">{{desc}}</p>
|
||||
<br><br>
|
||||
</div>
|
||||
{{/general}}
|
||||
|
||||
{{/values}}
|
||||
</div>
|
||||
</fieldset>
|
||||
{{/settings}}
|
||||
|
||||
</script>
|
||||
<!-- global settings template end }}}-->
|
||||
|
@ -282,13 +309,8 @@
|
|||
<h3>Global Settings</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<legend>General Settings</legend>
|
||||
<div id="dynamic_global_settings" class="control-group">
|
||||
<form class="form-horizontal" id="dynamic_global_settings">
|
||||
<!-- dynamic settings injection here -->
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
|
|
@ -199,7 +199,8 @@ var input_file_settings = [
|
|||
},
|
||||
{
|
||||
name: "file-allocation",
|
||||
desc: "Specify file allocation method. none doesn't pre-allocate file space. prealloc pre-allocates file space before download begins. This may take some time depending on the size of the file. If you are using newer file systems such as ext4 (with extents support), btrfs, xfs or NTFS(MinGW build only), falloc is your best choice. It allocates large(few GiB) files almost instantly. Don't use falloc with legacy file systems such as ext3 and FAT32 because it takes almost same time as prealloc and it blocks aria2 entirely until allocation finishes. falloc may not be available if your system doesn't have posix_fallocate(3) function. Possible Values: none, prealloc, falloc Default: prealloc"
|
||||
desc: "Specify file allocation method. none doesn't pre-allocate file space. prealloc pre-allocates file space before download begins. This may take some time depending on the size of the file. If you are using newer file systems such as ext4 (with extents support), btrfs, xfs or NTFS(MinGW build only), falloc is your best choice. It allocates large(few GiB) files almost instantly. Don't use falloc with legacy file systems such as ext3 and FAT32 because it takes almost same time as prealloc and it blocks aria2 entirely until allocation finishes. falloc may not be available if your system doesn't have posix_fallocate(3) function. Possible Values: none, prealloc, falloc Default: prealloc",
|
||||
options: ["none", "prealloc", "falloc"]
|
||||
},
|
||||
{
|
||||
name: "follow-metalink",
|
||||
|
|
93
js/script.js
93
js/script.js
|
@ -127,13 +127,104 @@ $(function() {
|
|||
});
|
||||
$('#addNewDownload').click(newDownload);
|
||||
});
|
||||
function check_global(name) {
|
||||
for(var i = 0; i < global_settings_exclude.length; i++) {
|
||||
if(global_settings_exclude[i] === name) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function get_global_settings(cb) {
|
||||
var sets = [];
|
||||
var tmp_set;
|
||||
for(var i = 0; i < input_file_settings.length; i++) {
|
||||
tmp_set = input_file_settings[i];
|
||||
if(check_global(tmp_set)) {
|
||||
sets.push(tmp_set);
|
||||
}
|
||||
}
|
||||
for(var i = 0; i < global_settings.length; i++) {
|
||||
tmp_set = global_settings[i];
|
||||
if(check_global(tmp_set)) {
|
||||
sets.push(tmp_set);
|
||||
}
|
||||
}
|
||||
aria_syscall({
|
||||
func: 'getGlobalOption',
|
||||
success: function(data) {
|
||||
var res = data.result;
|
||||
console.log(res);
|
||||
for(var i in data.result) {
|
||||
for(var j = 0; j < sets.length; j++) {
|
||||
if(sets[j].name === i) {
|
||||
sets[j].value = res[i].trim();
|
||||
sets[j].has_value = true;
|
||||
if(sets[j].option) {
|
||||
for(var k = 0; k < sets[j].options.length; k++) {
|
||||
var tmp = {
|
||||
val: sets[j].options[k].toString(),
|
||||
disp: sets[j].options[k].toString()
|
||||
};
|
||||
if(sets[j].options[k].toString() === sets[j].value) {
|
||||
tmp.val = sets[j].value + '" selected="true';
|
||||
}
|
||||
sets[j].options[k] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cb(sets);
|
||||
},
|
||||
error: function() {
|
||||
alert("Connection to aria server failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
function custom_global_settings() {
|
||||
var gen = function(name) {
|
||||
return { name: name, values: [] };
|
||||
}
|
||||
var general_settings = gen("General Settings");
|
||||
var torrent_settings = gen("Bit-Torrent Settings");
|
||||
var ftp_settings = gen("FTP Settings");
|
||||
var http_settings = gen("HTTP(S) Settings");
|
||||
var metalink_settings = gen("Metalink Settings");
|
||||
|
||||
get_global_settings(function(sets) {
|
||||
for(var i = 0; i < sets.length; i++) {
|
||||
var set = sets[i];
|
||||
if(set.name.indexOf("bt") !== -1 || set.name.indexOf("torrent") !== -1) {
|
||||
torrent_settings.values.push(set);
|
||||
}
|
||||
else if(set.name.indexOf("metalink") !== -1) {
|
||||
metalink_settings.values.push(set);
|
||||
}
|
||||
else if(set.name.indexOf("http") !== -1) {
|
||||
http_settings.values.push(set);
|
||||
}
|
||||
else if(set.name.indexOf("ftp") !== -1) {
|
||||
ftp_settings.values.push(set);
|
||||
}
|
||||
else
|
||||
general_settings.values.push(set);
|
||||
|
||||
}
|
||||
|
||||
var templ = $('#global_general_settings_template').text();
|
||||
var item = Mustache.render(templ, {
|
||||
general: input_file_settings
|
||||
settings: [
|
||||
general_settings,
|
||||
http_settings,
|
||||
ftp_settings,
|
||||
torrent_settings,
|
||||
metalink_settings
|
||||
]
|
||||
});
|
||||
$('#dynamic_global_settings').html(item);
|
||||
modals.global_settings_modal.modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
function addDownload(uris) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user