mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
json-rpc - origin, ui update (#407)
* try ace * . * update * ... * update * update * test * - * update * fix * . * Revert "." This reverts commit631c30f8c0
. * Revert "fix" This reverts commitbe3dbc9cbd
. * Revert "update" This reverts commit50fc89e800
. * Revert "-" This reverts commit8a6c1fdab3
. * Revert "test" This reverts commit50b3641490
. * update schema * update ui * flags * adjustments
This commit is contained in:
@@ -1,6 +1,53 @@
|
||||
$(document).ready( function() {
|
||||
performTranslation();
|
||||
|
||||
function newsCont(t,e,l)
|
||||
{
|
||||
var h = '<div style="padding-left:9px;border-left:6px solid #0088cc;">';
|
||||
h += '<h4 style="font-weight:bold;font-size:17px">'+t+'</h4>';
|
||||
h += e;
|
||||
h += '<a href="'+l+'" class="" target="_blank"><i class="fa fa-fw fa-newspaper-o"></i>'+$.i18n('dashboard_newsbox_readmore')+'</a>';
|
||||
h += '</div><hr/>';
|
||||
$('#dash_news').append(h);
|
||||
}
|
||||
|
||||
function createNews(d)
|
||||
{
|
||||
for(var i = 0; i<d.length; i++)
|
||||
{
|
||||
if(i > 5)
|
||||
break;
|
||||
|
||||
title = d[i].title.rendered;
|
||||
excerpt = d[i].excerpt.rendered;
|
||||
link = d[i].link+'?pk_campaign=WebUI&pk_kwd=post_'+d[i].slug;
|
||||
|
||||
newsCont(title,excerpt,link);
|
||||
}
|
||||
}
|
||||
|
||||
function getNews()
|
||||
{
|
||||
var h = '<span style="color:red;font-weight:bold">'+$.i18n('dashboard_newsbox_noconn')+'</span>';
|
||||
$.ajax({
|
||||
url: 'https://hyperion-project.org/wp-json/wp/v2/posts?_embed',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
timeout: 2000
|
||||
})
|
||||
.done( function( data, textStatus, jqXHR ) {
|
||||
if(jqXHR.status == 200)
|
||||
createNews(data);
|
||||
else
|
||||
$('#dash_news').html(h);
|
||||
})
|
||||
.fail( function( jqXHR, textStatus ) {
|
||||
$('#dash_news').html(h);
|
||||
});
|
||||
}
|
||||
|
||||
//getNews();
|
||||
|
||||
function updateComponents()
|
||||
{
|
||||
var components = serverInfo.info.components;
|
||||
@@ -12,13 +59,11 @@ $(document).ready( function() {
|
||||
$("#tab_components").html(components_html);
|
||||
}
|
||||
|
||||
// get active led device
|
||||
var leddevice = serverInfo.info.ledDevices.active;
|
||||
$('#dash_leddevice').html(leddevice);
|
||||
|
||||
// get host
|
||||
var hostname = serverInfo.info.hostname;
|
||||
$('#dash_systeminfo').html(hostname+':'+jsonPort);
|
||||
// add more info
|
||||
$('#dash_leddevice').html(serverInfo.info.ledDevices.active);
|
||||
$('#dash_currv').html(currentVersion);
|
||||
$('#dash_instance').html(serverConfig.general.name);
|
||||
$('#dash_ports').html(jsonPort+' | '+serverConfig.protoServer.port);
|
||||
|
||||
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
|
||||
parsedUpdateJSON = JSON.parse(data);
|
||||
@@ -26,8 +71,7 @@ $(document).ready( function() {
|
||||
var cleanLatestVersion = latestVersion.replace(/\./g, '');
|
||||
var cleanCurrentVersion = currentVersion.replace(/\./g, '');
|
||||
|
||||
$('#currentversion').html(currentVersion);
|
||||
$('#latestversion').html(latestVersion);
|
||||
$('#dash_latev').html(latestVersion);
|
||||
|
||||
if ( cleanCurrentVersion < cleanLatestVersion )
|
||||
$('#versioninforesult').html('<div style="margin:0px;" class="alert alert-warning">'+$.i18n('dashboard_infobox_message_updatewarning', latestVersion)+'</div>');
|
||||
@@ -35,6 +79,24 @@ $(document).ready( function() {
|
||||
$('#versioninforesult').html('<div style="margin:0px;" class="alert alert-success">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>');
|
||||
});
|
||||
|
||||
//determine platform
|
||||
var grabbers = serverInfo.info.grabbers.available;
|
||||
var html = "";
|
||||
|
||||
if(grabbers.indexOf('dispmanx') > -1)
|
||||
html += 'Raspberry Pi';
|
||||
else if(grabbers.indexOf('x11') > -1)
|
||||
html += 'X86';
|
||||
else if(grabbers.indexOf('osx') > -1)
|
||||
html += 'OSX';
|
||||
else if(grabbers.indexOf('amlogic') > -1)
|
||||
html += 'Amlogic';
|
||||
else
|
||||
html += 'Framebuffer';
|
||||
|
||||
$('#dash_platform').html(html);
|
||||
|
||||
|
||||
//interval update
|
||||
updateComponents();
|
||||
$(hyperion).on("cmd-serverinfo",updateComponents);
|
||||
|
@@ -99,13 +99,17 @@ $(document).ready( function() {
|
||||
});
|
||||
|
||||
$('#btn_submit_foregroundEffect').off().on('click',function() {
|
||||
//requestWriteConfig(foregroundEffect_editor.getValue());
|
||||
console.log(foregroundEffect_editor.getValue());
|
||||
var value = foregroundEffect_editor.getValue();
|
||||
if(typeof value.foregroundEffect.effect == 'undefined')
|
||||
value.foregroundEffect.effect = serverConfig.foregroundEffect.effect;
|
||||
requestWriteConfig(value);
|
||||
});
|
||||
|
||||
$('#btn_submit_backgroundEffect').off().on('click',function() {
|
||||
//requestWriteConfig(backgroundEffect_editor.getValue());
|
||||
console.log(backgroundEffect_editor.getValue());
|
||||
var value = backgroundEffect_editor.getValue();
|
||||
if(typeof value.backgroundEffect.effect == 'undefined')
|
||||
value.backgroundEffect.effect = serverConfig.backgroundEffect.effect;
|
||||
requestWriteConfig(value);
|
||||
});
|
||||
|
||||
//create introduction
|
||||
|
@@ -3,6 +3,14 @@ $(document).ready( function() {
|
||||
var conf_editor_v4l2 = null;
|
||||
var conf_editor_fg = null;
|
||||
|
||||
function hideEl(el)
|
||||
{
|
||||
for(var i = 0; i<el.length; i++)
|
||||
{
|
||||
$('[data-schemapath*="root.framegrabber.'+el[i]+'"]').toggle(false);
|
||||
}
|
||||
}
|
||||
|
||||
if(showOptHelp)
|
||||
{
|
||||
//fg
|
||||
@@ -55,6 +63,18 @@ $(document).ready( function() {
|
||||
createHint("intro", $.i18n('conf_grabber_v4l_intro'), "editor_container_v4l2");
|
||||
}
|
||||
|
||||
//hide specific options
|
||||
conf_editor_fg.on('ready',function() {
|
||||
var grabbers = serverInfo.info.grabbers.available;
|
||||
|
||||
if(grabbers.indexOf('dispmanx') > -1)
|
||||
hideEl(["device","verticalPixelDecimation","horizontalPixelDecimation","useXGetImage"]);
|
||||
else if(grabbers.indexOf('x11') > -1)
|
||||
hideEl(["device","width","height"]);
|
||||
else if(grabbers.indexOf('osx') > -1 || grabbers.indexOf('amlogic') > -1)
|
||||
hideEl(["device","verticalPixelDecimation","horizontalPixelDecimation","useXGetImage","cropLeft","cropBottom","cropTop","cropRight"]);
|
||||
});
|
||||
|
||||
removeOverlay();
|
||||
});
|
||||
|
||||
|
@@ -67,8 +67,9 @@ $(document).ready( function() {
|
||||
initRestart();
|
||||
});
|
||||
|
||||
$(".mnava").on('click', function(e){
|
||||
$(".mnava").bind('click.menu', function(e){
|
||||
loadContent(e);
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -2,16 +2,6 @@
|
||||
var ledsCustomCfgInitialized = false;
|
||||
var finalLedArray = [];
|
||||
|
||||
function validateText(){
|
||||
e = isJsonString($("#ledconfig").val());
|
||||
|
||||
if (e.length != 0){
|
||||
showInfoDialog("error", $.i18n('InfoDialog_leds_validfail_title'), e);
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function round(number) {
|
||||
var factor = Math.pow(10, 4);
|
||||
var tempNumber = number * factor;
|
||||
@@ -35,7 +25,7 @@ function createLedPreview(leds, origin){
|
||||
}
|
||||
|
||||
$('#previewledcount').html($.i18n('conf_leds_layout_preview_totalleds', leds.length));
|
||||
$('#previewledpower').html($.i18n('conf_leds_layout_preview_ledpower', (leds.length * 0.06).toFixed(1)));
|
||||
$('#previewledpower').html($.i18n('conf_leds_layout_preview_ledpower', ((leds.length * 0.06)*1.1).toFixed(1)));
|
||||
|
||||
$('.st_helper').css("border", "8px solid grey");
|
||||
|
||||
@@ -106,7 +96,7 @@ function createClassicLeds(){
|
||||
}
|
||||
|
||||
function rotateArray(array, times){
|
||||
if (times > "0"){
|
||||
if (times > 0){
|
||||
while( times-- ){
|
||||
array.push(array.shift())
|
||||
}
|
||||
@@ -366,35 +356,70 @@ $(document).ready(function() {
|
||||
|
||||
// bind change event to all inputs
|
||||
$('.ledCLconstr').bind("change", function() {
|
||||
valValue(this.id,this.value,this.min,this.max);
|
||||
createClassicLeds();
|
||||
});
|
||||
|
||||
$('.ledMAconstr').bind("change", function() {
|
||||
valValue(this.id,this.value,this.min,this.max);
|
||||
createMatrixLeds();
|
||||
});
|
||||
|
||||
// cl leds push to textfield and save values
|
||||
$('#btn_cl_generate').off().on("click", function() {
|
||||
if (finalLedArray != ""){
|
||||
$("#ledconfig").text(JSON.stringify(finalLedArray, null, "\t"));
|
||||
$('#collapse1').collapse('hide');
|
||||
$('#collapse4').collapse('show');
|
||||
}
|
||||
});
|
||||
|
||||
// ma leds push to textfield and save values
|
||||
$('#btn_ma_generate').off().on("click", function() {
|
||||
if (finalLedArray != ""){
|
||||
$("#ledconfig").text(JSON.stringify(finalLedArray, null, "\t"));
|
||||
$('#collapse2').collapse('hide');
|
||||
$('#collapse4').collapse('show');
|
||||
}
|
||||
});
|
||||
|
||||
// fill textfield with current led conf and copy to finalLedArray
|
||||
$("#ledconfig").text(JSON.stringify(serverConfig.leds, null, "\t"));
|
||||
// v4 of json schema with diff required assignment - remove when hyperion schema moved to v4
|
||||
var ledschema = {"items":{"additionalProperties":false,"required":["hscan","vscan","index"],"properties":{"clone":{"type":"integer"},"colorOrder":{"enum":["rgb","bgr","rbg","brg","gbr","grb"],"type":"string"},"hscan":{"additionalProperties":false,"properties":{"maximum":{"maximum":1,"minimum":0,"type":"number"},"minimum":{"maximum":1,"minimum":0,"type":"number"}},"type":"object"},"index":{"type":"integer"},"vscan":{"additionalProperties":false,"properties":{"maximum":{"maximum":1,"minimum":0,"type":"number"},"minimum":{"maximum":1,"minimum":0,"type":"number"}},"type":"object"}},"type":"object"},"type":"array"}
|
||||
//create jsonace editor
|
||||
var aceEdt = new JSONACEEditor(document.getElementById("aceedit"),{
|
||||
mode: 'code',
|
||||
schema: ledschema,
|
||||
onChange: function(){
|
||||
var success = true;
|
||||
try{
|
||||
aceEdt.get();
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
if(success)
|
||||
{
|
||||
$('#leds_custom_updsim').attr("disabled", false);
|
||||
$('#leds_custom_save').attr("disabled", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#leds_custom_updsim').attr("disabled", true);
|
||||
$('#leds_custom_save').attr("disabled", true);
|
||||
}
|
||||
}
|
||||
}, serverConfig.leds);
|
||||
|
||||
//TODO: HACK! No callback for schema validation - Add it!
|
||||
setInterval(function(){
|
||||
if($('#aceedit table').hasClass('jsoneditor-text-errors'))
|
||||
{
|
||||
$('#leds_custom_updsim').attr("disabled", true);
|
||||
$('#leds_custom_save').attr("disabled", true);
|
||||
}
|
||||
},1000)
|
||||
|
||||
$('.jsoneditor-menu').toggle();
|
||||
|
||||
// leds to finalLedArray
|
||||
finalLedArray = serverConfig.leds;
|
||||
|
||||
// cl/ma leds push to textfield
|
||||
$('#btn_cl_generate, #btn_ma_generate').off().on("click", function(e) {
|
||||
if(e.currentTarget.id == "btn_cl_generate")
|
||||
$('#collapse1').collapse('hide');
|
||||
else
|
||||
$('#collapse2').collapse('hide');
|
||||
|
||||
aceEdt.set(finalLedArray);
|
||||
$('#collapse4').collapse('show');
|
||||
|
||||
});
|
||||
|
||||
// create and update editor
|
||||
var conf_editor = null;
|
||||
$("#leddevices").off().on("change", function() {
|
||||
@@ -471,9 +496,7 @@ $(document).ready(function() {
|
||||
|
||||
// validate textfield and update preview
|
||||
$("#leds_custom_updsim").off().on("click", function() {
|
||||
if (validateText()){
|
||||
createLedPreview(JSON.parse($("#ledconfig").val()), 'text');
|
||||
}
|
||||
createLedPreview(aceEdt.get(), 'text');
|
||||
});
|
||||
|
||||
// save led config and saveValues - passing textfield
|
||||
@@ -482,13 +505,10 @@ $(document).ready(function() {
|
||||
saveValues();
|
||||
});
|
||||
|
||||
// validate and save led config from textfield
|
||||
// save led config from textfield
|
||||
$("#leds_custom_save").off().on("click", function() {
|
||||
if (validateText())
|
||||
{
|
||||
requestWriteConfig(JSON.parse('{"leds" :'+$("#ledconfig").val()+'}'));
|
||||
saveValues();
|
||||
}
|
||||
requestWriteConfig(JSON.parse('{"leds" :'+aceEdt.getText()+'}'));
|
||||
saveValues();
|
||||
});
|
||||
|
||||
// toggle led numbers
|
||||
|
@@ -25,7 +25,7 @@ $(document).ready(function() {
|
||||
$('#btn_submit').off().on('click',function() {
|
||||
requestWriteConfig(conf_editor.getValue());
|
||||
});
|
||||
|
||||
|
||||
function uploadLog()
|
||||
{
|
||||
var reportUrl = 'https://glot.io/snippets/';
|
||||
@@ -33,6 +33,7 @@ $(document).ready(function() {
|
||||
var config = JSON.stringify(serverConfig, null, "\t").replace(/"/g, '\\"');
|
||||
var prios = serverInfo.info.priorities;
|
||||
var comps = serverInfo.info.components;
|
||||
var info;
|
||||
|
||||
//create log
|
||||
for(var i = 0; i<messages.length; i++)
|
||||
@@ -52,9 +53,17 @@ $(document).ready(function() {
|
||||
|
||||
log += "["+app_name+" "+logger_name+"] <"+level_string+"> "+debug+msg+"\n";
|
||||
}
|
||||
//create general info
|
||||
info = "######## GENERAL ######## \n";
|
||||
info += 'Build: '+serverInfo.info.hyperion[0].build+'\n';
|
||||
info += 'Build time: '+serverInfo.info.hyperion[0].time+'\n';
|
||||
info += 'Version: '+serverInfo.info.hyperion[0].version+'\n';
|
||||
info += 'UI Lang: '+storedLang+'\n';
|
||||
info += 'UI Access: '+storedAccess+'\n';
|
||||
info += 'Avail Capt: '+serverInfo.info.grabbers.available+'\n\n';
|
||||
|
||||
//create prios
|
||||
var info = "######## PRIORITIES ######## \n";
|
||||
info += "######## PRIORITIES ######## \n";
|
||||
for(var i = 0; i<prios.length; i++)
|
||||
{
|
||||
info += prios[i].priority;
|
||||
@@ -96,7 +105,8 @@ $(document).ready(function() {
|
||||
}
|
||||
})
|
||||
.fail( function( jqXHR, textStatus ) {
|
||||
//console.log(jqXHR, textStatus)
|
||||
$('#btn_logupload').attr("disabled", false);
|
||||
$('#upl_link').html('<span style="color:red">'+$.i18n('conf_logging_uplfailed')+'<span>');
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,8 @@ $(document).ready(function() {
|
||||
var oldEffects = [];
|
||||
var cpcolor = '#B500FF';
|
||||
var mappingList = serverSchema.properties.color.properties.imageToLedMappingType.enum;
|
||||
|
||||
var duration = 0;
|
||||
|
||||
//create html
|
||||
createTable('ssthead', 'sstbody', 'sstcont');
|
||||
$('.ssthead').html(createTableRow([$.i18n('remote_input_origin'), $.i18n('remote_input_owner'), $.i18n('remote_input_priority'), $.i18n('remote_input_status')], true, true));
|
||||
@@ -55,10 +56,11 @@ $(document).ready(function() {
|
||||
if(sColor[key].key == "brightness" || sColor[key].key == "backlightThreshold")
|
||||
property = '<input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0.0" max="1.0" step="0.05" value="'+value+'"/>';
|
||||
else
|
||||
property = '<input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0.0" max="4.0" step="0.1" value="'+value+'"/>';
|
||||
property = '<input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0.01" max="4.0" step="0.1" value="'+value+'"/>';
|
||||
|
||||
$('.crtbody').append(createTableRow([title, property], false, true));
|
||||
$('#cr_'+sColor[key].key).off().on('change', function(e){
|
||||
valValue(this.id,this.value,this.min,this.max);
|
||||
requestAdjustment(e.target.id.substr(e.target.id.indexOf("_") + 1), e.currentTarget.value);
|
||||
});
|
||||
}
|
||||
@@ -86,9 +88,10 @@ $(document).ready(function() {
|
||||
var data = "";
|
||||
var prios = serverInfo.info.priorities
|
||||
var i;
|
||||
|
||||
for(i = 0; i < prios.length; i++)
|
||||
{
|
||||
var origin = "not impl";
|
||||
var origin = prios[i].origin;
|
||||
var ip = "xxx.xxx.xxx.xxx";
|
||||
var owner = prios[i].owner;
|
||||
var active = prios[i].active;
|
||||
@@ -218,9 +221,15 @@ $(document).ready(function() {
|
||||
// colorpicker and effect
|
||||
if (getStorage('rmcpcolor') != null)
|
||||
cpcolor = getStorage('rmcpcolor');
|
||||
|
||||
if (getStorage('rmduration') != null)
|
||||
{
|
||||
$("#remote_duration").val(getStorage('rmduration'));
|
||||
duration = getStorage('rmduration');
|
||||
}
|
||||
|
||||
createCP('cp2', cpcolor, function(rgb,hex){
|
||||
requestSetColor(rgb.r, rgb.g, rgb.b);
|
||||
requestSetColor(rgb.r, rgb.g, rgb.b,duration);
|
||||
$("#effect_select").val("__none__");
|
||||
setStorage('rmcpcolor', hex);
|
||||
});
|
||||
@@ -229,6 +238,11 @@ $(document).ready(function() {
|
||||
requestPriorityClear();
|
||||
$("#effect_select").val("__none__");
|
||||
});
|
||||
|
||||
$("#remote_duration").off().on("change", function(){
|
||||
duration = valValue(this.id,this.value,this.min,this.max);
|
||||
setStorage('rmduration', duration);
|
||||
});
|
||||
|
||||
$("#effect_select").off().on("change", function(event) {
|
||||
efx = $(this).val();
|
||||
@@ -236,11 +250,18 @@ $(document).ready(function() {
|
||||
{
|
||||
requestPriorityClear();
|
||||
$(hyperion).one("cmd-clear", function(event) {
|
||||
setTimeout(function() {requestPlayEffect(efx)}, 100);
|
||||
setTimeout(function() {requestPlayEffect(efx,duration)}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#remote_input_img").change(function(){
|
||||
readImg(this, function(src,width,height){
|
||||
console.log(src,width,height)
|
||||
requestSetImage(src,width,height,duration)
|
||||
});
|
||||
});
|
||||
|
||||
//force first update
|
||||
updateRemote();
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
|
||||
// global vars
|
||||
var webPrio = 1;
|
||||
var webOrigin = "Web Configuration";
|
||||
var showOptHelp;
|
||||
var currentVersion;
|
||||
var latestVersion;
|
||||
@@ -217,14 +218,34 @@ function requestPriorityClear(prio)
|
||||
sendToHyperion("clear", "", '"priority":'+prio+'');
|
||||
}
|
||||
|
||||
function requestPlayEffect(effectName)
|
||||
function requestPlayEffect(effectName, duration)
|
||||
{
|
||||
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'"},"priority":'+webPrio+'');
|
||||
if(typeof duration === "undefined" || duration < 0)
|
||||
duration = 0;
|
||||
else
|
||||
duration *= 1000;
|
||||
|
||||
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'"},"priority":'+webPrio+',"duration":'+duration+',"origin":"'+webOrigin+'"');
|
||||
}
|
||||
|
||||
function requestSetColor(r,g,b)
|
||||
function requestSetColor(r,g,b,duration)
|
||||
{
|
||||
sendToHyperion("color", "", '"color":['+r+','+g+','+b+'], "priority":'+webPrio+'');
|
||||
if(typeof duration === "undefined" || duration < 0)
|
||||
duration = 0;
|
||||
else
|
||||
duration *= 1000;
|
||||
|
||||
sendToHyperion("color", "", '"color":['+r+','+g+','+b+'], "priority":'+webPrio+',"duration":'+duration+',"origin":"'+webOrigin+'"');
|
||||
}
|
||||
|
||||
function requestSetImage(data,width,height,duration)
|
||||
{
|
||||
if(typeof duration === "undefined" || duration < 0)
|
||||
duration = 0;
|
||||
else
|
||||
duration *= 1000;
|
||||
|
||||
sendToHyperion("image", "", '"imagedata":"'+data+'", "imagewidth":'+width+',"imageheight":'+height+', "priority":'+webPrio+',"duration":'+duration+'');
|
||||
}
|
||||
|
||||
function requestSetComponentState(comp, state)
|
||||
|
File diff suppressed because one or more lines are too long
12
assets/webconfig/js/lib/bootstrap.min.js
vendored
12
assets/webconfig/js/lib/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
126
assets/webconfig/js/lib/jquery-linedtextarea.js
vendored
126
assets/webconfig/js/lib/jquery-linedtextarea.js
vendored
@@ -1,126 +0,0 @@
|
||||
/**
|
||||
* jQuery Lined Textarea Plugin
|
||||
* http://alan.blog-city.com/jquerylinedtextarea.htm
|
||||
*
|
||||
* Copyright (c) 2010 Alan Williamson
|
||||
*
|
||||
* Version:
|
||||
* $Id: jquery-linedtextarea.js 464 2010-01-08 10:36:33Z alan $
|
||||
*
|
||||
* Released under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Usage:
|
||||
* Displays a line number count column to the left of the textarea
|
||||
*
|
||||
* Class up your textarea with a given class, or target it directly
|
||||
* with JQuery Selectors
|
||||
*
|
||||
* $(".lined").linedtextarea({
|
||||
* selectedLine: 10,
|
||||
* selectedClass: 'lineselect'
|
||||
* });
|
||||
*
|
||||
* History:
|
||||
* - 2010.01.08: Fixed a Google Chrome layout problem
|
||||
* - 2010.01.07: Refactored code for speed/readability; Fixed horizontal sizing
|
||||
* - 2010.01.06: Initial Release
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
$.fn.linedtextarea = function(options) {
|
||||
|
||||
// Get the Options
|
||||
var opts = $.extend({}, $.fn.linedtextarea.defaults, options);
|
||||
|
||||
|
||||
/*
|
||||
* Helper function to make sure the line numbers are always
|
||||
* kept up to the current system
|
||||
*/
|
||||
var fillOutLines = function(codeLines, h, lineNo){
|
||||
while ( (codeLines.height() - h ) <= 0 ){
|
||||
if ( lineNo == opts.selectedLine )
|
||||
codeLines.append("<div class='lineno lineselect'>" + lineNo + "</div>");
|
||||
else
|
||||
codeLines.append("<div class='lineno'>" + lineNo + "</div>");
|
||||
|
||||
lineNo++;
|
||||
}
|
||||
return lineNo;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Iterate through each of the elements are to be applied to
|
||||
*/
|
||||
return this.each(function() {
|
||||
var lineNo = 1;
|
||||
var textarea = $(this);
|
||||
|
||||
/* Turn off the wrapping of as we don't want to screw up the line numbers */
|
||||
textarea.attr("wrap", "off");
|
||||
textarea.css({resize:'none'});
|
||||
var originalTextAreaWidth = textarea.outerWidth();
|
||||
|
||||
/* Wrap the text area in the elements we need */
|
||||
textarea.wrap("<div class='linedtextarea'></div>");
|
||||
var linedTextAreaDiv = textarea.parent().wrap("<div class='linedwrap' style='width:" + originalTextAreaWidth + "px'></div>");
|
||||
var linedWrapDiv = linedTextAreaDiv.parent();
|
||||
|
||||
linedWrapDiv.prepend("<div class='lines' style='width:50px'></div>");
|
||||
|
||||
var linesDiv = linedWrapDiv.find(".lines");
|
||||
linesDiv.height( textarea.height() + 6 );
|
||||
|
||||
|
||||
/* Draw the number bar; filling it out where necessary */
|
||||
linesDiv.append( "<div class='codelines'></div>" );
|
||||
var codeLinesDiv = linesDiv.find(".codelines");
|
||||
lineNo = fillOutLines( codeLinesDiv, linesDiv.height(), 1 );
|
||||
|
||||
/* Move the textarea to the selected line */
|
||||
if ( opts.selectedLine != -1 && !isNaN(opts.selectedLine) ){
|
||||
var fontSize = parseInt( textarea.height() / (lineNo-2) );
|
||||
var position = parseInt( fontSize * opts.selectedLine ) - (textarea.height()/2);
|
||||
textarea[0].scrollTop = position;
|
||||
}
|
||||
|
||||
|
||||
/* Set the width */
|
||||
var sidebarWidth = linesDiv.outerWidth();
|
||||
var paddingHorizontal = parseInt( linedWrapDiv.css("border-left-width") ) + parseInt( linedWrapDiv.css("border-right-width") ) + parseInt( linedWrapDiv.css("padding-left") ) + parseInt( linedWrapDiv.css("padding-right") );
|
||||
var linedWrapDivNewWidth = originalTextAreaWidth - paddingHorizontal;
|
||||
var textareaNewWidth = originalTextAreaWidth - sidebarWidth - paddingHorizontal - 20;
|
||||
|
||||
textarea.width( textareaNewWidth );
|
||||
linedWrapDiv.width( linedWrapDivNewWidth );
|
||||
|
||||
|
||||
|
||||
/* React to the scroll event */
|
||||
textarea.scroll( function(tn){
|
||||
var domTextArea = $(this)[0];
|
||||
var scrollTop = domTextArea.scrollTop;
|
||||
var clientHeight = domTextArea.clientHeight;
|
||||
codeLinesDiv.css( {'margin-top': (-1*scrollTop) + "px"} );
|
||||
lineNo = fillOutLines( codeLinesDiv, scrollTop + clientHeight, lineNo );
|
||||
});
|
||||
|
||||
|
||||
/* Should the textarea get resized outside of our control */
|
||||
textarea.resize( function(tn){
|
||||
var domTextArea = $(this)[0];
|
||||
linesDiv.height( domTextArea.clientHeight + 6 );
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
// default options
|
||||
$.fn.linedtextarea.defaults = {
|
||||
selectedLine: -1,
|
||||
selectedClass: 'lineselect'
|
||||
};
|
||||
})(jQuery);
|
49
assets/webconfig/js/lib/jsonaceeditor.min.js
vendored
Normal file
49
assets/webconfig/js/lib/jsonaceeditor.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -5,7 +5,8 @@ $(function() {
|
||||
|
||||
});
|
||||
|
||||
var oldWidth;
|
||||
var mInit = false;
|
||||
|
||||
//Loads the correct sidebar on window load,
|
||||
//collapses the sidebar on window resize.
|
||||
// Sets the min-height of #page-wrapper to window size
|
||||
@@ -13,28 +14,32 @@ $(function() {
|
||||
$(window).bind("load resize", function() {
|
||||
var topOffset = 50;
|
||||
var width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
|
||||
if(oldWidth != width)
|
||||
if (width < 768)
|
||||
{
|
||||
if (width < 768)
|
||||
if(!mInit)
|
||||
{
|
||||
mInit = true;
|
||||
$('#main-nav').css({"position":"fixed","right":"-235px","top":"45px","width":"230px","border":"1px solid rgba(0, 0, 0, .2)","box-shadow":"0 3px 9px rgba(0, 0, 0, .5)"});
|
||||
topOffset = 100; // 2-row-menu
|
||||
$('.mnava').on('click', function(){
|
||||
$("html, body").animate({ scrollTop: 0 }, "fast");
|
||||
|
||||
$('.mnava').bind('click.smnav', function(){
|
||||
$( "#main-nav" ).animate({right: "-235px",}, 300 );
|
||||
$(".navbar-toggle").addClass("closed");
|
||||
});
|
||||
}
|
||||
else
|
||||
$( "#main-nav" ).removeAttr("style").css({"position":"absolute"});
|
||||
}
|
||||
else
|
||||
{
|
||||
$( "#main-nav" ).removeAttr('style').css({"position":"fixed"});
|
||||
$( ".mnava" ).unbind('click.smnav');
|
||||
mInit = false;
|
||||
}
|
||||
|
||||
|
||||
var height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
|
||||
height = height - topOffset;
|
||||
if (height < 1) height = 1;
|
||||
if (height > topOffset) {
|
||||
$("#page-wrapper").css("min-height", (height-11) + "px");
|
||||
}
|
||||
var height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
|
||||
height = height - topOffset;
|
||||
if (height < 1) height = 1;
|
||||
if (height > topOffset) {
|
||||
$("#page-wrapper").css("min-height", (height-11) + "px");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,7 +60,7 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$('.navbar-toggle').off().on('click', function(){
|
||||
$('.navbar-toggle').on('click', function(){
|
||||
if($('#main-nav').css("right") != "-2px")
|
||||
{
|
||||
$('#main-nav').animate({right: "-2px",}, 300 );
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -81,7 +81,7 @@ function loadContent(event)
|
||||
$("#page-content").off();
|
||||
$("#page-content").load("/content/"+tag+".html", function(response,status,xhr){
|
||||
if(status == "error")
|
||||
$("#page-content").html('<h3>The page you requested is no longer available, click on another menu item!</h3>');
|
||||
$("#page-content").html('<h3>'+$.i18n('info_404')+'</h3>');
|
||||
removeOverlay();
|
||||
});
|
||||
}
|
||||
@@ -218,6 +218,39 @@ function createHint(type, text, container)
|
||||
}
|
||||
}
|
||||
|
||||
function valValue(id,value,min,max)
|
||||
{
|
||||
//TODO: Do not use parser, all values are now typeof number
|
||||
value = parseInt(value)
|
||||
if(typeof value === 'number')
|
||||
{
|
||||
if(typeof max === 'undefined' || max == "")
|
||||
max = 999999;
|
||||
|
||||
if(value > max || value < min)
|
||||
{
|
||||
$('#'+id).val(min);
|
||||
return min;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function readImg(input,cb)
|
||||
{
|
||||
if (input.files && input.files[0]) {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
var i = new Image();
|
||||
i.src = e.target.result;
|
||||
cb(i.src,i.width,i.height);
|
||||
}
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
}
|
||||
|
||||
function isJsonString(str)
|
||||
{
|
||||
try
|
||||
|
Reference in New Issue
Block a user