Move OC host/port/protocol helpers to the bundle and deprecate themtags/v17.0.0beta1
@@ -117,7 +117,7 @@ function se(e){for(var t,n=[],a=0,r=-1,i=0;a<e.length;){t=e.charAt(a);var s=!i&& | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/if(void 0===ue){var le=(ue=location.pathname).indexOf("/index.php/");ue=-1!==le?ue.substr(0,le):ue.substr(0,ue.lastIndexOf("/"))}var ce,_e=ue,me=a.a={coreApps:j.i,menuSpeed:j.j,PERMISSION_ALL:j.a,PERMISSION_CREATE:j.b,PERMISSION_DELETE:j.c,PERMISSION_NONE:j.d,PERMISSION_READ:j.e,PERMISSION_SHARE:j.f,PERMISSION_UPDATE:j.g,TAG_FAVORITE:j.h,addScript:function(e,t,n){var a;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return o[r]?n&&n():(a=s.a.Deferred(),s.a.getScript(r,function(){return a.resolve()}),o[r]=a),o[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===d.indexOf(n)&&(d.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=s()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),s()("head").append(t)))},Apps:u.a,AppConfig:_,appConfig:c,appswebroots:m,Backbone:b,ContactsMenu:P.a,config:H,currentUser:E,dialogs:W,EventSource:I,getCurrentUser:function(){return{uid:E,displayName:O}},isUserAdmin:function(){return q},L10N:K,_capabilities:$(),getCapabilities:$,hideMenus:U,registerMenu:function(e,t,n,a){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(J)?U():(J&&U(),!0===a&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(j.j,n),J=t,e))})},showMenu:function(e,t,n){t.is(J)||(U(),J=t,e,t.trigger(new s.a.Event("beforeShow")),t.show(),t.trigger(new s.a.Event("afterShow")),y.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(J)&&U(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],a=0;a<t.length;a++)n.push(encodeURIComponent(t[a]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),a=(t||"").split("/").filter(function(e){return"."!==e});return(e=S.apply(void 0,n))===(t=S.apply(void 0,a))},joinPaths:S,getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return s()("html").prop("lang")},msg:Q,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].attach&&a[r].attach(t,n)},detach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].detach&&a[r].detach(t,n)}},search:ae,Util:oe,debug:de,filePath:Z.a,generateUrl:Z.b,get:(ce=window,function(e){for(var t=e.split("."),n=t.pop(),a=0;a<t.length;a++)if(!(ce=ce[t[a]]))return!1;return ce[n]}),set:function(e){return function(t,n){for(var a=t.split("."),r=a.pop(),i=0;i<a.length;i++)e[a[i]]||(e[a[i]]={}),e=e[a[i]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(N.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:_e}; | |||
*/if(void 0===ue){var le=(ue=location.pathname).indexOf("/index.php/");ue=-1!==le?ue.substr(0,le):ue.substr(0,ue.lastIndexOf("/"))}var ce,_e=ue,me=a.a={coreApps:j.i,menuSpeed:j.j,PERMISSION_ALL:j.a,PERMISSION_CREATE:j.b,PERMISSION_DELETE:j.c,PERMISSION_NONE:j.d,PERMISSION_READ:j.e,PERMISSION_SHARE:j.f,PERMISSION_UPDATE:j.g,TAG_FAVORITE:j.h,addScript:function(e,t,n){var a;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return o[r]?n&&n():(a=s.a.Deferred(),s.a.getScript(r,function(){return a.resolve()}),o[r]=a),o[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===d.indexOf(n)&&(d.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=s()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),s()("head").append(t)))},Apps:u.a,AppConfig:_,appConfig:c,appswebroots:m,Backbone:b,ContactsMenu:P.a,config:H,currentUser:E,dialogs:W,EventSource:I,getCurrentUser:function(){return{uid:E,displayName:O}},isUserAdmin:function(){return q},L10N:K,_capabilities:$(),getCapabilities:$,hideMenus:U,registerMenu:function(e,t,n,a){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(J)?U():(J&&U(),!0===a&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(j.j,n),J=t,e))})},showMenu:function(e,t,n){t.is(J)||(U(),J=t,e,t.trigger(new s.a.Event("beforeShow")),t.show(),t.trigger(new s.a.Event("afterShow")),y.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(J)&&U(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],a=0;a<t.length;a++)n.push(encodeURIComponent(t[a]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),a=(t||"").split("/").filter(function(e){return"."!==e});return(e=S.apply(void 0,n))===(t=S.apply(void 0,a))},joinPaths:S,getHost:function(){return window.location.host},getHostName:function(){return window.location.hostname},getPort:function(){return window.location.port},getProtocol:function(){return window.location.protocol.split(":")[0]},getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return s()("html").prop("lang")},msg:Q,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].attach&&a[r].attach(t,n)},detach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].detach&&a[r].detach(t,n)}},search:ae,Util:oe,debug:de,filePath:Z.a,generateUrl:Z.b,get:(ce=window,function(e){for(var t=e.split("."),n=t.pop(),a=0;a<t.length;a++)if(!(ce=ce[t[a]]))return!1;return ce[n]}),set:function(e){return function(t,n){for(var a=t.split("."),r=a.pop(),i=0;i<a.length;i++)e[a[i]]||(e[a[i]]={}),e=e[a[i]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(N.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:_e}; | |||
/* | |||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | |||
* |
@@ -117,7 +117,7 @@ function oe(e){for(var t,n=[],i=0,r=-1,s=0;i<e.length;){t=e.charAt(i);var o=!s&& | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/if(void 0===ce){var ue=(ce=location.pathname).indexOf("/index.php/");ce=-1!==ue?ce.substr(0,ue):ce.substr(0,ce.lastIndexOf("/"))}var de,he=ce,pe=i.a={coreApps:C.i,menuSpeed:C.j,PERMISSION_ALL:C.a,PERMISSION_CREATE:C.b,PERMISSION_DELETE:C.c,PERMISSION_NONE:C.d,PERMISSION_READ:C.e,PERMISSION_SHARE:C.f,PERMISSION_UPDATE:C.g,TAG_FAVORITE:C.h,addScript:function(e,t,n){var i;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return a[r]?n&&n():(i=o.a.Deferred(),o.a.getScript(r,function(){return i.resolve()}),a[r]=i),a[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===l.indexOf(n)&&(l.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=o()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),o()("head").append(t)))},Apps:c.a,AppConfig:h,appConfig:d,appswebroots:p,Backbone:D,ContactsMenu:E.a,config:S,currentUser:O,dialogs:z,EventSource:B,getCurrentUser:function(){return{uid:O,displayName:P}},isUserAdmin:function(){return q},L10N:K,_capabilities:R(),getCapabilities:R,hideMenus:Q,registerMenu:function(e,t,n,i){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(U)?Q():(U&&Q(),!0===i&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(C.j,n),U=t,e))})},showMenu:function(e,t,n){t.is(U)||(Q(),U=t,e,t.trigger(new o.a.Event("beforeShow")),t.show(),t.trigger(new o.a.Event("afterShow")),_.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(U)&&Q(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],i=0;i<t.length;i++)n.push(encodeURIComponent(t[i]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),i=(t||"").split("/").filter(function(e){return"."!==e});return(e=Y.apply(void 0,n))===(t=Y.apply(void 0,i))},joinPaths:Y,getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return o()("html").prop("lang")},msg:$,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].attach&&i[r].attach(t,n)},detach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].detach&&i[r].detach(t,n)}},search:ie,Util:ae,debug:le,filePath:Z.a,generateUrl:Z.b,get:(de=window,function(e){for(var t=e.split("."),n=t.pop(),i=0;i<t.length;i++)if(!(de=de[t[i]]))return!1;return de[n]}),set:function(e){return function(t,n){for(var i=t.split("."),r=i.pop(),s=0;s<i.length;s++)e[i[s]]||(e[i[s]]={}),e=e[i[s]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(F.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:he}; | |||
*/if(void 0===ce){var ue=(ce=location.pathname).indexOf("/index.php/");ce=-1!==ue?ce.substr(0,ue):ce.substr(0,ce.lastIndexOf("/"))}var de,he=ce,pe=i.a={coreApps:C.i,menuSpeed:C.j,PERMISSION_ALL:C.a,PERMISSION_CREATE:C.b,PERMISSION_DELETE:C.c,PERMISSION_NONE:C.d,PERMISSION_READ:C.e,PERMISSION_SHARE:C.f,PERMISSION_UPDATE:C.g,TAG_FAVORITE:C.h,addScript:function(e,t,n){var i;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return a[r]?n&&n():(i=o.a.Deferred(),o.a.getScript(r,function(){return i.resolve()}),a[r]=i),a[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===l.indexOf(n)&&(l.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=o()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),o()("head").append(t)))},Apps:c.a,AppConfig:h,appConfig:d,appswebroots:p,Backbone:D,ContactsMenu:E.a,config:S,currentUser:O,dialogs:z,EventSource:B,getCurrentUser:function(){return{uid:O,displayName:P}},isUserAdmin:function(){return q},L10N:K,_capabilities:R(),getCapabilities:R,hideMenus:Q,registerMenu:function(e,t,n,i){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(U)?Q():(U&&Q(),!0===i&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(C.j,n),U=t,e))})},showMenu:function(e,t,n){t.is(U)||(Q(),U=t,e,t.trigger(new o.a.Event("beforeShow")),t.show(),t.trigger(new o.a.Event("afterShow")),_.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(U)&&Q(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],i=0;i<t.length;i++)n.push(encodeURIComponent(t[i]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),i=(t||"").split("/").filter(function(e){return"."!==e});return(e=Y.apply(void 0,n))===(t=Y.apply(void 0,i))},joinPaths:Y,getHost:function(){return window.location.host},getHostName:function(){return window.location.hostname},getPort:function(){return window.location.port},getProtocol:function(){return window.location.protocol.split(":")[0]},getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return o()("html").prop("lang")},msg:$,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].attach&&i[r].attach(t,n)},detach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].detach&&i[r].detach(t,n)}},search:ie,Util:ae,debug:le,filePath:Z.a,generateUrl:Z.b,get:(de=window,function(e){for(var t=e.split("."),n=t.pop(),i=0;i<t.length;i++)if(!(de=de[t[i]]))return!1;return de[n]}),set:function(e){return function(t,n){for(var i=t.split("."),r=i.pop(),s=0;s<i.length;s++)e[i[s]]||(e[i[s]]={}),e=e[i[s]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(F.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:he}; | |||
/* | |||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | |||
* |
@@ -18,50 +18,6 @@ Object.assign(window.OC, { | |||
}, | |||
/** | |||
* Protocol that is used to access this Nextcloud instance | |||
* @return {string} Used protocol | |||
*/ | |||
getProtocol: function() { | |||
return window.location.protocol.split(':')[0]; | |||
}, | |||
/** | |||
* Returns the host used to access this Nextcloud instance | |||
* Host is sometimes the same as the hostname but now always. | |||
* | |||
* Examples: | |||
* http://example.com => example.com | |||
* https://example.com => example.com | |||
* http://example.com:8080 => example.com:8080 | |||
* | |||
* @return {string} host | |||
* | |||
* @since 8.2 | |||
*/ | |||
getHost: function() { | |||
return window.location.host; | |||
}, | |||
/** | |||
* Returns the hostname used to access this Nextcloud instance | |||
* The hostname is always stripped of the port | |||
* | |||
* @return {string} hostname | |||
* @since 9.0 | |||
*/ | |||
getHostName: function() { | |||
return window.location.hostname; | |||
}, | |||
/** | |||
* Returns the port number used to access this Nextcloud instance | |||
* | |||
* @return {int} port number | |||
* | |||
* @since 8.2 | |||
*/ | |||
getPort: function() { | |||
return window.location.port; | |||
}, | |||
/** |
@@ -0,0 +1,63 @@ | |||
/* | |||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | |||
* | |||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | |||
* | |||
* @license GNU AGPL version 3 or any later version | |||
* | |||
* This program is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Affero General Public License as | |||
* published by the Free Software Foundation, either version 3 of the | |||
* License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Affero General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
/** | |||
* Protocol that is used to access this Nextcloud instance | |||
* @return {string} Used protocol | |||
* @deprecated 17.0.0 use window.location.protocol directly | |||
*/ | |||
export const getProtocol = () => window.location.protocol.split(':')[0] | |||
/** | |||
* Returns the host used to access this Nextcloud instance | |||
* Host is sometimes the same as the hostname but now always. | |||
* | |||
* Examples: | |||
* http://example.com => example.com | |||
* https://example.com => example.com | |||
* http://example.com:8080 => example.com:8080 | |||
* | |||
* @return {string} host | |||
* | |||
* @since 8.2 | |||
* @deprecated 17.0.0 use window.location.host directly | |||
*/ | |||
export const getHost = () => window.location.host | |||
/** | |||
* Returns the hostname used to access this Nextcloud instance | |||
* The hostname is always stripped of the port | |||
* | |||
* @return {string} hostname | |||
* @since 9.0 | |||
* @deprecated 17.0.0 use window.location.hostname directly | |||
*/ | |||
export const getHostName = () => window.location.hostname | |||
/** | |||
* Returns the port number used to access this Nextcloud instance | |||
* | |||
* @return {int} port number | |||
* | |||
* @since 8.2 | |||
* @deprecated 17.0.0 use window.location.port directly | |||
*/ | |||
export const getPort = () => window.location.port |
@@ -50,6 +50,12 @@ import Dialogs from './dialogs' | |||
import EventSource from './eventsource' | |||
import {get, set} from './get_set' | |||
import {getCapabilities} from './capabilities' | |||
import { | |||
getHost, | |||
getHostName, | |||
getPort, | |||
getProtocol, | |||
} from './host' | |||
import { | |||
getToken as getRequestToken, | |||
subscribe as subscribeToRequestTokenChange, | |||
@@ -157,6 +163,14 @@ export default { | |||
isSamePath, | |||
joinPaths, | |||
/** | |||
* Host (url) helpers | |||
*/ | |||
getHost, | |||
getHostName, | |||
getPort, | |||
getProtocol, | |||
/** | |||
* L10n | |||
*/ |