mirror of
https://github.com/misterunknown/ifm.git
synced 2025-08-11 18:43:58 +02:00
add self-detection of api url
This commit is contained in:
16
src/ifm.js
16
src/ifm.js
@@ -5,15 +5,8 @@ function IFM( params ) {
|
|||||||
var self = this; // reference to ourself, because "this" does not work within callbacks
|
var self = this; // reference to ourself, because "this" does not work within callbacks
|
||||||
|
|
||||||
// set the backend for the application
|
// set the backend for the application
|
||||||
if( ! params.api ) {
|
self.api = params.api || window.location.pathname;
|
||||||
throw new Error( "IFM: no backend configured" );
|
|
||||||
} else {
|
|
||||||
self.api = params.api;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.isDocroot = <?php echo realpath( IFMConfig::root_dir ) == dirname( __FILE__ ) ? "true" : "false"; ?>;
|
|
||||||
this.editor = null; // global ace editor
|
this.editor = null; // global ace editor
|
||||||
this.fileChanged = false; // flag for check if file was changed already
|
this.fileChanged = false; // flag for check if file was changed already
|
||||||
this.currentDir = ""; // this is the global variable for the current directory; it is used for AJAX requests
|
this.currentDir = ""; // this is the global variable for the current directory; it is used for AJAX requests
|
||||||
@@ -93,7 +86,7 @@ function IFM( params ) {
|
|||||||
newRow += '><td><a tabindex="0"';
|
newRow += '><td><a tabindex="0"';
|
||||||
var guid = self.generateGuid();
|
var guid = self.generateGuid();
|
||||||
if(data[i].type=="file") {
|
if(data[i].type=="file") {
|
||||||
if( self.isDocroot ) {
|
if( self.config.isDocroot ) {
|
||||||
newRow += ' href="'+self.pathCombine(ifm.currentDir,data[i].name)+'"';
|
newRow += ' href="'+self.pathCombine(ifm.currentDir,data[i].name)+'"';
|
||||||
if( data[i].icon.indexOf( 'file-image' ) !== -1 )
|
if( data[i].icon.indexOf( 'file-image' ) !== -1 )
|
||||||
newRow += ' data-toggle="tooltip" title="<img src=\''+self.pathCombine(self.currentDir,data[i].name)+'\' class=\'imgpreview\'>"';
|
newRow += ' data-toggle="tooltip" title="<img src=\''+self.pathCombine(self.currentDir,data[i].name)+'\' class=\'imgpreview\'>"';
|
||||||
@@ -796,9 +789,10 @@ function IFM( params ) {
|
|||||||
*/
|
*/
|
||||||
this.showMessage = function(m, t) {
|
this.showMessage = function(m, t) {
|
||||||
var msgType = (t == "e")?"danger":(t == "s")?"success":"info";
|
var msgType = (t == "e")?"danger":(t == "s")?"success":"info";
|
||||||
|
var element = ( self.config.inline ) ? self.rootElement : "body";
|
||||||
$.notify(
|
$.notify(
|
||||||
{ message: m },
|
{ message: m },
|
||||||
{ type: msgType, delay: 5000, mouse_over: 'pause', offset: { x: 15, y: 65 } }
|
{ type: msgType, delay: 5000, mouse_over: 'pause', offset: { x: 15, y: 65 }, element: element }
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1192,5 +1186,5 @@ function IFM( params ) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var ifm = new IFM({ api: "ifm.php" });
|
var ifm = new IFM({});
|
||||||
ifm.init( "ifm" );
|
ifm.init( "ifm" );
|
||||||
|
Reference in New Issue
Block a user