2010-10-20 20:11:15 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 2010, Google Inc.
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are
|
|
|
|
met:
|
|
|
|
|
2011-08-04 22:37:14 +02:00
|
|
|
* Redistributions of source code must retain the above copyright
|
2010-10-20 20:11:15 +02:00
|
|
|
notice, this list of conditions and the following disclaimer.
|
2011-08-04 22:37:14 +02:00
|
|
|
* Redistributions in binary form must reproduce the above
|
2010-10-20 20:11:15 +02:00
|
|
|
copyright notice, this list of conditions and the following disclaimer
|
|
|
|
in the documentation and/or other materials provided with the
|
|
|
|
distribution.
|
2011-08-04 22:37:14 +02:00
|
|
|
* Neither the name of Google Inc. nor the names of its
|
2010-10-20 20:11:15 +02:00
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2012-10-19 01:40:31 +02:00
|
|
|
var OpenRefineVersion;
|
2010-10-22 03:43:56 +02:00
|
|
|
|
2011-08-02 05:34:47 +02:00
|
|
|
var Refine = {
|
2011-08-04 22:37:14 +02:00
|
|
|
actionAreas: []
|
2011-08-02 05:34:47 +02:00
|
|
|
};
|
2010-06-20 16:47:45 +02:00
|
|
|
|
2014-07-03 15:05:39 +02:00
|
|
|
var lang = (navigator.language|| navigator.userLanguage).split("-")[0];
|
2013-07-02 13:40:50 +02:00
|
|
|
var dictionary = "";
|
|
|
|
$.ajax({
|
2014-12-03 14:52:06 +01:00
|
|
|
url : "command/core/load-language?",
|
2013-07-02 13:40:50 +02:00
|
|
|
type : "POST",
|
|
|
|
async : false,
|
|
|
|
data : {
|
2013-07-31 06:31:31 +02:00
|
|
|
module : "core",
|
|
|
|
// lang : lang
|
2013-07-02 13:40:50 +02:00
|
|
|
},
|
|
|
|
success : function(data) {
|
|
|
|
dictionary = data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.i18n.setDictionary(dictionary);
|
|
|
|
// End internationalization
|
|
|
|
|
2011-08-02 05:34:47 +02:00
|
|
|
Refine.selectActionArea = function(id) {
|
2011-08-04 22:37:14 +02:00
|
|
|
$('.action-area-tab').removeClass('selected');
|
2011-08-12 21:15:58 +02:00
|
|
|
$('.action-area-tab-body').css('visibility', 'hidden').css('z-index', '50');
|
2011-08-04 22:37:14 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < Refine.actionAreas.length; i++) {
|
|
|
|
var actionArea = Refine.actionAreas[i];
|
|
|
|
if (id == actionArea.id) {
|
|
|
|
actionArea.tabElmt.addClass('selected');
|
2011-10-08 01:44:11 +02:00
|
|
|
actionArea.bodyElmt.css('visibility', 'visible').css('z-index', '55');
|
2010-02-03 07:23:40 +01:00
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
}
|
2011-08-02 05:34:47 +02:00
|
|
|
};
|
2010-02-03 07:23:40 +01:00
|
|
|
|
2011-08-02 05:34:47 +02:00
|
|
|
$(function() {
|
2017-09-27 12:00:47 +02:00
|
|
|
var isThereNewRelease = function(thisVer,latestVer) {
|
|
|
|
// Assumes Semantic Version numbering format of form X.Y.Z where X, Y, and Z are non-negative integer
|
|
|
|
// Ignores any trailing letters e.g. 2.7.1-rc.1 will be interpreted as equivalent to 2.7.1
|
|
|
|
if(thisVer == latestVer) {
|
2011-08-04 22:37:14 +02:00
|
|
|
return false;
|
|
|
|
}
|
2017-09-27 12:00:47 +02:00
|
|
|
var thisVerParts = thisVer.split(".");
|
|
|
|
var latestVerParts = latestVer.split(".");
|
|
|
|
while(thisVerParts.length < 3)
|
|
|
|
thisVerParts.push(0);
|
|
|
|
while(latestVerParts.length < 3)
|
2017-09-27 12:47:07 +02:00
|
|
|
latestVerParts.push(0);
|
2017-09-27 12:00:47 +02:00
|
|
|
|
|
|
|
for(var i=0; i<3; i++) {
|
2017-09-27 12:47:07 +02:00
|
|
|
var thisVerPartInt = parseInt(thisVerParts[i],10);
|
|
|
|
var latestVerPartInt = parseInt(latestVerParts[i],10);
|
|
|
|
if(thisVerPartInt == latestVerPartInt) {
|
2017-09-27 12:00:47 +02:00
|
|
|
continue;
|
|
|
|
} else {
|
2017-09-27 13:22:59 +02:00
|
|
|
return !(thisVerPartInt > latestVerPartInt);
|
2017-09-27 12:00:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2011-08-04 22:37:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
var showVersion = function() {
|
|
|
|
$.getJSON(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/core/get-version",
|
2010-10-18 06:18:09 +02:00
|
|
|
null,
|
|
|
|
function(data) {
|
2012-10-19 01:40:31 +02:00
|
|
|
OpenRefineVersion = data;
|
2011-08-04 22:37:14 +02:00
|
|
|
|
2018-11-21 16:24:57 +01:00
|
|
|
$("#openrefine-version").text($.i18n._('core-index/version')+" " + OpenRefineVersion.full_version);
|
2013-08-18 18:37:26 +02:00
|
|
|
|
2017-09-27 12:00:47 +02:00
|
|
|
|
2017-09-27 12:47:07 +02:00
|
|
|
$.getJSON("https://api.github.com/repos/openrefine/openrefine/releases/latest",
|
2017-09-27 12:00:47 +02:00
|
|
|
function( data ) {
|
|
|
|
var latestVersion = data.tag_name;
|
|
|
|
var latestVersionName = data.name;
|
|
|
|
var latestVersionUrl = data.html_url;
|
|
|
|
var thisVersion = OpenRefineVersion.version;
|
|
|
|
|
|
|
|
if(latestVersion.startsWith("v")) {
|
|
|
|
latestVersion = latestVersion.substr(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isThereNewRelease(thisVersion,latestVersion)) {
|
2011-08-04 22:37:14 +02:00
|
|
|
var container = $('<div id="notification-container">')
|
2011-10-08 01:44:11 +02:00
|
|
|
.appendTo(document.body);
|
2011-08-04 22:37:14 +02:00
|
|
|
var notification = $('<div id="notification">')
|
2018-11-21 16:24:57 +01:00
|
|
|
.text($.i18n._('core-index/new-version')+' ')
|
2011-10-08 01:44:11 +02:00
|
|
|
.appendTo(container);
|
2011-08-04 22:37:14 +02:00
|
|
|
$('<a>')
|
|
|
|
.addClass('notification-action')
|
2017-09-27 12:00:47 +02:00
|
|
|
.attr("href", latestVersionUrl)
|
2017-09-27 13:22:59 +02:00
|
|
|
.attr("target", "_blank")
|
2018-11-21 16:24:57 +01:00
|
|
|
.text($.i18n._('core-index/download')+' ' + latestVersionName + ' '+$.i18n._('core-index/now')+'.')
|
2011-08-04 22:37:14 +02:00
|
|
|
.appendTo(notification);
|
|
|
|
}
|
2017-09-27 12:00:47 +02:00
|
|
|
});
|
2010-10-18 06:18:09 +02:00
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
var resize = function() {
|
|
|
|
var leftPanelWidth = 150;
|
|
|
|
// px
|
|
|
|
var width = $(window).width();
|
|
|
|
var height = $(window).height();
|
|
|
|
var headerHeight = $('#header').outerHeight();
|
|
|
|
var panelHeight = height - headerHeight;
|
|
|
|
|
|
|
|
$('.main-layout-panel')
|
|
|
|
.css("top", headerHeight + "px")
|
|
|
|
.css("bottom", "0px")
|
|
|
|
.css("height", panelHeight + "px")
|
|
|
|
.css("visibility", "visible");
|
|
|
|
|
|
|
|
$('#left-panel')
|
|
|
|
.css("left", "0px")
|
|
|
|
.css("width", leftPanelWidth + "px");
|
|
|
|
var leftPanelBodyHPaddings = 10;
|
|
|
|
// px
|
|
|
|
var leftPanelBodyVPaddings = 0;
|
|
|
|
// px
|
|
|
|
$('#left-panel-body')
|
|
|
|
.css("margin-left", leftPanelBodyHPaddings + "px")
|
|
|
|
.css("margin-top", leftPanelBodyVPaddings + "px")
|
|
|
|
.css("width", ($('#left-panel').width() - leftPanelBodyHPaddings) + "px")
|
|
|
|
.css("height", ($('#left-panel').height() - leftPanelBodyVPaddings) + "px");
|
|
|
|
|
|
|
|
$('#right-panel')
|
|
|
|
.css("left", leftPanelWidth + "px")
|
|
|
|
.css("width", (width - leftPanelWidth) + "px");
|
|
|
|
|
|
|
|
var rightPanelBodyHPaddings = 5;
|
|
|
|
// px
|
|
|
|
var rightPanelBodyVPaddings = 5;
|
|
|
|
// px
|
|
|
|
$('#right-panel-body')
|
|
|
|
.css("margin-left", rightPanelBodyHPaddings + "px")
|
|
|
|
.css("margin-top", rightPanelBodyVPaddings + "px")
|
|
|
|
.css("width", ($('#right-panel').width() - rightPanelBodyHPaddings) + "px")
|
|
|
|
.css("height", ($('#right-panel').height() - rightPanelBodyVPaddings) + "px");
|
2011-08-08 01:26:51 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < Refine.actionAreas.length; i++) {
|
|
|
|
Refine.actionAreas[i].ui.resize();
|
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
};
|
|
|
|
$(window).bind("resize", resize);
|
2011-08-08 01:26:51 +02:00
|
|
|
window.setTimeout(resize, 100); // for Chrome, give the window some time to layout first
|
2011-08-04 22:37:14 +02:00
|
|
|
|
|
|
|
var renderActionArea = function(actionArea) {
|
|
|
|
actionArea.bodyElmt = $('<div>')
|
|
|
|
.addClass('action-area-tab-body')
|
|
|
|
.appendTo('#right-panel-body');
|
|
|
|
|
|
|
|
actionArea.tabElmt = $('<li>')
|
|
|
|
.addClass('action-area-tab')
|
|
|
|
.text(actionArea.label)
|
|
|
|
.appendTo($('#action-area-tabs'))
|
|
|
|
.click(function() {
|
|
|
|
Refine.selectActionArea(actionArea.id);
|
|
|
|
});
|
|
|
|
|
|
|
|
actionArea.ui = new actionArea.uiClass(actionArea.bodyElmt);
|
|
|
|
};
|
|
|
|
|
|
|
|
for (var i = 0; i < Refine.actionAreas.length; i++) {
|
|
|
|
renderActionArea(Refine.actionAreas[i]);
|
|
|
|
}
|
|
|
|
Refine.selectActionArea('create-project');
|
2013-07-11 15:01:45 +02:00
|
|
|
|
2018-11-21 16:24:57 +01:00
|
|
|
$("#slogan").text($.i18n._('core-index/slogan')+".");
|
|
|
|
$("#or-index-pref").text($.i18n._('core-index/preferences'));
|
|
|
|
$("#or-index-help").text($.i18n._('core-index/help'));
|
|
|
|
$("#or-index-about").text($.i18n._('core-index/about'));
|
|
|
|
$("#or-index-noProj").text($.i18n._('core-index/no-proj')+".");
|
|
|
|
$("#or-index-try").text($.i18n._('core-index/try-these'));
|
|
|
|
$("#or-index-sample").text($.i18n._('core-index/sample-data'));
|
2011-08-04 22:37:14 +02:00
|
|
|
|
|
|
|
showVersion();
|
2011-08-02 05:34:47 +02:00
|
|
|
});
|