Skip to content

Commit

Permalink
Implement rule for importing files
Browse files Browse the repository at this point in the history
  • Loading branch information
dasistwas committed Oct 15, 2023
1 parent 9448729 commit 03d1209
Show file tree
Hide file tree
Showing 42 changed files with 1,251 additions and 108 deletions.
3 changes: 0 additions & 3 deletions amd/build/pdf.min.js

This file was deleted.

1 change: 0 additions & 1 deletion amd/build/pdf.min.js.map

This file was deleted.

3 changes: 0 additions & 3 deletions amd/build/pdf.worker.entry.min.js

This file was deleted.

1 change: 0 additions & 1 deletion amd/build/pdf.worker.entry.min.js.map

This file was deleted.

3 changes: 0 additions & 3 deletions amd/build/pdf.worker.min.js

This file was deleted.

1 change: 0 additions & 1 deletion amd/build/pdf.worker.min.js.map

This file was deleted.

8 changes: 0 additions & 8 deletions amd/build/pdf_backup.min.js

This file was deleted.

1 change: 0 additions & 1 deletion amd/build/pdf_backup.min.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions amd/build/pdfembed.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/pdfembed.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions amd/src/pdf.worker.entry.js

This file was deleted.

34 changes: 15 additions & 19 deletions amd/src/pdfembed.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
* @copyright 2023 David Bogner <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// import 'mod_datalynx/pdf';

import * as pdfjsLib from 'mod_datalynx/pdf';
import pdfjsWorker from 'mod_datalynx/pdf.worker';

// import * as pdfjsLib from 'mod_datalynx/pdf';
// import * as pdfjsWorker from 'mod_datalynx/pdf.worker';

// eslint-disable-next-line require-jsdoc
function renderPDFfunction(url, canvasContainer) {

function renderPage(page) {
Expand All @@ -36,22 +35,13 @@ function renderPDFfunction(url, canvasContainer) {
canvasContext: ctx,
viewport: viewport
};
// Calculate the scaling factors to fit the container's width and height
var widthScale = canvasContainer.clientWidth / viewport.width;
var heightScale = canvasContainer.clientHeight / viewport.height;

// Use the minimum scale to ensure that the entire page fits within the container
var scale = Math.min(widthScale, heightScale);

// Apply the scaling factor
canvas.width = viewport.width * scale;
canvas.height = viewport.height * scale;
var customScale = 1;
var desiredWidth = 595;
var desiredHeight = 841;

// canvas.height = canvasContainer.clientHeight;
// canvas.width = canvasContainer.clientWidth;

// canvas.height = 800;
// canvas.width = 1200;
canvas.height = desiredHeight * customScale;
canvas.width = desiredWidth * customScale;

canvasContainer.appendChild(canvas);

Expand All @@ -75,9 +65,15 @@ function renderPDFfunction(url, canvasContainer) {

}

// eslint-disable-next-line require-jsdoc
/**
*
* @param {*} pdfUrl
* @param {*} canvasContainerId
*/
export function renderPDF(pdfUrl, canvasContainerId) {

console.log(pdfUrl, canvasContainerId);

// eslint-disable-next-line no-unused-vars
const pdf = M.cfg.wwwroot + '/mod/datalynx/tests/turnen.pdf';
const container = document.querySelector(`#${canvasContainerId}`);
Expand Down
11 changes: 5 additions & 6 deletions classes/datalynx.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,15 @@ public function __construct($d = 0, $id = 0) {
* Get datalynx object by instanceid (id of datalynx table)
*
* @param $instanceid
* @return mod_datalynx\datalynx
* @throws \coding_exception
* @return datalynx
*/
public static function get_datalynx_by_instance($instanceid) {
public static function get_datalynx_by_instance($instanceid): datalynx {
$cm = get_coursemodule_from_instance('datalynx', $instanceid);
return new mod_datalynx\datalynx($instanceid, $cm->id);
return new datalynx($instanceid, $cm->id);
}

/**
* Get datalynx id.
* Get datalynx table id. Not cmid.
*
* @return mixed
*/
Expand Down Expand Up @@ -1029,7 +1028,7 @@ public function get_fieldname($key) {
* @param string $sort
* @return datalynxfield_base[]
*/
public function get_fields($exclude = null, $menu = false, $forceget = false, $sort = '') {
public function get_fields($exclude = null, $menu = false, $forceget = false, $sort = ''): array {
global $DB;

if (!$this->fields or $forceget) {
Expand Down
Loading

0 comments on commit 03d1209

Please sign in to comment.